33

In Ubuntu 20.04, I see that I can not change the set-ntp due to the following error.

# timedatectl set-ntp true
Failed to set ntp: NTP not supported

Any way to fix that?

UPDATE:

It seems that systemd-timesyncd fails with the start command.

$ systemctl status systemd-timesyncd
● systemd-timesyncd.service
     Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
     Active: inactive (dead)
$ sudo systemctl start systemd-timesyncd
Failed to start systemd-timesyncd.service: Unit systemd-timesyncd.service is masked.

Solution

Using the command sudo timedatectl set-ntp yes the problem is now fixed.

mahmood
  • 1,875

2 Answers2

50

This worked for me on Ubuntu:

Install NTP:

apt install systemd-timesyncd

Activate NTP:

timedatectl set-ntp true
  • 1
    The OP indicates that systemd-timesyncd is already installed, but configured not to start. This will not do anything useful to solve the problem. – Paul Gear Nov 03 '21 at 23:51
  • 1
    @PaulGear My system didn't have systemd-timesyncd but behaved just as OP indicated. OP has not stated that it is already installed. As it stands, this answer has solved my issue. I fail to understand why systemd-timesyncd is recognized as masked when the package is not installed. – MariusSiuram Dec 02 '21 at 17:17
  • ... and let me say thanks and comment that a Raspberry Pi installed with Raspbian 11 bullseye solved its issues by following your steps :) Just in case somebody in the future ends up here with Raspberry Pi issues – MariusSiuram Dec 02 '21 at 17:20
  • this just helped us as well, I think this one should be the accepted answer here – morhekil May 10 '22 at 07:39
  • +1 This also works on raspberry pi – user000001 Jul 13 '23 at 09:17
17

Your systemd-timesyncd service is masked. That means it can't be started, and can't be enabled. To reverse this, you need to run the following:

systemctl unmask systemd-timesyncd.service

Then you can enable and start the service:

systemctl enable systemd-timesyncd.service
systemctl start systemd-timesyncd.service

HOWEVER, it's pretty unlikely that your system got into this state on its own. Perhaps you followed some instructions to enable a more full-featured NTP server, like chronyd or ntpd? I recommend double-checking that they aren't installed before you proceed with the above method:

systemctl status chronyd.service
systemctl status ntp.service

If either of the above commands returns a good status, I recommend that you leave systemd-timesyncd disabled and masked.

Paul Gear
  • 464