Fsck
<yambe:breadcrumb self="Fsck">Filesystem or partition tools|Filesystem or partition tools</yambe:breadcrumb>
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:
- https://unix.stackexchange.com/questions/347280/how-to-perform-full-check-of-ext4-file-system-structure
- https://askubuntu.com/questions/14740/force-fsck-ext4-on-reboot-but-really-forceful
<yambe:breadcrumb self="Fsck">Filesystem or partition tools|Filesystem or partition tools</yambe:breadcrumb>