Disks and file system

Command fsck

Check and repair the file system

Linux · Bash examples · commands run on the selected server

When to use fsck

Use fsck to check or repair a filesystem only after identifying its type and checking whether it is mounted. Read the instructions for that filesystem first. Do not repair a filesystem while it is mounted and writable; use the recommended offline or recovery procedure.

Syntax

fsck [OPTIONS] [FILE_SYSTEM]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-N
Show planned actions without running a filesystem check.
-n
Pass read-only mode to a filesystem checker that supports it.
-f
Force a check with tools that support this option.

Usage examples

See which validation tool will be called

sudo fsck -N /dev/vdb1

The checker that would run is displayed without executing a repair.

Determine file system type

lsblk -f

Filesystem types and identifiers are inspected to verify the intended partition.

Check mount status

findmnt /dev/vdb1

The current mount relationship for the selected source is inspected.

Notes and limitations

  • Do not repair a mounted filesystem in use. Back up your data and follow the procedure for the specific filesystem.
  • fsck dispatches to filesystem-specific fsck.* tools. Options and support vary; XFS, for example, uses other tools.

Common questions and troubleshooting

Can I repair a mounted filesystem with fsck?

Ordinary offline repair generally requires the filesystem to be unmounted. Follow the filesystem's own recovery procedure and never assume a live root volume is safe.

Does a dry run prove the filesystem is healthy?

No. Showing the selected checker is not a full consistency test. Treat it as preparation, not a successful repair or health result.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man fsck.