Linux, Technical

Ubuntu: Turn off Periodic FSCK

I halt my computer at night, and boot it in the morning. This reduces my carbon impact. Alas, Ubuntu for whatever brain-dead reason doesn’t trust its filesystem. As if we lived in the 1970s it insists on checking the filesystem consistency every thirtieth boot. I sip my morning coffee, check my workstation, and have to hit ESC . . .

So, I googled a bit, and found a helpful forum thread. I thought I’d offer my own tiny variation:

0-09:57 dannhowa@T60p ~$ sudo tune2fs -c 0 `mount | awk '$3 == "/" {print $1}'`
tune2fs 1.40.8 (13-Mar-2008)
Setting maximal mount count to -1

Update: wamukota made an excellent suggestion, that one can instead set an interval with the -i flag. For example, one could set their computer to check every three months:

0-19:06 djh@noneedto ~$ sudo tune2fs -i 3m `mount | awk '$3 == "/" {print $1}'`
tune2fs 1.41.4 (27-Jan-2009)
Setting interval between checks to 7776000 seconds

Okay, that is a scary-looking command-line. Let me break it down. First, here are what filesystems we have mounted:

0-09:58 dannhowa@T60p ~$ mount
/dev/sda3 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.24-21-generic/volatile type tmpfs (rw)
/dev/sda1 on /C type fuseblk (rw,nosuid,nodev,noatime,allow_other,default_permissions,blksize=4096)
securityfs on /sys/kernel/security type securityfs (rw)

The command we really want to run turn off checking of / is:
sudo tune2fs -c 0 /dev/sda3

But everyone’s / is mounted somewhere different, based on what sort of disks you have and how they are partitioned. If you wanted to boil it down in to one command you have to pluck the name of the disk from the mount command, and for this, awk is the shizzle. For example, you could print the third word followed by the first word of each line this way:

0-10:05 dannhowa@T60p ~$ mount | awk '{print $3" "$1}'
/ /dev/sda3
/proc proc
/sys /sys
/var/run varrun
/var/lock varlock
/dev udev
/dev/shm devshm
/dev/pts devpts
/lib/modules/2.6.24-21-generic/volatile lrm
/C /dev/sda1
/sys/kernel/security securityfs

And add a dash of logic, if the third word is “/” then print the first word:

0-10:06 dannhowa@T60p ~$ mount | awk '$3 == "/" {print $1}'

And through the miracle of back-ticks:

0-10:07 dannhowa@T60p ~$ sudo tune2fs -c 0 `mount | awk '$3 == "/" {print $1}'`
tune2fs 1.40.8 (13-Mar-2008)
Setting maximal mount count to -1

Now, I am cocky and I maintain backups of important files. Before doing what dannyman dot told you dot com, you may wish to take a glance at the tune2fs man page:

       -c max-mount-counts
              Adjust  the  number of mounts after which the filesystem will be
              checked by e2fsck(8).  If max-mount-counts is 0 or -1, the  num‐
              ber  of  times  the filesystem is mounted will be disregarded by
              e2fsck(8) and the kernel.

              Staggering the mount-counts at which  filesystems  are  forcibly
              checked  will  avoid  all  filesystems being checked at one time
              when using journaled filesystems.

              You should  strongly  consider  the  consequences  of  disabling
              mount-count-dependent   checking  entirely.   Bad  disk  drives,
              cables, memory, and kernel bugs could all corrupt  a  filesystem
              without  marking  the  filesystem dirty or in error.  If you are
              using journaling on your filesystem, your filesystem will  never
              be marked dirty, so it will not normally be checked.  A filesys‐
              tem error detected by the kernel will still force an fsck on the
              next reboot, but it may already be too late to prevent data loss
              at that point.

              See also the -i option for time-dependent checking.

You might also experiment with a modern filesystem, by running FreeBSD or Solaris.

Read More

Categories: Linux, Technical

  • I just use XFS and it doesn’t have that problem. Of course, you need to use the text based installer to go hardcore non-ext3.