6

I have a raspberry pi and every reboot I see this output in last:

root@RaspberryPi:~# last | grep boot
reboot   system boot  4.4.0-1055-raspi Thu Jan  1 01:00   still running
reboot   system boot  4.4.0-1055-raspi Thu Jan  1 01:00   still running
reboot   system boot  4.4.0-1055-raspi Thu Jan  1 01:00 - 23:01 (17305+22:01)
reboot   system boot  4.4.0-1055-raspi Thu Jan  1 01:00 - 23:01 (17305+22:01)
reboot   system boot  4.4.0-1055-raspi Thu Jan  1 01:00 - 23:01 (17305+22:01)

This is despite having both fake-hwclock and a hardware RTC installed.

Currently the service for fake-hwclock.service starts before sysinit.target, like this:

[Unit]
Before=sysinit.target

[Service]
ExecStart=/sbin/fake-hwclock load

[Install]
WantedBy=sysinit.target

How do I make it run before /var/log/wtmp is updated?

Roman Gaufman
  • 191
  • 3
  • 11

2 Answers2

1

I believe that this is a bug in systemd-update-utmp. See my comment here: https://github.com/systemd/systemd/issues/6057#issuecomment-435247567

A workaround is to run fake-hwclock in initramfs, before it passes control to the main systemd instance.

Piotr Jurkiewicz
  • 1,900
  • 1
  • 17
  • 17
-1

wtmp "reboot" login records are handled by the systemd-update-utmp systemd service. It must start before the sysinit target which means before that start is complete this service will start IF it wasn't started already. It does not mean that systemd-timesyncd will necessarily start before systemd-update-utmp.

I tested on my arch linux server and consistently systemd-timesyncd always runs well before systemd-update-utmp however. On the other hand they are almost always one pid away from each other.

But since it isn't explicitly running after NTP I suppose this should still be considered a bug.

From the systemd manual:

"After= is the inverse of Before=, i.e. while After= ensures that the configured unit is started after the listed unit finished starting up"

https://www.freedesktop.org/software/systemd/man/systemd.unit.html

What you should do:

systemctl edit systemd-update-utmp

[Unit]
After=systemd-timesyncd.service
Wants=systemd-timesyncd.service
jdwolf
  • 4,887
  • 1
  • 13
  • 28