How to check and manipulate Ext file-systems

Checking is easy, just run fsck against unmounted file-system.

# fsck -y /dev/sda1

Now if you want to display some information about the file-system use dumpe2fs commandline tool provided by e2fsprogs package on debian.

# dumpe2fs -h /dev/sda1

Note these lines in the output which mention mount count and check?

Mount count:         43
Maximum mount count: 50
Last checked:        Fri Mar 25 20:58:32 2016
Check interval:      15552000 (6 months)
Next check after:    Wed Sep 21 21:58:32 2016

You can tune those values with tool like tune2fs. Why? For example to trigger file-system check before next mounting or vice versa, to postpone checking. Tune2fs tool is also provided by e2fsprogs package on debian.

Adjusting maximum mount count before checking to 50 is below. To disable check triggering according to mount count, use “-1” as count.

# tune2fs -c 50 /dev/sda1

Adjust maximum check interval to 3 months is below. Use d/m/w to set days,months or weeks. To disable check triggering according to interval from last check, use “0” as interval.

# tune2fs -i 3m /dev/sda1

To trigger check on all ext2/34 file-systems during next reboot use following piece of code. It sets mount count to 9999 on all mounted ext file-systems so it will have to trigger the check unless you have disabled it by setting maximum mount count to -1.

for m in ext2 ext3 ext4; do
    for f in `mount -t ${m} |awk '{print $1}'`; do
      tune2fs -C 9999 ${f}


If you found this useful, say thanks, click on some banners or donate, I can always use some beer money.

Leave a Reply

Your email address will not be published. Required fields are marked *