FS#5445 - Wrong last mount & check time in partitions
Attached to Project:
Arch Linux
Opened by Dimos Dimoulis (dimosd) - Monday, 25 September 2006, 13:23 GMT
Last edited by Roman Kyrylych (Romashka) - Wednesday, 08 November 2006, 23:30 GMT
Opened by Dimos Dimoulis (dimosd) - Monday, 25 September 2006, 13:23 GMT
Last edited by Roman Kyrylych (Romashka) - Wednesday, 08 November 2006, 23:30 GMT
|
Details
The partitions are mounted read-write and checked before the
clock has been set up. If the hardware clock is in local
time, the time stamp for last mount and last check time will
be wrong (in my time zone, a few hours in the future).
After going through an automatic fsck of an ext3 partition in Arch, I booted in another Linux distribution. The last check time was found invalid and it fsck'ed the partition once again. Is there a way to set the clock earlier, before mounting everything? This would need to copy rather than symlink the appropriate zoneinfo to /etc/localtime, and parhaps not use /var/lib/hwclock/adjtime. |
This task depends upon
fully up to date, fresh install as of 10-14-2006
I just pasted the following:
"/sbin/hwclock --directisa --localtime --hctosys"
above the "status "Mounting Root Read-only" /bin/mount -n -o remount,ro /"
line in rc.sysinit
This is a kludge, for my needs. it works.
A better solution, would likely be to move the entire section for syncing the localtime from the system time, to before the fsck section.
I have a similar problem with time reported here: http://bugs.archlinux.org/task/5529
Maybe these two bugs can be fixed at once?
This is simply caused because the clock is set up too late, after filesystems are mounted and fsck'd, which causes a problem if local time is used.
The other problem could be because zoneinfo is wrong (GMT?) on first boot. I don't think adjtime is related.
How to setup clock and timezone without mounting / ?
This can't work right now because rc.sysinit wants to update the symlink /etc/localtime according to what rc.conf says. A minimal workaround would be to update the symlink during shutdown instead of startup.
It also wants to update adjtime. (At least in Debian it's disabled for causing problems more often that not, which agrees with my experience).
Perhaps updating /etc/localtime at boot time is a systematically wrong way to handle the task - I think it was the cause of #5444 as well.
Well, yes. I don't see the reason of updating /etc/localtime on _each_ boot.
On install - yes. And then only when user moves with his PC/notebook to another timezone.
Note that it require symlinking of /etc/localtime to be done by installer, otherwise
bug 5444/5529 will be valid again.I'm working on version that wouldn't require changes to the installer (useful for users installing with 0.7.2 installer from FTP or fresh package mirror on CD/HDD).
bug 5444/5529 valid again and not requiring any changes to installer.Note that this is temporary solution until the fix in official installer will be available (which should happen in 0.8, I hope), the first solution is much cleaner and elegant, while the second version is more like a hack, so it should be changed to first version when installer will be modified to do symlinking /etc/localtime by itself.
I am attaching a commented patch based on your first patch, intended for demonstration. I believe it treats the problem correctly (not necessarily optimally) but it needs the installer to be updated. Perhaps this bug fix can wait until then. Otherwise an updated version of initscripts or util-linux (hwclock) can place a correct /etc/localtime as a one time fix with its installation script (perhaps even during initial installation).
Please also give some thought to whether we should stop updating /etc/localtime according to what $TIMEZONE in rc.conf says and only rely on the installer.
I think better solution will be:
1) generate /etc/localtime from installer
2) remove that sed line from util-linux PKGBUILD that changes /etc/adjtime to /var/lib/hwclock/adjtime
3) do not do hwclock --hctosys for the second time, there's no need for it when there is /etc/adjtime
4) initializing /etc/adjtime can safely be done after reading hwclock, anyway there won't be any error when /etc/adjtime doesn't exist
5) replace ln -sf with cp in rc.shutdown, and keep TIMEZONE in rc.conf
So, my first patch should be modified to use /etc/adjtime and cp instead of ln.
Copying /etc/localtime in initscripts' or util-linux' .install file will be good for those who install with old installer but fresh package db (FTP or fresh mirror on CD).
1) /etc/localtime will not work when /usr is on different partition than /, so hwclock --hctosys will set wrong time.
2) when user changes TIMEZONE in rc.conf, on next boot first hwclock will set time for old timezone, then after fs check time will be changed.
I _highly_ recommend to fix the issue as in my first patch, with corrections made by dimosd me and me later.
Doesn't violate FHS. Works correctly with /usr and/or /var on different partitions that /.
Here's a patch against initscripts-0.8-1