we want to check the filesystem on the disks as /deb/sdc .... /dev/sdg on each linux redhat machine

the target is to find what are the disks that required e2fsck ( as e2fsck -y /dev/sdb . etc )

according to man page

-n     Open  the filesystem read-only, and assume an answer of `no' to all questions.  Allows e2fsck to be used non-interactively.  This option may not be specified at
          the same time as the -p or -y options.

when we run the command ( only example )

 e2fsck -n   /dev/sdXX

we get

e2fsck 1.42.9 (28-Dec-2013)
Warning!  /dev/sdc is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
/dev/sdc: clean, 94/1310720 files, 156685/5242880 blocks

so what need to capture from e2fsck output , that required to run e2fsck ?

e2fsck process

init 1

umount /dev/sdXX

e2fsck -y /dev/sdXX  ( or e2fsck -C /dev/sdXX for full details ) 

init 3

You probably are looking for the output of tune2fs rather than e2fsck

tune2fs -l /dev/sdXX |grep "Filesystem state\|Last checked\|Check interval"

which should yield something like this:

Filesystem state:         clean
Last checked:             Mon Nov 28 16:03:44 2016
Check interval:           31536000 (12 months)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.