Checking and repairing Linux file systems Which tool is used to verify and repair Linux file systems after improper shutdowns or detected inconsistencies?
-
Amkfs
-
Bfdisk
-
Cfsck
-
Dmount
-
ENone of the above
Answer
Correct Answer: fsck
Explanation
Introduction / Context:File system integrity is crucial for data reliability. After unexpected power loss or hardware issues, file systems may contain inconsistencies. Linux provides a standard tool to check and, when necessary, repair file systems to a consistent state before mounting them read-write.
Given Data / Assumptions:
- We are using Linux with common file systems (for example, ext4, xfs, btrfs with their respective helpers).
- We need a tool to check and fix inconsistencies.
- We understand that specific file systems may have specialized checkers invoked under a common wrapper.
Concept / Approach:
fsck is the front-end tool that orchestrates file system checks. It calls the appropriate checker (such as e2fsck for ext2/3/4 or xfs_repair for XFS) based on the device and file system type. It is typically run on unmounted file systems or in single-user/emergency mode to avoid further damage.
Step-by-Step Solution:
Identify the target device (for example, /dev/sda1).Ensure it is unmounted or mounted read-only.Run fsck or a specific checker (for example, fsck -t ext4 /dev/sda1).Accept or review repairs as prompted, then remount and verify.Verification / Alternative check:
Review system logs after boot; many distributions run fsck automatically based on mount counts or dirty flags. For ext filesystems, compare results with tune2fs -l to see mount counts and check intervals.
Why Other Options Are Wrong:
- mkfs: creates a new file system; using it would erase data.
- fdisk: edits partition tables; it does not check file system integrity.
- mount: attaches file systems to the directory tree; it does not repair them.
- None of the above: incorrect because fsck is correct.
Common Pitfalls:
Running fsck on a mounted file system, misunderstanding that some modern file systems have different repair workflows, and ignoring hardware issues causing recurring corruption.
Final Answer:
fsck