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:

# /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

… this also means that the stock checkroot/checkfs scripts can be maintained, without having to port custom work-arounds on each update.