Hello all, For jessie+1/experimental onward, we'll fix this properly by enabling timesyncd by default. It won't start if ntp or similar are installed. This will make sure that the hw clock will be updated often enough, and we won't poke false data into it:
http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/commit/?h=experimental&id=929bece5326 This is a new feature though, and as such most probably not appropriate for jessie at this point. For master (i. e. testing/jessie), I prepared and tested the attached patch. I'm still kind of hesitant to apply it as it's solving the problem in a rather questionable, insufficient, and conceptually wrong way. However, with that it would stay "bug compatible" with sysvinit in jessie. Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
From 74563299c38608afac0ab79e6926d74d9e26e853 Mon Sep 17 00:00:00 2001 From: Martin Pitt <martin.p...@ubuntu.com> Date: Mon, 16 Feb 2015 16:14:23 +0100 Subject: [PATCH] Add hwclock.service to sync the system clock to the hardware clock on shutdown This provides monotonic time for reboots. Thanks to Stefan Fritsch for the initial unit. Note: this is a hack for jessie; the next Debian release will enable timesyncd by default. Closes: #755722 --- debian/changelog | 9 +++++++++ debian/extra/hwclock.service | 14 ++++++++++++++ debian/rules | 2 +- debian/systemd.links | 3 ++- debian/systemd.postinst | 4 ++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 debian/extra/hwclock.service diff --git a/debian/changelog b/debian/changelog index 6d81277..4ebc8af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +systemd (215-13) UNRELEASED; urgency=medium + + * Add hwclock.service to sync the system clock to the hardware clock on + shutdown, to provide monotonic time for reboots. (Note: this is a hack for + jessie; the next Debian release will enable timesyncd by default). + (Closes: #755722) + + -- Martin Pitt <mp...@debian.org> Mon, 16 Feb 2015 16:11:12 +0100 + systemd (215-12) unstable; urgency=medium [ Martin Pitt ] diff --git a/debian/extra/hwclock.service b/debian/extra/hwclock.service new file mode 100644 index 0000000..1e0f99a --- /dev/null +++ b/debian/extra/hwclock.service @@ -0,0 +1,14 @@ +[Unit] +Description=Synchronise Hardware Clock to System Clock +DefaultDependencies=no +Before=shutdown.target +ConditionFileIsExecutable=!/usr/sbin/ntpd +ConditionFileIsExecutable=!/usr/sbin/openntpd +ConditionFileIsExecutable=!/usr/sbin/chrony + +[Service] +Type=oneshot +ExecStart=/sbin/hwclock -D --systohc + +[Install] +WantedBy=reboot.target halt.target poweroff.target diff --git a/debian/rules b/debian/rules index 4f79678..5d69e86 100755 --- a/debian/rules +++ b/debian/rules @@ -183,7 +183,7 @@ override_dh_install: debian/systemd/lib/lsb/init-functions.d/40-systemd install --mode=644 debian/tmpfiles.d/debian.conf \ debian/systemd/usr/lib/tmpfiles.d/ - install --mode=644 debian/debian-fixup.service debian/ifup@.service debian/extra/getty-static.service \ + install --mode=644 debian/debian-fixup.service debian/ifup@.service debian/extra/getty-static.service debian/extra/hwclock.service \ debian/systemd/lib/systemd/system/ install -D --mode=644 debian/extra/network-pre.conf \ debian/systemd/lib/systemd/system/networking.service.d/network-pre.conf diff --git a/debian/systemd.links b/debian/systemd.links index 74ab5a7..1c29732 100644 --- a/debian/systemd.links +++ b/debian/systemd.links @@ -31,7 +31,8 @@ # systemd sets the hwclock internally # http://cgit.freedesktop.org/systemd/systemd/commit/?id=7948c4dfbea73ac21250b588089039aa17a90386 -/dev/null /lib/systemd/system/hwclock.service +# we ship a replacement hwclock.service for shutdown, but disable the other one +# from util-linux /dev/null /lib/systemd/system/hwclockfirst.service # We use native mount support so mask those services diff --git a/debian/systemd.postinst b/debian/systemd.postinst index 488df32..f5c9913 100644 --- a/debian/systemd.postinst +++ b/debian/systemd.postinst @@ -131,6 +131,10 @@ if dpkg --compare-versions "$2" lt "214-1"; then systemctl enable remote-fs.target || true fi +if dpkg --compare-versions "$2" lt "215-12"; then + systemctl enable hwclock.service || true +fi + # Re-run systemctl enable for any service that was enabled when preinst was run. if dpkg --compare-versions "$2" ge "204"; then while read UNIT ; do -- 2.1.4
signature.asc
Description: Digital signature
_______________________________________________ Pkg-systemd-maintainers mailing list Pkg-systemd-maintainers@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-systemd-maintainers