Ubuntu – Superblock set in the future, fixing system clock

ext4fsck

I keep getting errors messages about my Superblock mount time being in the future, and insisting on doing fsck on every boot and I have to go in from the recovery options to do this every time.

Here is information I think maybe helpful, I ran these after booting and fsck:

Snipped from dump2fs after fsck 

Last mount time:          Thu Sep 19 17:24:47 2013
Last write time:          Thu Sep 19 17:24:47 2013
Mount count:              14
Maximum mount count:      -1
Last checked:             Thu Sep 19 14:31:17 2013

$ sudo hwclock --debug
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Last drift adjustment done at 1379654884 seconds after 1969
Last calibration done at 1379654884 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2013/09/20 00:28:37
Hw clock time : 2013/09/20 00:28:37 = 1379662117 seconds since 1969
Fri Sep 20 00:28:37 2013  -0.567722 seconds

$ sudo dpkg-reconfigure tzdata
Current default time zone: 'America/Los_Angeles'
Local time is now:      Fri Sep 20 00:32:33 PDT 2013.
Universal Time is now:  Fri Sep 20 07:32:33 UTC 2013.

$ date
Fri Sep 20 00:32:20 PDT 2013

$ cat /proc/driver/rtc 
rtc_time    : 00:32:03
rtc_date    : 2013-09-20
alrm_time   : 23:41:15
alrm_date   : 2013-09-20
alarm_IRQ   : no
alrm_pending    : no
update IRQ enabled  : no
periodic IRQ enabled    : no
periodic IRQ frequency  : 1024
max user IRQ frequency  : 64
24hr        : yes
periodic_IRQ    : no
update_IRQ  : no
HPET_emulated   : yes
BCD     : yes
DST_enable  : no
periodic_freq   : 1024
batt_status : okay

$ cat /etc/adjtime
0.000000 1379654884 0.000000
1379654884
LOCAL

I ran it a second time as soon as possible with one string:

date && hwclock --debug && dumpe2fs /dev/sdc3 | head -50

Fri Sep 20 22:06:11 PDT 2013
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Last drift adjustment done at 1379663788 seconds after 1969
Last calibration done at 1379663788 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2013/09/20 22:06:12
Hw clock time : 2013/09/20 22:06:12 = 1379739972 seconds since 1969
Fri Sep 20 22:06:12 2013  -0.844855 seconds


dumpe2fs 1.42 (29-Nov-2011)

Last mount time:          Fri Sep 20 15:04:39 2013
Last write time:          Fri Sep 20 14:54:16 2013
Mount count:              21
Maximum mount count:      -1
Last checked:             Thu Sep 19 14:31:17 2013

Best Answer

Probably your BIOS battery is failing. This seems to be somewhat common in some models of old laptops. Replacing the battery would probably fix the problem. Another solution that worked for me is to tell e2fsck your clock is broken:

Put the following in /etc/e2fsck.conf:

[options]
broken_system_clock = true

Then you have to get that conf file added to your initramfs.
Put the following into /etc/initramfs-tools/hooks/e2fsck-conf.sh:

#!/bin/sh

PREREQ=""  
prereqs()
{
   echo "$PREREQ"
}

case $1 in
prereqs)
   prereqs
   exit 0
   ;;
esac

. /usr/share/initramfs-tools/hook-functions
CONFFILE=/etc/e2fsck.conf
CONFDIR=`dirname "$CONFFILE"`
if [ -f "$CONFFILE" ]
then 
   mkdir -p ${DESTDIR}${CONFDIR}
   cp $CONFFILE ${DESTDIR}${CONFDIR}
fi

Then execute sudo update-initramfs -u.

Source: Debian user forums. I took the liberty of making the initramfs hook script a bit more verbose. That's purely my stylistic preference.