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
Task Type Bug Report
Category System
Status Closed
Assigned To Judd Vinet (judd)
Architecture not specified
Severity Low
Priority Normal
Reported Version 0.7.2 Gimmick
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

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

Closed by  Roman Kyrylych (Romashka)
Monday, 18 December 2006, 21:12 GMT
Reason for closing:  Fixed
Comment by eliott (cactus) - Sunday, 15 October 2006, 03:49 GMT
yup. i get this too.
fully up to date, fresh install as of 10-14-2006
Comment by eliott (cactus) - Sunday, 15 October 2006, 04:05 GMT
New info.
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.
Comment by Roman Kyrylych (Romashka) - Sunday, 15 October 2006, 08:50 GMT
Hmm... haven't noticed this problem, but I will check if it exists for me too.
I have a similar problem with time reported here: http://bugs.archlinux.org/task/5529
Maybe these two bugs can be fixed at once?
Comment by Dimos Dimoulis (dimosd) - Tuesday, 17 October 2006, 14:22 GMT
I had reported the problem with wrong time after first boot in http://bugs.archlinux.org/task/5444 (should be marked as duplicate of 5529), but imho it's not related to this one.

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.
Comment by Roman Kyrylych (Romashka) - Monday, 13 November 2006, 22:12 GMT
> 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.

How to setup clock and timezone without mounting / ?
Comment by Dimos Dimoulis (dimosd) - Tuesday, 14 November 2006, 14:40 GMT
The time stamp on the file system is updated only when it's mounted read-write. Initially the root file system is mounted read only, which gives us the chance to update the clock among other things, then it's remounted read-write.

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.
Comment by Roman Kyrylych (Romashka) - Wednesday, 15 November 2006, 09:02 GMT
> 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.
Comment by Roman Kyrylych (Romashka) - Saturday, 02 December 2006, 18:44 GMT
Is this bug still valid with testing/initscripts-0.7.3-1 ?
Comment by Dimos Dimoulis (dimosd) - Sunday, 03 December 2006, 22:27 GMT
Yes, please keep this open for now.
Comment by Roman Kyrylych (Romashka) - Thursday, 14 December 2006, 13:30 GMT
dimosd, does removing lines that do symlinking of /etc/localtime from rc.sysinit and copying required file in place of /etc/localtime solves the issue?
Comment by Roman Kyrylych (Romashka) - Saturday, 16 December 2006, 18:21 GMT
Here is the patch that solves the issue. Please test it and confirm if it works.
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).
Comment by Roman Kyrylych (Romashka) - Saturday, 16 December 2006, 19:44 GMT
Here's the second version of patch that fixes the issue while not making  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.
Comment by Dimos Dimoulis (dimosd) - Sunday, 17 December 2006, 02:11 GMT
Thank you for your patch. There's an issue that comes up if /usr or /var reside on partitions of their own.
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.
Comment by Roman Kyrylych (Romashka) - Sunday, 17 December 2006, 10:31 GMT
Well, I didn't think about /usr and /var on different partitions, thanks for poiting this out.
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.
Comment by Roman Kyrylych (Romashka) - Sunday, 17 December 2006, 10:37 GMT
1) generate /etc/localtime from installer == cp it, not ln -sf, of course.

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).
Comment by Roman Kyrylych (Romashka) - Monday, 18 December 2006, 09:22 GMT
Today initscripts-0.8-1 hit Current. They contain changes made by tpowa, but they _do_not_ fix the issue properly.
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.
Comment by Roman Kyrylych (Romashka) - Monday, 18 December 2006, 09:30 GMT
And please fix the installer before making official 0.8 ISOs.
Comment by Roman Kyrylych (Romashka) - Monday, 18 December 2006, 10:25 GMT
New patch, requires installer to cp zoneinfo file to /etc/localtime
Doesn't violate FHS. Works correctly with /usr and/or /var on different partitions that /.
Comment by Roman Kyrylych (Romashka) - Monday, 18 December 2006, 10:50 GMT
Oh, forgot to mention that it was fagainst 0.7.2 (I haven't updated system to 0.8 yet), sorry.
Here's a patch against initscripts-0.8-1

Loading...