13

We have RedHat 7.2 OS.

/dev/sdc is mounted to /bla/appLO

Is it possible to run fsck on mounted disks (without umount /bla/appLO) and to see only the errors if they exist?

Example:

e2fsck -n /dev/sdc
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, 11/1310720 files, 126322/5242880 blocks

Does fsck -n show the error even though the disk is mounted?

1
  • You can use exit code of command fsck. But you can get errors in fs because is mounted Commented Apr 24, 2018 at 8:38

1 Answer 1

10

No.

You should never run fsck on a mounted filesystem. Correcting errors on a live filesystem will mess up your disk. Even if you run the tool in read-only mode (without error correction) the results can't be trusted. This is true even if the filesystem is mounted read-only.

From man e2fsck:

Note that in general it is not safe to run e2fsck on mounted filesystems. The only exception is if the -n option is specified, and -c, -l, or -L options are not specified. However, even if it is safe to do so, the results printed by e2fsck are not valid if the filesystem is mounted. If e2fsck asks whether or not you should check a filesystem which is mounted, the only correct answer is ``no''. Only experts who really know what they are doing should consider answering this question in any other way.

From man fsck:

For some filesystem-specific checkers, the -n option will cause the fs-specific fsck to avoid attempting to repair any problems, but simply report such problems to stdout. This is however not true for all filesystem-specific checkers. In particular, fsck.reiserfs(8) will not report any corruption if given this option. fsck.minix(8) does not support the -n option at all.

You should take the time to unmount the disk and do a proper filesystem check; results that cannot be trusted aren't useful at all.

6
  • thank you , could you help me with my question on - unix.stackexchange.com/questions/439661/…
    – yael
    Commented Apr 24, 2018 at 8:44
  • I already seen your question, it puzzles me. I've never seen ew in the output of mount. I'd be interested to know the answer too.
    – dr_
    Commented Apr 24, 2018 at 8:48
  • Does this prohibition against fsck, even with -n specified, include on filesystems that are mounted read-only? Commented Nov 26, 2019 at 14:55
  • @DanielGriscom I'd say yes, as fsck would need to do writes on the filesystem anyway, in case of errors.
    – dr_
    Commented Dec 4, 2019 at 19:27
  • 1
    @dr01 No: with the -n option fsck makes no changes to the filesystem, correct? So, if the filesystem is mounted read-only then the mounted state won't confuse fsck, and if fsck -n is used then no fsck changes would be made and the filesystem couldn't be corrupted, right? Commented Dec 4, 2019 at 20:19

You must log in to answer this question.

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