How to check your file system's integrity with fsck

Posted . Visible to the public.

To force a check on your next reboot (here for your root partition), simply:

touch /forcefsck

To manually do this, here is how to do it for the first partition on sda, when you are using ext4:

fsck.ext4 -fn /dev/sda1
  • -f forces the check, even if everything seems okay.
  • -n is a "read only" check, where nothing is changed and every question is answered with "no".
  • When using dmcrypt, you probably want to check something like /dev/mapper/lvm-root.

This does not work properly when doing this on mounted devices (i.e. while your system is up), even when using the -n switch.

Kudos to Kim.

Arne Hartherz
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2012-05-07 12:35)