[Bug 563618] Re: Ignoring a broken clock results in infinite reboots; not ignoring results in fsck failure; no solution to this problem

Oliver Grawert ogra at ubuntu.com
Fri Apr 16 13:02:59 UTC 2010


here is a proof of concept code snippet (untested yet) we could put in
initramfs to work around the issue ...

#!/bin/sh
#
# use the fixrtc cmdline option in your bootloader to
# automatically set the hardware clock to the date of
# the last mount of your root filesystem to avoid fsck
# to get confused by the superblock being in the future

BROKEN_CLOCK=""

for x in $(cat /proc/cmdline); do
	case ${x} in
	root=*)
		UUID=${x#*=}
		UUID="${UUID#*=}"
	;;
	fixrtc)
		BROKEN_CLOCK=1
	;;
	esac
done

if [ -n $BROKEN_CLOCK ];then
	ROOTDISK=$(readlink -f /dev/disk/by-uuid/$UUID)

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

	DISKYEAR=$(date -d "${TIME}" +%Y)
	CLOCKYEAR=$(date +%Y)

	if [ $DISKYEAR -gt $CLOCKYEAR ]; then
		hwclock --set --date="${TIME}"
	fi
fi

-- 
Ignoring a broken clock results in infinite reboots; not ignoring results in fsck failure; no solution to this problem
https://bugs.launchpad.net/bugs/563618
You received this bug notification because you are a member of Kernel
Bugs, which is subscribed to util-linux in ubuntu.




More information about the kernel-bugs mailing list