Fsck

From Notes_Wiki

Home > CentOS > CentOS 6.x > Filesystem or partition tools > Fsck

Checking ext3 partitions for disk errors

We can use following command to check ext3 partitions for disk errors / surface scan for bad blocks:

e2fsck -c -c -k -v -C 0 <partition_device_name>

Here:

  • -c : To call badblocks for surface scan
  • -c : Repeated to indicate non-destructive read-write tests
  • -k : Preserve previous list of bad blocks
  • -v : Verbose
  • -C 0 : To print progress on file descriptor. For some strange reason 0 causes output to be sent on screen.


Note:

  • It is advisable to use e2fsck in above format so that it calls 'badblocks' internally, and we should avoid calling program badblocks directly.


Automatically answer to fsck prompts

fsck can automatically repair issues using 'fsck -a' or fsck -p. However, if repair is likely to be destructive error would be shown and we need to run with -a and -p and manually enter yes/no for prompts. Thus, it is better to use

  fsck -y

which answers y for all prompts and does not requires human intervention. -y cannot be used along with -a or -p


Force check of clean file-system

If the filesystem is clean and check should be forced use -f


Recommended options- Scan bad blocks, default yes and force scan

If not sure which options should be used, then:

  fsck -cyf

should be fine in most cases


Refer:


Home > CentOS > CentOS 6.x > Filesystem or partition tools > Fsck