Jan 29 2011
Working around the lack of an RTC battery on ALIX system boards…
The ALIX 2c3 system board the forms my traffic-shaper has one irksome weakness: it lacks an on-board CMOS/RTC battery to maintain the time when the system is shutdown.
This is a more significant problem than it sounds since, for starters, the fsck tools for the ext2 filesystem, by default, treat a timestamp in the future as a failure – and disk checks have to be performed almost immediately on system start, so there is no opportunity to raise networking and start an NTP dæmon.
After some consideration, the best solution (without soldering in a battery – an option which this board supports) struck me as resetting timestamps on critical items immediately prior to reboot:
[cc lang=”bash” width=”0″ line_numbers=”false” theme=”geshi”]# /etc/conf.d/local.stop
# This is a good place to unload any misc.
# programs you started above.
# For example, if you are using OSS and have
# “/usr/local/bin/soundon” above, put
# “/usr/local/bin/soundoff” here.
# The ALIX 2c3 has no RTC, and so the system thinks that the date
# is 01/01/2000, which breaks fsck (last mount time is in the future)
# and the init system.
# This is crazy, but may fix things…
umount -f /dev/sda1 >/dev/null 2>&1
date -u 010100001979.00 >/dev/null 2>&1
touch /etc/rc.conf /etc/conf.d /etc/conf.d/* /etc/init.d /etc/init.d/*
tune2fs -T now /dev/sda1
mount /dev/sda1 /boot -o rw,noatime
true[/cc]
… this also means that the stock checkroot/checkfs scripts can be maintained, without having to port custom work-arounds on each update.
Stuart
14th May 2011 @ 3:57 pm
Since baselayout-2 and OpenRC were stabilised last weekend, there’s now a much better approach to the above which entirely replaces the use of /etc/conf.d/local.stop (now replaced by individual scripts in /etc/local.d/) documented above:
Simply remove “hwclock” from the “boot” run-level, and add “swclock” in its place – simple as that!