🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

fsck Command

Advanced Disk & Storage man(1)

Check and repair a Linux filesystem

👁 10 views 📅 Updated: Mar 15, 2026
SYNTAX
fsck [OPTION]... [DEVICE]

What Does fsck Do?

fsck (filesystem check) verifies and repairs Linux filesystem integrity. It checks for and fixes errors such as orphaned inodes, bad blocks, incorrect link counts, and directory structure problems.

fsck should only be run on unmounted filesystems or filesystems mounted read-only. Running fsck on a mounted read-write filesystem can cause data corruption.

On modern systems with journaling filesystems (ext4, xfs), filesystem corruption is rare. fsck is mainly used during boot when the system detects an unclean shutdown, or when troubleshooting specific issues.

Options & Flags

OptionDescriptionExample
-y Automatically answer yes to all repairs sudo fsck -y /dev/sdb1
-n No changes — just check sudo fsck -n /dev/sdb1
-f Force check even if filesystem seems clean sudo fsck -f /dev/sdb1
-t Specify filesystem type sudo fsck -t ext4 /dev/sdb1
-p Automatically repair safe problems sudo fsck -p /dev/sdb1
-C Show progress bar sudo fsck -C /dev/sdb1

Practical Examples

#1 Check filesystem

Checks the filesystem for errors.
$ sudo fsck /dev/sdb1
Output: /dev/sdb1: clean, 1234/65536 files, 45678/262144 blocks

#2 Force check

Forces a full check even if the filesystem appears clean.
$ sudo fsck -f /dev/sdb1

#3 Auto-repair

Automatically fixes all detected errors.
$ sudo fsck -y /dev/sdb1

#4 Check without changes

Reports errors without making any repairs.
$ sudo fsck -n /dev/sdb1

#5 Check root filesystem

Forces a root filesystem check on next boot.
$ sudo touch /forcefsck && sudo reboot

Tips & Best Practices

NEVER run on mounted filesystem: Running fsck on a mounted read-write filesystem can cause severe data corruption. Unmount first or boot into single-user mode.
Journaling reduces need: ext4 and xfs have journaling that recovers from most crash scenarios. fsck is rarely needed on modern systems.
Exit codes: 0=no errors, 1=errors corrected, 2=reboot needed, 4=errors uncorrected, 8=operational error.

Frequently Asked Questions

When should I run fsck?
After an unclean shutdown, when you see filesystem errors in dmesg, or when files are inexplicably corrupted. Must be unmounted.
How do I check the root filesystem?
Boot from a live USB and run fsck, or create /forcefsck and reboot to force a check during boot.
Why does fsck say device is busy?
The filesystem is mounted. Unmount it first: sudo umount /dev/sdX1. For root, boot from live USB.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →