CompTIA Linux+ (XK0-006)TroubleshootingEasy
A technician needs to run `fsck` on the root filesystem (/) of a running server to check for errors. What is the safest way to accomplish this?
- ARun `fsck -f /` with the -f flag to force it to ignore the mount state
- BRun `fsck -y /` directly while the system is running normally
- CSchedule fsck to run via cron during business hours
- DBoot into rescue/single-user mode or use live media so the filesystem is unmounted before running fsck
Show answer & explanationAnswer & explanation
Correct answer: D. Boot into rescue/single-user mode or use live media so the filesystem is unmounted before running fsck
fsck should never be run on a mounted, actively-used filesystem because it can cause data corruption. The safe approach is to boot into rescue/single-user mode or from live media, where the root filesystem is unmounted or mounted read-only, before running the check and repair.
Why the other options are wrong
- A. The -f flag forces a check but does not make it safe to run on a mounted filesystem.
- B. Running fsck -y on a live mounted root filesystem risks severe corruption.
- C. Scheduling via cron does not unmount the filesystem and does not make it safe.
fsck on Mounted Filesystem
fsck should not be run on a mounted, in-use filesystem; doing so risks corruption because the kernel may write to the disk during the check.
- Root filesystem: boot to rescue/single-user mode first
- fsck displays a warning if run on a mounted filesystem
- Non-root filesystems can simply be unmounted with umount before checking
Memory trick: Never repair a car engine while it's still running