$linuxjunkies
>

fsck(8)

Check and repair a Linux filesystem.

UbuntuDebianFedoraArch

Synopsis

fsck [OPTIONS] [DEVICE]

Description

fsck is used to check and optionally repair one or more Linux filesystems. By default, fsck will run the appropriate filesystem-specific checker (fsck.ext4, fsck.xfs, etc.) based on the filesystem type. It can check filesystems on block devices, mount points, or labels.

fsck should only be run on unmounted filesystems or the root filesystem in read-only mode. Running fsck on a mounted filesystem can cause corruption. Most modern systems use automatic filesystem checking at boot time if the system crashed unexpectedly.

Common options

FlagWhat it does
-t fstypeSpecify the filesystem type (ext4, xfs, btrfs, etc.) instead of autodetecting
-aAutomatically repair the filesystem without prompting (non-interactive mode)
-nOpen filesystem read-only; do not attempt to repair anything
-yAnswer yes to all prompts; useful for automated repair
-cCheck for bad blocks before starting the repair
-fForce checking even if filesystem appears clean
-vVerbose mode; print details about what is being checked
-pAutomatically repair problems that can be safely fixed (preen mode)
-CDisplay completion progress bar
-l fileAdd device name to a log file

Examples

Check /dev/sda1 in read-only mode without making any changes; useful for inspection

sudo fsck -n /dev/sda1

Automatically repair /dev/sda1; filesystem must be unmounted first

sudo fsck -a /dev/sda1

Force check the ext4 filesystem on /dev/sdb1 and answer yes to all repair prompts

sudo fsck -t ext4 -y /dev/sdb1

Check /dev/sda1 for bad blocks and repair any errors found

sudo fsck -c /dev/sda1

Check the root filesystem (only safe if booted in single-user or rescue mode)

sudo fsck /

Force a check on /dev/sdc1 even if it appears clean, with verbose output

sudo fsck -f -v /dev/sdc1

Preen mode: safely fix common problems without prompting (used at boot time)

sudo fsck -p /dev/sda2

Related commands