live-config: Wrong time when RTC is set to local time

Santiago García Mantiñán manty at debian.org
Mon Nov 27 13:42:14 GMT 2017


Package: live-config
Version: 5.20170112
Severity: normal

Hi!

This may be a follow up of #824197, I believe that the patches that were
introduced then don't fix the problem, at least not now.

I'm testing this on a live network image which was built using stretch and
has as boot parameters:
boot=live components config hostname=coru username=debian locales=es_ES.UTF-8,gl_ES.UTF-8 keyboard-layouts=es timezone=Europe/Madrid utc=no netboot=cifs nfsroot=//10.10.50.10/debian-live-amd64 noroot quiet

The important part here is that the clock is supposed to be in local time
(we have the utc=no to signal this and indeed the /etc/adjtime on the live
system file says LOCAL) and we are on CET (timezone=Europe/Madrid).

However, the system adds 1 hour to the rtc even though we are saying that it
is on local time anyway.

I believe that systemd is reading /etc/adjtime before live systems adds the
LOCAL label to it, or something similar (this is just my thought, no
evicence pointing at this yet). This is what timedatectl says after booting:

      Local time: jue 2017-11-23 09:25:36 CET
  Universal time: jue 2017-11-23 08:25:36 UTC
        RTC time: jue 2017-11-23 08:25:35
       Time zone: Europe/Madrid (CET, +0100)
 Network time on: yes
NTP synchronized: no
 RTC in local TZ: yes

As you can see it detects that we have the rtc on local time however the
info is incoherent, it is showing that the rtc has 8:25 and utc is is 8:25
with a TZ of +1 and the RTC in local TZ :-(

I did contact Raphael Hertzog about this and he was so kind to produce a
patch on which we changed live-config to use timedatectl instead of just
changing /etc/adjtime, but this didn't help either.  Here is Raphael's patch
with a little typo fixed:

diff --git a/components/1120-util-linux b/components/1120-util-linux
index 8bb45e5..b078df5 100755
--- a/components/1120-util-linux
+++ b/components/1120-util-linux
@@ -43,25 +43,24 @@ Config ()
 	then
 		case "${LIVE_UTC}" in
 			yes)
-
-cat > /etc/adjtime << EOF
-0.0 0 0.0
-0
-UTC
-EOF
-
+				set_local_rtc=0
+				adjtime=UTC
 				;;
 
 			no)
-
-cat > /etc/adjtime << EOF
-0.0 0 0.0
-0
-LOCAL
-EOF
-
+				set_local_rtc=1
+				adjtime=LOCAL
 				;;
 		esac
+		if which timedatectl >/dev/null 2>&1; then
+			timedatectl set-local-rtc $set_local_rtc --adjust-system-clock
+		else
+			cat > /etc/adjtime <<-EOF
+			0.0 0 0.0
+			0
+			$adjtime
+			EOF
+		fi
 	fi
 
 	# Creating state file

The problem seems to be that when this script is run timedatectl doesn't
have enough services to be able to do anything, so it doesn't do a thing.

I have done some tests and at the time 1120-util-linux just a few systemd
services are running:
root       441  0.6  0.4  39176  4400 ?        Ss   15:04   0:00 /lib/systemd/systemd-journald
systemd+   492  0.4  0.4 129344  4192 ?        Ssl  15:04   0:00 /lib/systemd/systemd-timesyncd
in fact, no other service is running except for init, lvmetad, the kernel
processes and live-config itself.

So...  the question here is...  how to we tell systemd at this time of the
boot process that we have the RTC in LOCAL time if setting LOCAL on third
line of /etc/adjtime at this time doesn't work and we cannot use timedatectl?

I have tested this both with live-config from stable and unstable.

If you want me to do any tests or need any other info just let me know.

Regards.


Kernel: Linux 4.9.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=gl_ES.UTF-8, LC_CTYPE=gl_ES.UTF-8 (charmap=UTF-8), LANGUAGE=gl_ES.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages live-config depends on:
ii  live-config-systemd [live-config-backend]  5.20170112+nmu1

Versions of packages live-config recommends:
ii  iproute2                4.9.0-1
ii  keyboard-configuration  1.164
ii  live-config-doc         5.20170112
pn  live-tools              <none>
ii  locales                 2.24-11+deb9u1
ii  locales-all             2.24-11+deb9u1
ii  sudo                    1.8.19p1-2.1
pn  user-setup              <none>

Versions of packages live-config suggests:
ii  pciutils  1:3.5.2-1
ii  wget      1.18-5+deb9u1

-- no debconf information



More information about the Pkg-systemd-maintainers mailing list