[systemd-devel] systemd-timesyncd with read-only root filesystem

André Hartmann andre.hartmann at iseg-hv.de
Fri Dec 9 13:18:17 UTC 2016


Hi Michael,

Am 09.12.2016 um 12:43 schrieb Michael Chapman:
> On Fri, 9 Dec 2016, Michael Chapman wrote:
> [...]
>> You will need to use the .service extension on at least the first of
>> those links. systemd will only consider links in that directory that
>> have valid unit names. (I'm pretty sure the intermediate link's name
>> doesn't matter, but I wouldn't want to rely on that -- best just to
>> use valid full unit names everywhere.)
>
> Oh, something else I thought of... I'm pretty sure it doesn't make sense
> having a symlink to /dev/null inside a .wants directory. Really, only
> the name of those links are considered. The links aren't actually
> dereferenced.

I have to disagree on this, the name does not matter, the link target 
does matter (see log below, the relevant status is marked with <---).

If I create a link named foo pointing to 
/lib/systemd/system/systemd-timesyncd.service the service is enabled and 
started. If I delete the link, the service is disabled and not started. 
Everything is fine. But it requires write access to /etc.

If I create a link structure like this:

/etc/systemd/system/sysinit.target.wants/systemd-timesyncd ->
/mnt/writeable/systemd-timesyncd ->
/lib/systemd/system/systemd-timesyncd.service

the service is also started (Good).

But if I then change the structure to

/etc/systemd/system/sysinit.target.wants/systemd-timesyncd ->
/mnt/writeable/systemd-timesyncd ->
/dev/null

timedatectl still says "NTP is enabled".

And at this point I don't know how to proceed.

Best regards,
André

Log:

$ ssh root at 192.168.16.14
Password:

root at apalis-imx6:~# rm 
/etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service

root at apalis-imx6:~# reboot
Connection to 192.168.16.14 closed by remote host.

$ ssh root at 192.168.16.14
Password:

root at apalis-imx6:~# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
    Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service;
    disabled; vendor preset: enabled)                              <---
    Active: inactive (dead)
      Docs: man:systemd-timesyncd.service(8)

root at apalis-imx6:~# timedatectl
       Local time: Fri 2016-12-09 13:20:46 UTC
   Universal time: Fri 2016-12-09 13:20:46 UTC
         RTC time: n/a
        Time zone: Universal (UTC, +0000)
      NTP enabled: no                                              <----
NTP synchronized: no
  RTC in local TZ: no
       DST active: n/a

root at apalis-imx6:~# cd /etc/systemd/system/sysinit.target.wants/
root at apalis-imx6:/etc/systemd/system/sysinit.target.wants# mount-rw /
root at apalis-imx6:/etc/systemd/system/sysinit.target.wants# ln -s 
/lib/systemd/system/systemd-timesyncd.service foo
root at apalis-imx6:/etc/systemd/system/sysinit.target.wants# ll foo
lrwxrwxrwx    1 root     root            45 Dec  9 13:21 foo -> 
/lib/systemd/system/systemd-timesyncd.service

root at apalis-imx6:/etc/systemd/system/sysinit.target.wants# reboot
Connection to 192.168.16.14 closed by remote host.

$ ssh root at 192.168.16.14
Warning: Permanently added '192.168.16.14' (ECDSA) to the list of known 
hosts.
Password:

root at apalis-imx6:~# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
    Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service;
    enabled; vendor preset: enabled)                                 <---
    Active: inactive (dead)
      Docs: man:systemd-timesyncd.service(8)

root at apalis-imx6:~# timedatectl
       Local time: Fri 2016-12-09 13:21:51 UTC
   Universal time: Fri 2016-12-09 13:21:51 UTC
         RTC time: n/a
        Time zone: Universal (UTC, +0000)
      NTP enabled: yes                                               <---
NTP synchronized: no
  RTC in local TZ: no
       DST active: n/a

root at apalis-imx6:~#


More information about the systemd-devel mailing list