12

Following this question: Force fsck.ext4 on reboot, but really "forceful"

Apparently the output of e2fsck -n is not reliable when you use it on a mounted filesystem, so its output should not be trusted.

Is there any way to check for errors in a mounted filesystem? Just check, not fix. I am more interested in ext4, because that's what I use the most.

2 Answers 2

10

Because of the way that most Linux file systems work you simply cannot do a safe/useful check on a mounted file system. It's not really safe, and because the system is in use, it can be unreliable. Sadly, sometimes, you have to live with things the way they are until someone does it better ;). Ext4 probably won't pick up this feature (maybe ext5? if it ever happens) but I believe btrfs will, and if it does, you will be able to switch your partitions over when the time comes.

4
  • 1
    I noticed that fsck -n shows "Warning: skipping journal recovery because doing a read-only filesystem check." I think this is related to why it's not reliable. I'd love to get some links to a better explanation, though.
    – UrkoM
    Nov 26, 2010 at 4:10
  • I could try to pull up some good links tomorrow, or maybe a kernel hacker can get them quick for you. But generally, even on windows (yes even on windows) doing checks on a mounted file system is bad news!
    – RolandiXor
    Nov 26, 2010 at 4:53
  • This seems like a good link: linux-archive.org/ubuntu-user/… I searched before asking, but obviously not with the right wording.
    – UrkoM
    Nov 26, 2010 at 5:52
  • @RolandiXor does Windows even let you do chkdsk on a mounted FS? AFAIR, to check the system FS you have to reboot into some pre-login mode, where chkdsk will work, printing mojibake for non-latin filenames if some files have problems. (At least, this was so when I was using Windows—the XP era.)
    – Ruslan
    May 14, 2020 at 13:03
2

if it is an LVM volume then you can take a snapshot of the volume and then run fsck on the snapshot to see whether the filesystem is in a recoverable state. That's not the same as checking whether it currently is in a consistent state. However it is close enough for almost all intentions. When you're done, drop the snapshot.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .