YDL 2.2, hwclock & separate /usr partition: system clock changes btw. reboots

Jussi-Pekka Mantere yellowdog-general@lists.terrasoftsolutions.com
Tue Apr 9 16:22:01 2002


When using a from scratch YDL 2.2 installation I noticed that my system 
clock kept changing by several hours between reboots. I had set up a 
separate /usr partition and when rc.sysinit reads the system clock with 
/sbin/hwclock --hctosys --localtime it doesn't have access to the time 
zone info as /etc/localtime is a symbolic link to 
/usr/share/zoneinfo/... and the file system isn't mounted when hwclock 
is run. When hwclock is run at shutdown, now with access to the zone 
info, it sets the hardware clock off by several hours (delta btw. the 
current system time zone and UTC.)

If 'grep localtime /var/log/messages' shows

rc.sysinit: Setting clock  (localtime): Tue Apr  9 02:34:12 UTC 2002 
succeeded

as opposed to

rc.sysinit: Setting clock  (localtime): Tue Apr  9 02:34:12 PDT 2002 
succeeded

then the system in question has this problem. Running xntpd or such 
naturally masks this.

The symptom can be demonstrated by:

#! /bin/sh
date
mv /etc/localtime /etc/localtime.badsymlink
date
/sbin/hwclock --hctosys --localtime
date
mv /etc/localtime.badsymlink /etc/localtime
date
/sbin/hwclock --hctosys --localtime
date

The fix for this is to populate the /usr/share/zoneinfo directory on the 
root file system so that even without the /usr file system mounted the 
/etc/localtime symlink is still valid. Easiest way to do this is to boot 
into single user mode to do the copy:

- from yaboot boot into "linux single"
- once in the shell, unmount /usr and mount the partition on /mnt
- copy over the usr/share/zoneinfo from /mnt to /
- remount the usr partition under /usr
- exit from shell to continue booting

#! /bin/sh
umount /usr
mount /dev/hda[USR] /mnt
cd /mnt
find usr/share/zoneinfo -depth -print | cpio -pmad /
cd /
umount /mnt
mount /dev/hda[USR] /usr

YMMV.