Friday 6 January 2017

Preventing or changing filesystem checking on a specific disk

In some situations you won't always want to scan specific file systems - like in the event where you have a huge disk - that might take hours to scan - imagine attempting a routine reboot and getting that lumped on you unexpectedly!

Fortunately we can modify this behaviour with the 'tune2fs' utility.

Lets firstly get some information for the root file system:

tune2fs -l /dev/mapper/fedora-root

This will provide us with a whole host of information - to name a few:

- The last time the file system was mounted.
- Whether the file system state is clean or not.
- The file system UUID.
- The file system check frequency.

By default in Fedora 25 I noticed that the 'Maximum mount count' is set to -1 rendering it useless - a file system check would only typically be performed if the files ystem is marked as dirty or a user manually invokes a check with fsck.

cat /etc/mke2fs.conf | grep enable

By changing  'enable_periodic_fsck' to 1 we can re-enable periodic scans of the file system.

When the 'Mount count' hits the threshold ('Maximum mount count') or the 'Check Interval' a file system check is performed on the next boot. We can however manipulate the 'Mount count' variable hence forcing a file system check to take place upon next boot.

For example to set the max-mount-counts and mount-count values we can issue:

tune2fs -c 5 -C 5 /dev/mapper/fedora-root

(This would force a file system check on next boot.)

Where -c = max-mount-counts and -C = mount-count

To disable checks on a specific file system we would issue:

tune2fs -c 0 -C 0 /dev/mapper/fedora-root


Post a Comment