How to avoid “Run fsck manually” messages while allowing experimenting with system time changes

bootdatefsckrhel

I'm working with a system where we want to allow users to play around with the date and time if they want, and where reboots may happen arbitrarily. This is fine, except for one thing: if there's a large time jump backwards, the following error appears on reboot:

Checking filesystems
IMAGE2: Superblock last mount time (Tue Mar  1 17:32:48 2011,
        now = Thu Feb 24 17:34:29 2011) is in the future.

IMAGE2: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
        (i.e., without -a or -p options)

*** An error occurred during the file system check.
*** Dropping you to a shell; the system will reboot
*** when you leave the shell.

…and then the boot hangs waiting for user console input, and even once console access is gained, requires a root password to continue.

This is decidedly less than ideal. Is there any way to either skip the check or force the check to happen automatically on reboot?

Google has only provided help that requires running fsck manually if/when this is hit, which is not what I'm after. Running fsck manually after setting the time doesn't work as the filesystem is still mounted at that point, and just disabling fsck entirely is less than ideal.

I'm using RedHat 6.

Update: The solution I'm currently going with is to hack fstab to disable fsck checking on reboot. I'd tried editing the last mount time on the disks using debugfs, which works fine for ext3 drives, but appears to fail inconsistently on ext4.

Best Answer

I was going to suggest hacking e2fsck to disable the specific checks for a last mount time or last write times in the future. These are defined in problem.c / problem.h, and used in super.c. But in looking, I discovered that E2fsprogs 1.41.10 adds a new option to /etc/e2fsck.conf called broken_system_clock. This seems to be exactly what you need, and since you're using Red Hat Enterprise Linux 6, you should have 1.41.12, which includes this option. From the man page:

   broken_system_clock
          The e2fsck(8) program has some hueristics that assume  that  the
          system clock is correct.  In addition, many system programs make
          similar assumptions.  For example, the UUID library  depends  on
          time  not going backwards in order for it to be able to make its
          guarantees about issuing universally unique ID’s.  Systems  with
          broken  system clocks, are well, broken.  However, broken system
          clocks, particularly in embedded systems, do exist.  E2fsck will
          attempt  to  use  hueristics to determine if the time can no tbe
          trusted; and to skip time-based checks if this is true.  If this
          boolean  is set to true, then e2fsck will always assume that the
          system clock can not be trusted.

Yes, the man page can't spell "heuristics". Oops. But presumably the code works anyway. :)

Related Question