fsck: Linux File System Check and Repair

fsck

The Linux/Unix file system check and repair utility. Unlike Windows chkdsk which is a single monolithic tool, fsck is a wrapper that dispatches to filesystem-specific tools: e2fsck for ext2/ext3/ext4, xfs_repair for XFS, btrfs check for Btrfs, ntfsfix for NTFS via ntfs-3g, dosfsck for FAT. fsck integrates with /etc/fstab via the pass field (0=no check, 1=root, 2=other) and runs at boot via systemd-fsck@.service. The fundamental rule: fsck must run on unmounted filesystems; running on mounted volumes causes severe corruption. Common parameters: -y (yes to all), -n (read-only diagnostic), -p (safe automatic), -f (force), -A (all in fstab), -c (badblocks scan). The 5-pass e2fsck scan covers inodes, directory structure, connectivity, reference counts, and group summary. Orphan files go to lost+found.

Reference content reviewed by recovery engineers. Editorial standards. About the authors.
📚
9 sources
e2fsck man · Linuxize
OneUptime · 2DayGeek
📅
5 e2fsck passes
Inodes · Directories
Connectivity · Counts · Groups
📅
Last updated
util-linux package
📖
9 min
Reading time

fsck is the Linux/Unix file system check and repair utility, distributed as part of the util-linux package. It is a wrapper that dispatches to filesystem-specific tools: e2fsck for ext4, xfs_repair for XFS, btrfs check for Btrfs, ntfsfix for NTFS, dosfsck for FAT. The wrapper architecture is the fundamental difference from Windows chkdsk, which is a single monolithic utility. fsck integrates with /etc/fstab and systemd-fsck@.service for automatic boot-time checking. The fundamental rule: fsck must run on unmounted filesystems; running on mounted volumes causes severe corruption.

What fsck Is

The Linuxvox fsck reference provides a concise definition: “fsck (short for ‘File System Check’) is a utility that scans Linux file systems for inconsistencies and repairs them. It is part of the util-linux package, preinstalled on most Linux distributions. File systems (e.g., ext4, XFS, Btrfs) rely on metadata (inode tables, superblocks, etc.) to track files and directories. When a system shuts down improperly (e.g., power loss), or due to hardware issues (e.g., bad sectors), this metadata can become corrupted. fsck identifies such corruption (e.g., orphaned inodes, bad blocks, or mismatched file counts) and attempts to fix it.”1

The Unix philosophy origin

fsck dates back to early Unix (V7 in 1979) and reflects classic Unix design principles: small, focused tools that compose well rather than monolithic utilities. Key historical points:

  • 1979 (Unix V7): original fsck for the Bell Labs Unix file system; fixed inode and directory structure consistency.
  • 1980s BSD Unix: fsck adapted for Berkeley FFS (Fast File System) which became the model for many later filesystems.
  • 1992 (Linux 0.99): Linux inherited the fsck pattern; e2fsck developed for ext2 by Theodore Ts’o.
  • 1990s-2000s: filesystem-specific tools proliferated as new filesystems emerged (XFS, ReiserFS, JFS, Btrfs).
  • Modern systemd era: systemd-fsck@.service unit handles boot-time invocation.
  • util-linux package: the canonical home for fsck.c since 2002; bundled with virtually all Linux distributions.

When fsck runs automatically

Linux systems trigger fsck automatically in several scenarios. The Linuxize fsck reference describes the trigger conditions: “On most Linux distributions, fsck runs at boot time if a filesystem is marked as dirty or after a certain number of boots or time.” Specific triggers:

  • Dirty bit set: filesystem was not unmounted cleanly (power loss, kernel crash, force shutdown).
  • Mount count threshold: tune2fs -c configures the maximum mount count after which fsck runs.
  • Time interval: tune2fs -i configures the maximum time between checks (e.g., 2w for 2 weeks).
  • /forcefsck flag file: creating this file in the root triggers fsck on next boot.
  • fsck.mode=force kernel parameter: GRUB-level option to force fsck on every boot.
  • systemd-fsck@.service: the systemd unit that handles boot-time checking.

The /etc/fstab pass field

The OneUptime fsck reference describes the fstab integration: “In /etc/fstab, the last two fields control fsck: <fs> <mount> <type> <options> <dump> <pass>. Pass field values: 0 – Never check; 1 – Check first (root filesystem); 2 – Check after root (other filesystems).”2 The semantics:

  • Pass 0: never check; appropriate for swap partitions, btrfs filesystems, XFS filesystems (which don’t use traditional fsck), and network mounts.
  • Pass 1: check first; reserved for the root filesystem, so other checks don’t interfere with root recovery.
  • Pass 2: check after root; standard for non-root ext filesystems and FAT mounts.
  • Parallel checks: filesystems with the same pass number are checked in parallel, accelerating boot for systems with many filesystems.

The exit code spectrum

fsck returns specific exit codes that indicate the operation result; useful for scripts and automation:

CodeMeaningAction needed
0No errorsNone
1Errors correctedNone; filesystem now clean
2System should be rebootedReboot the system
4Errors left uncorrectedManual intervention required
8Operational errorCheck syntax and device existence
16Usage or syntax errorReview command parameters
32fsck canceled by userRe-run if check still needed
128Shared library errorSystem library issue

Privileges and execution requirements

fsck has specific execution requirements:

  • Root privileges required: sudo or root account; fsck modifies block devices and metadata.
  • Filesystem must be unmounted: the only safe exception is fsck -n (read-only diagnostic).
  • Root filesystem requires special handling: single-user mode, recovery mode, live USB, or boot-time check.
  • LVM volumes: activate with lvchange -ay if inactive; otherwise fsck operates normally on /dev/vg/lv paths.
  • Encrypted volumes: must be unlocked (cryptsetup luksOpen) before fsck can access the filesystem.

The fsck Wrapper Architecture

The wrapper architecture is fsck’s defining design choice and the most significant departure from chkdsk’s monolithic approach. Understanding the dispatch logic clarifies which actual tool runs in different scenarios.

The dispatch logic

The OneUptime Ubuntu fsck reference describes the wrapper behavior: “fsck is actually a wrapper that calls the appropriate filesystem-specific tool: # fsck dispatches to the right tool automatically sudo fsck /dev/sdb1 # Checks whatever filesystem is on sdb1.”3 The dispatch process:

  1. fsck examines the device’s filesystem signature (typically via blkid or libblkid).
  2. Based on the detected type, fsck looks up the corresponding fsck.<type> binary.
  3. fsck.ext2, fsck.ext3, fsck.ext4 → all symlinks to e2fsck.
  4. fsck.xfs → no-op script that points to xfs_repair.
  5. fsck.btrfs → no-op script that points to btrfs check.
  6. fsck.vfat / fsck.fat / dosfsck → handles FAT12/16/32.
  7. fsck.exfat → handles exFAT (separate package).
  8. fsck.ntfs → typically symlink to ntfsfix from ntfs-3g.

The filesystem-tool mapping

FilesystemWrapperReal toolRepair semantics
ext2fsck.ext2e2fsckFull 5-pass scan
ext3fsck.ext3e2fsckJournal replay + 5-pass
ext4fsck.ext4e2fsckJournal replay + 5-pass
XFSfsck.xfsxfs_repair (separate)Journal replay + B-tree check
Btrfsfsck.btrfsbtrfs check (separate)COW-aware check (use with care)
NTFSfsck.ntfsntfsfixLimited NTFS repair via ntfs-3g
FAT12/16/32fsck.vfat / fsck.fatdosfsckFAT chain repair
exFATfsck.exfatexfatfsckexFAT structure check
HFS+ (macOS)fsck_hfsfsck_hfsmacOS-native
APFS (macOS)fsck_apfsfsck_apfsmacOS-native

Common fsck command patterns

Several command patterns are commonly used in practice:

  • sudo fsck /dev/sdb1: auto-detect filesystem and run interactive check.
  • sudo fsck -n /dev/sdb1: read-only diagnostic; safe on mounted filesystems with limitations.
  • sudo fsck -y /dev/sdb1: automatic yes to all repair prompts; use with caution.
  • sudo fsck -p /dev/sdb1: automatically repair only safe issues; safer than -y.
  • sudo fsck -f /dev/sdb1: force check even if filesystem is marked clean.
  • sudo fsck -A: check all filesystems in /etc/fstab.
  • sudo fsck -AR: check all but skip root filesystem.
  • sudo fsck -fy /dev/sdb1: force check with yes-to-all; common comprehensive repair invocation.

The interactive vs automatic distinction

The e2fsck man page describes the interactive mode: “If e2fsck is run in interactive mode (meaning that none of -y, -n, or -p are specified), the program will ask the user to fix each problem found in the file system. A response of ‘y’ will fix the error; ‘n’ will leave the error unfixed; and ‘a’ will fix the problem and all subsequent problems; pressing Enter will proceed with the default response, which is printed before the question mark.”4 The three modes:

  • Interactive (default): prompts for each issue; appropriate for careful manual repair where the operator can review each decision.
  • -p (preserve): automatically fixes only “safe” issues; more conservative than -y; recommended for boot-time runs.
  • -y (yes to all): automatically fixes all issues including potentially destructive ones; fastest but riskiest.
  • -n (no, read-only): reports issues without fixing; safe for diagnosis and for limited use on mounted filesystems.

Boot-time fsck via systemd

Modern Linux distributions use systemd-fsck@.service for boot-time integration:

  • systemd-fsck-root.service: handles the root filesystem before mount.
  • systemd-fsck@.service: templated service for non-root filesystems based on /etc/fstab.
  • Configuration via /etc/fstab: the pass field controls which filesystems are checked.
  • fsck.mode kernel parameter: auto (default), force, or skip.
  • fsck.repair kernel parameter: preen (default, equivalent to -p), yes (-y), or no (don’t auto-repair).
  • Boot output: systemd routes fsck output to the system journal; visible via journalctl.

e2fsck and the Five-Pass ext Check

e2fsck is the most commonly invoked filesystem-specific tool because ext4 is the default filesystem on most Linux distributions. The 5-pass scan structure is well-documented and characteristic of ext family checks.

The five-pass structure

The Hopeness Medium e2fsck reference shows the typical scan output: “Pass 1: Checking inodes, blocks, and sizes / Pass 2: Checking directory structure / Pass 3: Checking directory connectivity / Pass 4: Checking reference counts / Pass 5: Checking group summary information.”5 Each pass targets a specific consistency aspect:

PassFocusWhat it checks
1Inodes, blocks, sizesInode validity, block pointers, file sizes, shared blocks
2Directory structureDirectory inode entries, ‘.’ and ‘..’, filename validity
3Directory connectivityAll directories trace back to root; orphans go to lost+found
4Reference countsInode link counts match directory entries
5Group summary informationBlock bitmap, inode bitmap, group descriptor accuracy

The journal replay shortcut

The e2fsck man page describes a key optimization for ext3/ext4: “For ext3 and ext4 filesystems that use a journal, if the system has been shut down uncleanly without any errors, normally, after replaying the committed transactions in the journal, the file system should be marked as clean. Hence, for filesystems that use journalling, e2fsck will normally replay the journal and exit, unless its superblock indicates that further checking is required.” The optimization:

  • After unclean shutdown, e2fsck checks the journal first.
  • If journal contains uncommitted transactions, they’re replayed to the filesystem.
  • If the superblock indicates the filesystem is otherwise consistent, e2fsck exits without running the 5-pass scan.
  • This makes most boot-time fsck runs near-instant on healthy ext4 filesystems.
  • The full 5-pass scan only runs when the journal replay isn’t sufficient or when -f forces it.

Pass 1: inode and block verification

Pass 1 is typically the longest pass on large filesystems:

  • Reads each inode in the filesystem (typically millions on a multi-TB drive).
  • Verifies inode metadata: type (file, directory, symlink), permissions, timestamps.
  • Checks block pointers within filesystem bounds.
  • Detects shared blocks: same block claimed by multiple inodes (corruption).
  • Verifies file sizes match block allocations.
  • Reports per-issue: “Inode X has illegal block(s)” and similar diagnostics.

Pass 2: directory structure

Pass 2 verifies directory contents and structure:

  • Reads each directory inode and walks its entries.
  • Verifies ‘.’ (self) and ‘..’ (parent) entries are present and correct.
  • Checks filename validity (length, character set).
  • Verifies inode references in directory entries point to valid inodes.
  • Detects duplicate entries within a single directory.
  • For htree-indexed directories, validates the index structure.

Pass 3: directory connectivity

Pass 3 ensures the directory tree is connected:

  • Starting from the root inode, traces all directory paths.
  • Identifies disconnected directories (those not reachable from root).
  • Reconnects orphan directories to lost+found.
  • Detects directory loops (a directory containing itself).

Pass 4: reference counts

Pass 4 verifies inode link counts:

  • For each inode, counts directory entries pointing to it.
  • Compares with the inode’s stored link count.
  • Corrects mismatches.
  • Identifies inodes with 0 actual references that should be deleted.

Pass 5: group summary

Pass 5 verifies the bitmap and group descriptor accuracy:

  • Verifies block bitmap matches actual allocated blocks.
  • Verifies inode bitmap matches actual used inodes.
  • Verifies group descriptor counts (free blocks, free inodes, used directories).
  • Updates summary information if mismatches found.

e2fsck-specific parameters

Beyond the standard fsck parameters, e2fsck has ext-specific options:

  • -c (badblocks): invokes badblocks(8) for a read-only scan; bad blocks added to bad block inode.
  • -cc (badblocks RW): non-destructive read-write badblocks scan; more thorough.
  • -b superblock: use alternate superblock (typically 32768, 98304, 163840, etc.).
  • -B blocksize: force specific blocksize when locating superblock.
  • -D: optimize directories (reindex htree directories).
  • -E: set extended options (e.g., -E discard for SSD trim).
  • -l filename / -L filename: add bad blocks from file (-l) or replace bad block list (-L).

Alternate superblock recovery

When the primary superblock is corrupted, e2fsck can use backup copies. The OneUptime fsck reference describes the recovery procedure: “If the ext4 superblock is corrupted, fsck will report it and offer to use a backup: # Find backup superblock locations sudo mke2fs -n /dev/sdb1 # Dry run shows superblock locations without formatting.” Typical backup locations: 32768, 98304, 163840, 229376, 294912 (for default 4K blocks). The recovery sequence: sudo e2fsck -b 32768 /dev/sdb1.

fsck for Other File Systems

While ext is the most common Linux filesystem, fsck must handle several others. Each has distinct repair semantics that affect how recovery scenarios play out.

XFS: xfs_repair as the real tool

The Linuxize fsck reference summarizes the XFS situation: “fsck does not repair XFS or Btrfs. Use the filesystem-specific tool. XFS uses xfs_repair, and Btrfs usually uses btrfs scrub or btrfs check.”6 The XFS-specific workflow:

  • fsck.xfs: no-op script that prints “see xfs_repair(8)” and exits.
  • xfs_repair -n /dev/sdb1: read-only check; identifies issues without modifying.
  • xfs_repair /dev/sdb1: full repair; filesystem must be unmounted.
  • xfs_repair -L /dev/sdb1: clear log; last resort when xfs_repair fails with “dirty log” error; risks data loss.
  • Mount-time journal replay: XFS replays its journal automatically when mounted; xfs_repair handles deeper corruption.
  • B-tree-based metadata: XFS uses B-trees rather than the inode-table model of ext; xfs_repair logic differs accordingly.
  • fstab pass=0: XFS filesystems should have fstab pass=0 to prevent boot-time fsck attempts.

Btrfs: scrub vs check vs repair

Btrfs has the most complex relationship with fsck because of its copy-on-write architecture. The fsck.btrfs man page describes the design: “fsck.btrfs is a type of utility that should exist for any filesystem and is called during system setup when the corresponding /etc/fstab entries contain non-zero value for fs_passno… Traditional filesystems need to run their respective fsck utility in case the filesystem was not unmounted cleanly and the log needs to be replayed before mount. This is not needed for BTRFS. You should set fs_passno to 0.”7 The Btrfs ecosystem:

  • fsck.btrfs: no-op that prints “see btrfs(8) subcommand check” and exits.
  • btrfs scrub: the active maintenance tool; reads all data and metadata, verifying checksums; runs on mounted filesystems.
  • btrfs check –readonly /dev/sdb1: safe diagnostic; identifies issues without modifying.
  • btrfs check –repair /dev/sdb1: dangerous repair mode; can cause additional corruption; last resort.
  • btrfs rescue: emergency tools (zero-log, super-recover, chunk-recover) for severe corruption.
  • Snapshots as recovery: the preferred Btrfs recovery is to roll back to an earlier snapshot rather than use –repair.
  • Recovery mount options: rescue=usebackuproot, recovery, etc., for emergency mounting.

FAT family: dosfsck

FAT12, FAT16, and FAT32 are handled by dosfsck (also accessible as fsck.vfat or fsck.fat):

  • fsck.vfat /dev/sdb1: standard invocation for FAT volumes.
  • -a: automatic repair (safer than -y for FAT).
  • -r: interactive repair with prompts.
  • -w: write changes immediately to disk during repair.
  • -V: verify after repair by re-reading.
  • FAT-specific issues: cluster chain corruption, FAT/FAT2 inconsistency, lost clusters, cross-linked files.
  • FOUND.000 equivalent: FAT recovery doesn’t use lost+found; instead places lost clusters in FILE0001, FILE0002 in root.

exFAT: exfatfsck

exFAT (used on SD cards and USB drives over 32GB) has its own checker:

  • fsck.exfat /dev/sdb1: from the exfatprogs package (modern) or exfat-utils (legacy).
  • Limited functionality: exFAT repair tools are less mature than ext or NTFS counterparts.
  • Cross-platform considerations: exFAT volumes may be checked on Windows or macOS instead.

NTFS: ntfsfix

NTFS support on Linux is via the ntfs-3g package; the fsck-equivalent is ntfsfix:

  • ntfsfix /dev/sdb1: basic NTFS repair via ntfs-3g.
  • Limited compared to chkdsk: ntfsfix handles common issues but isn’t a full chkdsk replacement.
  • Use case: primarily clears the dirty bit and fixes minor inconsistencies so the volume can be mounted.
  • For serious NTFS repair: mount the drive on Windows and use chkdsk; ntfsfix is a stopgap.
  • fsck.ntfs: typically a symlink to ntfsfix on systems with ntfs-3g installed.

macOS fsck variants

On macOS, the fsck command exists but dispatches to macOS-specific filesystem tools:

  • fsck_hfs: for HFS+ volumes (Mac OS Extended).
  • fsck_apfs: for APFS volumes (modern Mac default).
  • fsck_msdos: for FAT volumes.
  • fsck_exfat: for exFAT volumes.
  • Single-user mode: macOS allows fsck on root via Recovery Mode or single-user mode (Cmd+S at boot).
  • Disk Utility: graphical front-end that invokes the appropriate fsck variant.

fsck and Data Recovery

fsck has the same fundamental data recovery dynamics as chkdsk: it can both help and harm depending on the scenario. The Linux ecosystem provides additional tools that complement fsck for recovery workflows.

The image-first recovery workflow on Linux

The professional Linux recovery workflow:

  1. Stop using the affected drive: unmount immediately if mounted; remount read-only if active access is needed.
  2. Image the drive: use ddrescue (the standard Linux recovery imager) or HDDSuperClone for severely-damaged drives.
  3. Verify the image: calculate hashes; ensure complete acquisition.
  4. Run recovery against the image: use TestDisk, PhotoRec, ext4magic, extundelete, or specialized tools on the image file.
  5. Save recovered files to a separate destination: never overwrite the original drive or its image.
  6. Validate recovered data: check critical files for integrity.
  7. Optionally run fsck on the original drive: only after recovery, to restore filesystem functionality for reuse.

The lost+found directory

fsck creates and uses a lost+found directory in the filesystem root for orphan files. The OneUptime fsck reference describes the convention: “When fsck finds orphaned files (files with no directory entry), it places them in the lost+found directory: # List lost+found contents ls -la /lost+found/ # Files are named by inode number # Example: #12345 is inode 12345.” Key properties:

  • Located at the filesystem root (e.g., /lost+found/ or /home/lost+found/).
  • Files named by inode number with # prefix (e.g., #12345).
  • Original filenames are lost; only the data content survives.
  • Uses the file utility to identify file types: file /lost+found/#12345.
  • For text files, simple cat or less can reveal content; for binary files, signature analysis is needed.
  • Created automatically by mke2fs when the filesystem is created; pre-allocates space.
  • If lost+found is missing or full, mklost+found utility recreates it.

Linux-specific recovery tools

The Linux ecosystem has specialized recovery tools that complement fsck:

  • ddrescue / dd_rescue: the standard Linux drive imaging tools; handle bad sectors gracefully.
  • TestDisk: partition table repair and partition recovery.
  • PhotoRec: file carving from images or drives; recovers files by signature regardless of filesystem.
  • ext4magic: ext4-specific recovery using the journal to recover deleted files.
  • extundelete: ext3/ext4 deleted file recovery using inode metadata.
  • foremost / scalpel: file carving tools; alternatives to PhotoRec.
  • debugfs: low-level ext filesystem debugger; manual inode and block manipulation.
  • btrfs restore: Btrfs-specific recovery from damaged filesystems.
  • xfs_db: XFS debugger for low-level access.
  • R-Studio Linux / UFS Explorer: commercial cross-filesystem recovery tools.

Why fsck can harm recovery

The same metadata-modification risks apply to fsck as to chkdsk:

  • Inode modifications: e2fsck may overwrite inode entries that recovery tools like ext4magic could otherwise use.
  • Directory rebuilds: Pass 2 and Pass 3 may regenerate directory entries, losing pointers to deleted files.
  • Journal replay: the journal contains recent metadata changes; replay commits them and overwrites previous state.
  • Bitmap updates: Pass 5 modifies block and inode bitmaps; recovery tools may interpret freed inodes as reusable.
  • Orphan reconnection: moving files to lost+found loses original filenames and directory context.
  • Badblocks scan with -c: reads and potentially writes to questionable sectors; can stress failing drives.

When fsck is appropriate

Despite the risks, fsck has clear roles:

  • Routine maintenance: periodic fsck on healthy drives via mount count or time interval.
  • Post-crash recovery: automatic boot-time fsck after unclean shutdown.
  • Post-recovery functionality restoration: after data has been recovered or written off, fsck restores filesystem usability.
  • Fresh formatting validation: verifying integrity of newly-created filesystems.
  • Pre-deployment checks: validating drives before production use.
  • Read-only diagnostics: fsck -n is safe even on mounted filesystems for status reporting.

When fsck is dangerous

Specific scenarios where fsck should be avoided:

  • Mounted filesystems: guaranteed corruption; the only safe exception is fsck -n.
  • Drives with critical irreplaceable data and signs of corruption: recover first, then fsck.
  • Failing or marginal hardware: badblocks scan with -c stresses already-weak drives.
  • Btrfs filesystems with snapshots: btrfs check –repair can damage snapshot trees; rollback is preferred.
  • XFS with dirty log: xfs_repair -L last resort only; clears journal and can lose recent changes.
  • Encrypted volumes without backup: fsck on dm-crypt mappings can interact unpredictably with the underlying encrypted layer.

fsck is the Linux administrator’s daily companion: it runs automatically at boot, integrates with /etc/fstab, and provides a unified interface across diverse filesystems. For data recovery purposes, the key insight is the wrapper architecture: invoking “fsck” doesn’t tell you which actual tool will run, and the underlying tools have radically different repair semantics. e2fsck on ext4 is a thorough 5-pass checker; xfs_repair on XFS is a B-tree-aware repair tool; btrfs check is so risky that the documentation recommends snapshot rollback instead. Understanding which tool is doing the work helps predict whether fsck will help or harm in any given scenario.

For Linux users wondering whether to run fsck, the practical guidance follows the data importance and filesystem type. For routine maintenance on ext filesystems with no missing files, periodic fsck (configured via tune2fs mount count or time interval) is reasonable and safe. For drives with replaceable data showing symptoms (mount errors, corrupted files), fsck -fy is the standard repair attempt. For drives with irreplaceable data and any signs of failure, fsck should be deferred until after data has been preserved through ddrescue imaging. The dirty bit can be checked via tune2fs -l on ext filesystems; XFS filesystems should never have fstab pass set to non-zero; Btrfs users should rely on btrfs scrub for routine maintenance and snapshot rollback for recovery rather than btrfs check –repair.

For Linux users facing fsck-related recovery scenarios, the practical guidance reflects the toolset available. If files are missing after fsck, check /lost+found/ for inode-numbered orphan files; identify file types with the file command and rename appropriately. Standard data recovery software often runs natively on Linux; HDD-focused recovery tools like TestDisk and PhotoRec are open-source and widely used in Linux recovery workflows. For ext-specific deleted file recovery, ext4magic and extundelete leverage filesystem journal contents to recover files that fsck might have processed but not fully removed. Cleanroom recovery services are filesystem-agnostic and can help with physical drive damage that fsck cannot address. The strongest defense remains preventive: ddrescue imaging before any fsck operation, and image-first workflows when recovery is the priority.

fsck FAQ

What is fsck?+

fsck (file system check) is the Linux/Unix utility for checking and repairing file system consistency. The Linuxvox fsck reference describes its purpose: it scans Linux file systems for inconsistencies and repairs them, identifying issues such as orphaned inodes, bad blocks, mismatched file counts, and corrupted superblocks. Unlike Windows chkdsk which is a single monolithic tool, fsck is a wrapper that dispatches to filesystem-specific tools based on the file system type detected. The OneUptime fsck reference confirms the architecture: “fsck is actually a wrapper that calls the appropriate filesystem-specific tool.” For ext2/ext3/ext4 filesystems, fsck calls e2fsck (also accessible as fsck.ext2, fsck.ext3, fsck.ext4). For XFS, the actual repair is done by xfs_repair. For Btrfs, btrfs check is the real tool. For NTFS, ntfsfix from ntfs-3g handles repairs. fsck integrates with /etc/fstab and runs automatically at boot via systemd-fsck@.service when filesystem is marked dirty or scheduled by mount count or time interval.

Why is fsck a wrapper instead of a single tool?+

The wrapper architecture reflects Unix philosophy and the diversity of Linux file systems. Each file system has its own metadata structure, journal format, and repair semantics; a single tool would be unable to handle them all effectively. The OneUptime Ubuntu fsck reference explains the dispatch logic: when invoked, fsck examines the file system type and calls the appropriate specialized tool. ext filesystems use e2fsck because they share a common metadata format (inodes, block groups, superblocks) and benefit from a unified checker. XFS uses xfs_repair because its B-tree-based metadata requires fundamentally different repair logic. Btrfs uses btrfs check because copy-on-write semantics and snapshot trees can’t be repaired with traditional inode-based logic. NTFS uses ntfsfix because the file system originated on Windows and has its own conventions. The wrapper provides a consistent command-line interface (fsck /dev/sda1 works regardless of filesystem) while preserving each tool’s specialized capabilities.

What are the e2fsck five passes?+

e2fsck performs a 5-pass scan on ext2/ext3/ext4 filesystems when running with -f or after detecting corruption. Pass 1 (Checking inodes, blocks, and sizes): verifies each inode in the filesystem; checks for valid inode types, block pointers within filesystem bounds, correct file sizes, and no shared blocks between files. Pass 2 (Checking directory structure): verifies each directory inode by reading the directory entries and confirming filename validity, ‘.’ and ‘..’ entries, and correct inode references. Pass 3 (Checking directory connectivity): verifies all directories can be traced back to the root directory; orphaned directories not connected to root are reconnected to lost+found. Pass 4 (Checking reference counts): verifies inode link counts match the number of directory entries pointing to each inode; corrects any mismatches. Pass 5 (Checking group summary information): verifies block bitmap, inode bitmap, and group descriptor counts match actual filesystem state; corrects discrepancies. The 5-pass structure reports: “Pass 1: Checking inodes, blocks, and sizes / Pass 2: Checking directory structure / Pass 3: Checking directory connectivity / Pass 4: Checking reference counts / Pass 5: Checking group summary information.”

What does fsck do for XFS and Btrfs?+

For XFS and Btrfs, fsck itself does essentially nothing; it exits successfully and points users to the correct repair tool. The fsck.btrfs man page describes the design: “fsck.btrfs is a type of utility that should exist for any filesystem and is called during system setup when the corresponding /etc/fstab entries contain non-zero value for fs_passno… Traditional filesystems need to run their respective fsck utility in case the filesystem was not unmounted cleanly and the log needs to be replayed before mount. This is not needed for BTRFS.” For XFS: fsck.xfs is a no-op that prints “see xfs_repair(8)”; the real repair tool is xfs_repair which must be run on unmounted filesystems and supports -n (read-only check) and -L (clear log, last resort). For Btrfs: fsck.btrfs is a no-op that prints “see btrfs(8) subcommand check”; the real tool is btrfs check with –readonly for safe checks and –repair for actual repairs (use with extreme caution). Btrfs users typically rely on btrfs scrub for routine integrity checking rather than btrfs check. For both filesystems, /etc/fstab pass field should be set to 0 to prevent boot-time fsck attempts.

Can fsck be run on a mounted filesystem?+

Generally no. The e2fsck man page is explicit on this point: “Note that in general it is not safe to run e2fsck on mounted filesystems. The only exception is if the -n option is specified, and -c, -l, or -L options are not specified. However, even if it is safe to do so, the results printed by e2fsck are not valid if the filesystem is mounted.” Running fsck on a mounted filesystem causes severe corruption because both the running system and fsck modify filesystem metadata simultaneously, leading to inconsistent state worse than the original problem. The OneUptime fsck reference reinforces this: running fsck on a mounted filesystem “can cause worse corruption than you started with.” For non-root filesystems: unmount with umount /dev/sdaX before running fsck. For the root filesystem (which cannot be unmounted while the system runs): boot from a live USB, use single-user/recovery mode, or create the /forcefsck flag file before reboot to trigger a boot-time check before mount. The -n option is the only safe alternative for active filesystems but provides only read-only diagnostic information.

Should I run fsck before data recovery?+

Generally no, similar to chkdsk: image the drive first, then run recovery against the image, and only run fsck on the original drive after recovery completes. The reasoning: fsck modifies file system metadata to restore consistency, including writing to inode tables, directory structures, superblocks, and reference counts. These modifications can overwrite metadata that recovery tools rely on to identify deleted or damaged files. The standard professional recovery workflow on Linux: (1) image the drive sector-by-sector using ddrescue, dd_rescue, or HDDSuperClone; (2) run recovery against the image using PhotoRec, TestDisk, ext4magic, extundelete, or similar specialized tools; (3) save recovered files to a separate destination drive; (4) only after recovery is complete, optionally run fsck on the original drive to restore filesystem functionality. For routine maintenance on healthy drives, fsck is appropriate and safe; for drives with critical irreplaceable data showing signs of corruption, fsck should be deferred until after data preservation. The lost+found directory will contain orphan files that fsck couldn’t reconnect during repair; these should be inspected before deletion in case they contain important data.

Related glossary entries

  • chkdsk: Windows file system check counterpart to fsck; monolithic vs wrapper architecture.
  • ext4: the most common Linux filesystem; primary target of e2fsck.
  • Btrfs: copy-on-write filesystem; uses btrfs check rather than traditional fsck.
  • Inode: ext filesystem metadata unit; e2fsck Pass 1 verifies inode consistency.
  • Journaling File System: ext3/ext4/XFS rely on journals; fsck replays uncommitted transactions.
  • Disk Image: the recommended pre-fsck step for data recovery scenarios.
  • Data Corruption: fsck’s primary repair target on Linux/Unix systems.

About the Authors

đŸ‘„ Researched & Reviewed By
Rachel Dawson
Rachel Dawson
Technical Approver · Data Recovery Engineer

Rachel brings over twelve years of data recovery engineering experience including substantial work involving fsck-related cases on Linux servers and workstations. The most consistent pattern in fsck recovery cases is the administrator who ran fsck -y on a corrupted ext4 filesystem to “fix” it and discovered later that the automatic yes-to-all prompts had moved important files into lost+found with inode-numbered names that lost all original directory context. The “image first” rule is even more critical on Linux than on Windows because the available recovery tooling (ddrescue, ext4magic, extundelete) is so capable that pre-fsck images often allow near-complete recovery of files that fsck would have orphaned. The harder cases involve filesystem-specific corruption: XFS dirty log scenarios where xfs_repair -L is the only path forward but loses recent changes; Btrfs cases where btrfs check –repair causes additional damage and snapshot rollback would have been the better recovery path; NTFS-on-Linux cases where ntfsfix has limited capabilities and Windows chkdsk would have been more effective. The universal recovery advice on Linux: use ddrescue first, run recovery tools against the image, and reserve fsck for post-recovery filesystem cleanup.

12+ years data recovery engineeringLinux server recoveryext4 forensics
✅
Editorial Independence & Affiliate Disclosure

Data Recovery Fix earns revenue through affiliate links on some product recommendations. This does not influence our reference content. Glossary entries are written and reviewed independently based on documented research, vendor documentation, independent testing, and recovery-engineer review. If anything on this page looks inaccurate, outdated, or worth revisiting, please reach out at contact@datarecoveryfix.com and we’ll review it promptly.

We will be happy to hear your thoughts

Leave a reply

Data Recovery Fix: Reviews, Comparisons and Tutorials
Logo