Linux fsck Command: Check and Repair Filesystems
fsck runs filesystem-specific check tools to verify the consistency of a file system and repair it if necessary. You must first check whether the target is in use, as modifying a mounted file system may corrupt data.
What is the fsck command?
fsck is a frontend for filesystem-specific checkers like fsck.ext4. The actual check and repair options vary for each file system. XFS does not recover through the standard fsck path and requires a separate xfs_repair procedure. After confirming the file system type, read the documentation for the corresponding tool.
Basic syntax
sudo fsck [options] [file system]
The installed implementation and options may vary depending on the distribution. Use man fsck to check the description on the current system.
Examples
Check the target and format
First, check the partition to be checked and its mount status.
lsblk -f
Check if it is mounted
If the target is in use, first plan to stop or detach it.
findmnt /dev/sdb1
Read-Only Check Example
This is an example of checking an ext-family file system after unmounting it without making changes.
sudo e2fsck -n /dev/sdb1
Differences Between Check and Automatic Recovery
fsck calls the checker suitable for the file system type. First, it is standard practice to confirm the actual partition and file system type, and to run it on an unmounted target.
lsblk -f sudo fsck -n /dev/sdb1
-n is a read-only check mode that answers 'no' to prompts, but do not assume it behaves the same on all file systems. For example, checkers in the ext series may output file system status and error counts over multiple lines, and the detailed results may vary depending on the target.
Do not immediately apply automatic recovery options just because errors appear in the check results. Verify the disk status and backups, and follow the recovery procedures specific to each file system. In particular, performing recovery checks on mounted read-write file systems carries a risk of data corruption.
The exit status of fsck may encode more than a simple success or failure: corrected errors, required reboot, and operational failures can use distinct bits. In automation, consult the installed implementation's manual for status codes and filesystem-specific checker options. After any repair, verify the mount and application state.
Main Options and Format
| Options/Format | Description |
|---|---|
-t format |
Specify the type of file system to check. |
-A |
Checks the file systems specified in the configuration file. The scope is broad. |
-N |
Displays only the commands to be executed and does not perform the check. |
-M |
Skips mounted file systems. |
-V |
Displays detailed execution process. |
Precautions when using
Before actual repairs, check recent backups and recovery options, and work in an unmounted state as much as possible. Automatic approval options like fsck -y can modify damaged files differently than expected. Since it is difficult to detach the root file system during normal operation, recovery mode or a live environment may be required. SSD, RAID, and LVM layers also affect the selection of targets.
Frequently Asked Questions
Is it okay to run fsck on a mounted file system?
Running a repair check on a mounted filesystem can corrupt data. Generally, unmount the target filesystem or check it in a recovery environment, and follow the instructions specific to the filesystem type.
Official Documentation
The exact behavior of the options and implementation-specific differences can be found in the official fsck documentation.









