FS#5529 - wrong time after install

Attached to Project: Arch Linux
Opened by Roman Kyrylych (Romashka) - Thursday, 05 October 2006, 23:10 GMT
Task Type Bug Report
Category System
Status Closed
Assigned To Aaron Griffin (phrakture)
Architecture not specified
Severity Medium
Priority Normal
Reported Version 0.7.2 Gimmick
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Reproduction:
Let assume we have some system where hardware clock shows local time. You can create vmware machine for testing.
Boot from Arch CD (I used latest from tpowa, but I don't think that matters) and install Arch.
During install procedure ensure there is HARDWARECLOCK="localtime" in /etc/rc.conf.
Reboot system. On reboot you can go to BIOS to ensure that the time is still correct.
Now check the time. It will be incorrect.
Why? Because in some way Arch thinks that hardware clock shows time in UTC, and so it adds required timeshift to produce localtime and saves it in BIOS. But it's wrong, because hardware clock already was in localtime!
So, before install I had 14:xx, after install I have 17:xx. That's because my timezone is GMT+0200 and DST time adds 1 hour two - thus 3 hours total. I noticed this on dual-boot system when after installing Arch my Windoze showed me wrong time.

The strange thing is that this happens only on first run. So I examined /etc/rc.sysinit:

if [ "$HARDWARECLOCK" = "UTC" ]; then
/sbin/hwclock --directisa --utc --hctosys
else
/sbin/hwclock --directisa --localtime --hctosys
fi
if [ ! -f /var/lib/hwclock/adjtime ]; then
echo "0.0 0 0.0" > /var/lib/hwclock/adjtime
fi

and /etc/rc.shutdown:

if [ "$HARDWARECLOCK" = "UTC" ]; then
/sbin/hwclock --directisa --utc --systohc
else
/sbin/hwclock --directisa --localtime --systohc
fi

You can see why this time change happens only on first run. Because /var/lib/hwclock/adjtime does not exist at that time. It seems that "/sbin/hwclock --localtime --hctosys" behaves wrong without /var/lib/hwclock/adjtime.
I think generating /var/lib/hwclock/adjtime during install will solve this problem.
This task depends upon

Closed by  Roman Kyrylych (Romashka)
Wednesday, 29 November 2006, 22:49 GMT
Reason for closing:  Fixed
Comment by Roman Kyrylych (Romashka) - Thursday, 05 October 2006, 23:16 GMT
However, generating /var/lib/hwclock/adjtime during install may produce similar problem when doing remote arch install on system with different clock. :-/
Comment by Roman Kyrylych (Romashka) - Monday, 16 October 2006, 10:36 GMT
Another fix:

# replace

if [ "$HARDWARECLOCK" = "UTC" ]; then
/sbin/hwclock --directisa --utc --hctosys
else
/sbin/hwclock --directisa --localtime --hctosys
fi
if [ ! -f /var/lib/hwclock/adjtime ]; then
echo "0.0 0 0.0" > /var/lib/hwclock/adjtime
fi

# with

if [ "$HARDWARECLOCK" = "UTC" ]; then
/sbin/hwclock --directisa --utc --hctosys
else
/sbin/hwclock --directisa --localtime --hctosys
fi
if [ ! -f /var/lib/hwclock/adjtime ]; then
if [ "$HARDWARECLOCK" = "UTC" ]; then
/sbin/hwclock --directisa --utc --systohc
else
/sbin/hwclock --directisa --localtime --systohc
fi
Comment by Roman Kyrylych (Romashka) - Monday, 16 October 2006, 10:40 GMT
Oops, another "fi" should be added after the last line, of course.
Comment by Roman Kyrylych (Romashka) - Saturday, 11 November 2006, 13:28 GMT
No. That fix don't work, because the source of problem was identified incorrectly by me. :)

The real fix is to move
if [ "$TIMEZONE" != "" ]; then
/bin/ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
fi
before
if [ "$HARDWARECLOCK" = "UTC" ]; then
Comment by Tobias Powalowski (tpowa) - Saturday, 11 November 2006, 13:36 GMT
could you post a correct rc.sysinit here please?
Comment by Roman Kyrylych (Romashka) - Saturday, 11 November 2006, 13:42 GMT
Here's a patch
Comment by Roman Kyrylych (Romashka) - Saturday, 11 November 2006, 13:44 GMT Comment by Aaron Griffin (phrakture) - Thursday, 16 November 2006, 01:04 GMT
Added fix in testing/initscripts-0.7.3-1
Please let me know if this resolves it.

Loading...