1

We have servers which have been running for a long time. When they reboot, we see this message:

kernel: EXT4-fs (sda3): warning: maximal mount count reached, running e2fsck is recommended

My question is: what if you never ever run e2fsck? Man page does not shed enough light. The warning message says "is recommended" - but does not say it is mandatory.

What are consequences of not running it?

What does it mean to have maximal count reached?

  • Waiting for the backup server to finish running a surprise `fsck` while other folks run around and try to fix the primary server is fun. Scheduling the `fsck` for outage windows is proably a better plan. A system that does not boot because the filesystem is broken is even more fun. – thrig Jul 16 '22 at 02:43

1 Answers1

3

An ext* filesystem has a couple of values in the metadata; how many times a filesystem can be mounted before it should be checked, and how long between checks should be allowed.

These values can be checked with the dumpe2fs command; eg

% sudo dumpe2fs -h /dev/vdb | egrep -i 'check|mount count'
dumpe2fs 1.42.9 (28-Dec-2013)
Mount count:              15
Maximum mount count:      25
Last checked:             Sun Jan  2 22:03:00 2022
Check interval:           15552000 (6 months)
Next check after:         Fri Jul  1 23:03:00 2022

This says the filesystem has been mounted 15 times and needs to be checked after 25 mounts; a check should be run every 6 months; the last check was Jan 2022, so the next check should be Jul 2022.

These values can be changed with the tunefs command (-i and -c) options.

And they can be turned off. eg

% sudo dumpe2fs -h /dev/vda3 | egrep -i 'check|mount count'
dumpe2fs 1.42.9 (28-Dec-2013)
Mount count:              138
Maximum mount count:      -1
Last checked:             Sun Jul 12 17:23:17 2015
Check interval:           0 (<none>)

This basically says "the disks never should be checked".

So now the question; should we run it regularly?

Essentially the rationale for regular-ish checking is to try and discover filesystem inconsistencies and try and fix them. On a modern system that doesn't shut down abnormally (eg crash, power failure) there's little risk, so it may not need to be done.

Indeed, on large filesystems or ones with large number of files this could take a long time! Potentially hours!

Contrariwise, on small filesystems with the correct entries in /etc/fstab it can happen automatically on reboot and only slows the reboot down a small amount.

So you might want to let small filesystems be checked via fstab but not allow large ones or ones with lots of files.

Red Hat, for example, recommends "In general Red Hat does not suggest disabling the fsck except in situations where the machine does not boot, the file system is extremely large or the file system is on remote storage." (https://access.redhat.com/solutions/281123)

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
Stephen Harris
  • 42,369
  • 5
  • 94
  • 123
  • Thanks for the answer. – Pawan Singh Jul 16 '22 at 02:56
  • 1
    [`lvcheck`](https://unix.stackexchange.com/questions/347280/how-to-perform-full-check-of-ext4-file-system-structure/347286) can be useful to perform checks of large file systems without incurring downtime. – Stephen Kitt Jul 16 '22 at 06:51