I recently powered down my UT box due to UPS service. It had an uptime of ~270 days. This made me wonder when the last time a fsck had been done. It is dangerous to run a fsck on a mounted drive, so a boot-time option is probably best.
First, what filesystems are on the UT box?
Therefore, /dev/hda1 is the target partition. When was the last file system consistency check, and when is the next due?Code:# nano /etc/fstab # /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/hda1 / ext3 errors=remount-ro 0 1 /dev/hda5 /data ext3 defaults 0 2 /dev/hda2 none swap sw 0 0 /dev/hdb /media/cdrom0 udf,iso9660 user,noauto 0 0
Yipes! The last time the file system was examined was when this machine was built.Code:tune2fs -l /dev/hda1 ...... Filesystem created: Mon Oct 19 22:45:09 2009 Last mount time: Sun Mar 13 12:00:22 2011 Last write time: Sun Mar 13 12:00:22 2011 Mount count: 7 Maximum mount count: 38 Last checked: Mon Oct 19 22:45:09 2009 Check interval: 0 (<none>) ......
This says that the ext3 partition on /dev/hda1 is checked every 38 power cycles. There is no date check to trigger a fsck. Since I've only rebooted my box twice since inception (plus the half-dozen boots when building the machine), it will be decade(s) until before the file system check is triggered by the "Maximum mount count".
The Maximum mount count can be changed, along with the Check interval:
Now, we can check when a boot-time fsck will run next:Code:tune2fs -c 1 /dev/hda1 tune2fs -i 1 /dev/hda1
Now, a boot-time fsck is run every reboot. This will increase the boot time. I may also make a cron job to reboot the machine at very obscure times to ensure fsck is occasionally run once or twice a year (for example, midnight on Valentine's day, because we're all busy elsewhere ...)Code:tune2fs -l /dev/hda1 ...... Filesystem created: Mon Oct 19 22:45:09 2009 Last mount time: Sun Mar 13 12:00:22 2011 Last write time: Mon Mar 14 08:44:25 2011 Mount count: 7 Maximum mount count: 1 Last checked: Mon Oct 19 22:45:09 2009 Check interval: 86400 (1 day) ......