Skip to main content

fsck Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for fsck: check Linux filesystems, run safe repairs, force checks, review exit codes, and handle boot-time recovery

fsck checks Linux filesystems for errors and can repair problems when a partition is unmounted. This cheatsheet covers safe check patterns, repair modes, boot-time checks, exit codes, and related recovery commands.

Basic Usage

Common fsck command forms.

CommandDescription
fsck /dev/sdb1Check a filesystem
fsck -n /dev/sdb1Check only, do not write changes
fsck -f /dev/sdb1Force a check even if the filesystem looks clean
fsck -t ext4 /dev/sdb1Check only filesystems of the given type
fsck -ACheck filesystems listed in /etc/fstab

Safe Repair Workflow

Use this sequence before making repairs.

CommandDescription
lsblk -fIdentify the device, mount point, and filesystem type
mount | grep /dev/sdb1Confirm whether the device is mounted
sudo umount /dev/sdb1Unmount the filesystem before repair
sudo fsck -n /dev/sdb1Run a read-only check first
sudo fsck -p /dev/sdb1Auto-fix safe problems without prompts

Repair Modes

Choose how interactive the repair should be.

OptionDescription
-nDo not make changes, useful for a safe first pass
-pAutomatically repair safe problems
-yAnswer yes to all prompts
-rPrompt before each repair
-fForce checking even if the filesystem appears clean

Filesystem Selection

Target one filesystem, one type, or all entries in fstab.

CommandDescription
sudo fsck /dev/nvme0n1p2Check one device directly
sudo fsck -t ext4 /dev/nvme0n1p2Check one device as ext4
sudo fsck -ACheck all eligible filesystems in /etc/fstab
sudo fsck -ARCheck all except the root filesystem
sudo fsck.ext4 /dev/nvme0n1p2Run the filesystem-specific checker directly

Root Filesystem Recovery

fsck cannot repair the mounted root filesystem on a running system.

MethodDescription
Recovery modeBoot into recovery and choose the filesystem check option
Live USBBoot a live system, identify the root partition, then run fsck there
fsck.mode=forceKernel parameter to force a check during boot on systemd systems
fsck.repair=yesKernel parameter to approve repairs during boot
sudo touch /forcefsckOlder non-systemd pattern to force a boot-time check

tune2fs Scheduling

Control when ext filesystems are checked automatically.

CommandDescription
sudo tune2fs -l /dev/sdb1 | grep -i 'last checked|mount count'Show last check time and mount counters
sudo tune2fs -c 25 /dev/sdb1Run a check after every 25 mounts
sudo tune2fs -c -1 /dev/sdb1Disable mount-count-based checks
sudo tune2fs -i 1m /dev/sdb1Run a check at most once per month
sudo tune2fs -i 0 /dev/sdb1Disable time-based checks

fstab Pass Values

The sixth /etc/fstab column controls boot-time check order.

ValueDescription
0Do not check this filesystem at boot
1Check first, usually the root filesystem
2Check after root, for other local filesystems

Example: /dev/sda2 /home ext4 defaults 0 2

Exit Codes

Use exit codes to understand what fsck found.

CodeDescription
0No errors
1Filesystem errors corrected
2System should be rebooted
4Filesystem errors left uncorrected
8Operational error
16Usage or syntax error
32Checking canceled by user
128Shared-library error

Other Filesystems

Some filesystems use tools other than fsck.

FilesystemTool
XFSxfs_repair
Btrfsbtrfs check or btrfs scrub
NTFSntfsfix
FAT/VFATfsck.vfat
Ext2/3/4fsck.ext2, fsck.ext3, fsck.ext4

Use these articles for the full workflow around filesystem repair.

GuideDescription
Fsck Command in Linux (Repair Filesystem)Full fsck guide with examples
How to Check Disk Space in Linux Using the df CommandCheck mounted filesystems and free space
How to Mount and Unmount File Systems in LinuxUnmount a filesystem before repair
Sudo Command in Linux: Run Commands as RootRun fsck with the required privileges