fixrtc kernel option always sets system time

Bug #947988 reported by Svein Seldal on 2012-03-06
This bug affects 1 person
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)
Oliver Grawert
Oliver Grawert

Bug Description

On Natty armel, the kernel option 'fixrtc' exists to set the system time from the last mount time from the rootfs. This allows systems which does not have a valid RTC time at startup to be able to boot of the root file system.

When the 'fixrtc' option is used, the system time is set to the last mount time, regardless if the system time is already set to something valid. There should be a comparison between the current system time and the last mount time. The fixrtc should only come into play if the system time is less than the last mount time of the fs.

Oliver Grawert (ogra) wrote :

could you try this patch (regenerate your initrd after applying it to /usr/share/initramfs-tools/scripts/local-premount/fixrtc):

--- /usr/share/initramfs-tools/scripts/local-premount/fixrtc 2010-04-26 16:59:13.000000000 +0200
+++ fixrtc 2012-03-06 14:47:49.580000000 +0100
@@ -50,12 +50,19 @@

 if [ -n "$BROKEN_CLOCK" -a -n "$ROOTDEV" ];then
- ROOTDISK=$(readlink -f "$ROOTDEV") &&
+ ROOTDISK=$(readlink -f "$ROOTDEV")

- TIMESTR=$(dumpe2fs -h "$ROOTDISK" 2>/dev/null|grep "Last mount time") &&
- TIME=${TIMESTR#*:} &&
+ TIMESTR=$(dumpe2fs -h "$ROOTDISK" 2>/dev/null|grep "Last mount time")

- date --set="${TIME} 1 minute" >/dev/null 2>&1
+ hwclock -s
+ MOUNTTIME=$(date --utc --date "${TIME}" +%s)
+ CURDATE=$(date --utc --date "$(date)" +%s)
+ if [ "$MOUNTTIME" -gt "$CURDATE" ]; then
+ date --set="${TIME} 1 minute" >/dev/null 2>&1
+ fi

 # This script is best-effort. If we couldn't fudge the clock as desired,

Changed in initramfs-tools (Ubuntu):
importance: Undecided → High
status: New → Triaged
assignee: nobody → Oliver Grawert (ogra)
Changed in initramfs-tools (Ubuntu Precise):
milestone: none → ubuntu-12.04-beta-2
Oliver Grawert (ogra) wrote :

hmpf, LP messes up the stlye, added as a proper patch now

tags: added: patch
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package initramfs-tools - 0.99ubuntu11

initramfs-tools (0.99ubuntu11) precise; urgency=low

  * make sure fixrtc only updates the RTC setting if last mount time is actually
    in the future (LP: #947988)
 -- Oliver Grawert <email address hidden> Wed, 07 Mar 2012 12:33:58 +0100

Changed in initramfs-tools (Ubuntu Precise):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers