1

I saw some kernel errors from months ago in syslog that said an inode was marked dirty. I want to fsck the system but a reboot would be undesirable at this time.

What sort of checks can I do safely now to help me decide if I should recommend an emergency reboot/fsck? For example: How can I check if the filesystem is marked "dirty"? I can't seem to find an option to display that in any utility.

xdfil
  • 205

2 Answers2

4

tune2fs -l <filesystem> was what I was looking for.

I wrote a command to quickly check the filesystem state for all mounted filesystems:

df | awk '/^\/dev/ {print $1}' | xargs -I {} sh -c 'echo {}; tune2fs -l {}' | awk '/^\/dev/ {print $1} /^Filesystem state/ {print $3, " ",$4}'
xdfil
  • 205
  • 1
    You need to print $4 at the end if you want to get the full state on non-clean devices. You could also limit the output to ext devices and use mount instead of df: mount|awk '/^\/dev.*type ext/ {print $1}'|xargs -I {} sh -c "sudo tune2fs -l {}|awk '/Filesystem state/{print \"{}\" \": \" \$3 \" \" \$4}'" or mount|awk '/^\/dev.*type ext/ {print $1}'|xargs -I {} sh -c "sudo tune2fs -l {}|awk -F: '/Filesystem state/{print \"{}\" \": \" \$2}'" – Stephen Kitt Mar 12 '15 at 19:34
2

As jordanm says, tune2fs -l /dev/... should say Filesystem state: clean (even for a mounted filesystem). I'm not entirely sure whether that's guaranteed though. You definitely don't want Filesystem state: with errors; as long as it doesn't say that you should be OK.

If your filesystems are built on logical volumes (with LVM), and you have some spare capacity in the underlying volume groups, you can use lvcheck to run fsck on a snapshot while the system is live, with no downtime.

Stephen Kitt
  • 434,908