Check file systems
Bugs, power failures, and mechanical problems can all cause data structures on a file system to become corrupted and cause severe data loss. To check and repair Linux file systems, you can use the fsck (stands for file system check ) command. This command performs a sequential investigation of the file system. If it finds a misplaced directory or a file with no inode number, it places them in the /lost+found directory.
Linux runs fsck automatically at startup on partitions that are marked for it in /etc/fstab. You can also run the fsck utility manually. To do this, run the fsck command along with the name of the file system you would like to check:
The fsck utility supports a couple of options:
- -A option – check all the file systems marked to be checked in /etc/fstab. Normally used in system startup scripts.
- -t option – normally, fsck determines the file system type automatically. You can force the type with the -t FSTYPE option.
- -N option – display what would be checked but don’t actually perform the check. This option is useful to see what would happen if you performed the check.
- -R option – checks all file systems except the root directory
- -V option – displays verbose output.