24

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.

3
  • What this would usually enable/disable is systemd-timesyncd (works fine for me in a new and clean Focal VM btw). You could try checking what this reports and add it to the question systemctl status systemd-timesyncd Feb 8, 2021 at 9:36
  • @ChristianEhrhardt: Please see the updated post.
    – mahmood
    Feb 9, 2021 at 10:26
  • In case you end up here with the issue (the message) on Amazon Linux. timesyncd is not available there. Use chrony or something.
    – x-yuri
    Jan 4, 2022 at 18:05

2 Answers 2

39

This worked for me on Ubuntu:

Install NTP:

apt install systemd-timesyncd

Activate NTP:

timedatectl set-ntp true
4
  • 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 3, 2021 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. Dec 2, 2021 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 Dec 2, 2021 at 17:20
  • this just helped us as well, I think this one should be the accepted answer here
    – morhekil
    May 10, 2022 at 7:39
15

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.