General

fsck Cheatsheet

Basic Usage

Common fsck command forms.

Command Description
fsck /dev/sdb1 Check a filesystem
fsck -n /dev/sdb1 Check only, do not write changes
fsck -f /dev/sdb1 Force a check even if the filesystem looks clean
fsck -t ext4 /dev/sdb1 Check only filesystems of the given type
fsck -A Check filesystems listed in /etc/fstab

Safe Repair Workflow

Use this sequence before making repairs.

Command Description
lsblk -f Identify the device, mount point, and filesystem type
mount | grep /dev/sdb1 Confirm whether the device is mounted
sudo umount /dev/sdb1 Unmount the filesystem before repair
sudo fsck -n /dev/sdb1 Run a read-only check first
sudo fsck -p /dev/sdb1 Auto-fix safe problems without prompts

Repair Modes

Choose how interactive the repair should be.

Option Description
-n Do not make changes, useful for a safe first pass
-p Automatically repair safe problems
-y Answer yes to all prompts
-r Prompt before each repair
-f Force checking even if the filesystem appears clean

Filesystem Selection

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

Command Description
sudo fsck /dev/nvme0n1p2 Check one device directly
sudo fsck -t ext4 /dev/nvme0n1p2 Check one device as ext4
sudo fsck -A Check all eligible filesystems in /etc/fstab
sudo fsck -AR Check all except the root filesystem
sudo fsck.ext4 /dev/nvme0n1p2 Run the filesystem-specific checker directly

Root Filesystem Recovery

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

Method Description
Recovery mode Boot into recovery and choose the filesystem check option
Live USB Boot a live system, identify the root partition, then run fsck there
fsck.mode=force Kernel parameter to force a check during boot on systemd systems
fsck.repair=yes Kernel parameter to approve repairs during boot
sudo touch /forcefsck Older non-systemd pattern to force a boot-time check

tune2fs Scheduling

Control when ext filesystems are checked automatically.

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

fstab Pass Values

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

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

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

Exit Codes

Use exit codes to understand what fsck found.

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

Other Filesystems

Some filesystems use tools other than fsck.

Filesystem Tool
XFS xfs_repair
Btrfs btrfs check or btrfs scrub
NTFS ntfsfix
FAT/VFAT fsck.vfat
Ext2/3/4 fsck.ext2, fsck.ext3, fsck.ext4

Related Guides

Use these articles for the full workflow around filesystem repair.

Guide Description
Fsck Command in Linux (Repair Filesystem) Full fsck guide with examples
How to Check Disk Space in Linux Using the df Command Check mounted filesystems and free space
How to Mount and Unmount File Systems in Linux Unmount a filesystem before repair
Sudo Command in Linux: Run Commands as Root Run fsck with the required privileges
AI Assistant
Context loaded: fsck Cheatsheet