Use it when the symptom is “Filesystem Corruption”: work through the layers in order and stop at the first one that fails.
Filesystem Corruption
Filesystem integrity depends on successful block I/O plus coherent filesystem metadata. Diagnose read-only and non-destructive checks first, then prove the backing device/path is stable before repair.
1. Corruption: check underlying disks/RAM first.
2. Image the device before repair if data is valuable.
3. Run repair offline.
4. Restore damaged data from backups.
5. Find the root cause.
corruption → device check → repair/restore
Context & applicabilityCommon mistakes · platform/version boundaries
A filesystem consistency error shows a filesystem structure is inconsistent; it does not by itself identify whether the cause was power loss, software, memory, media or transport.
Suspicious evidence includes repeated metadata errors after repair, new I/O errors, checksum mismatches, remount-read-only events or corruption recurring on the same blocks/device.
Operational reference
Fast context before you go deeper.
fsck -n /dev/<device>Primary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
Application symptom → filesystem metadata/data structures → block device/volume → path/controller → media/backend → read-only check → repair → read-back
Healthy evidence shows clean filesystem-specific verification, stable backing I/O and successful application/file read-back after recovery.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Filesystem error message ≠ failed disk automatically.
- Journal replay ≠ full integrity verification.
- Repair success ≠ user-file contents are correct.
- Running destructive repair on an unstable device can worsen recoverability.
dmesg | grep -i -e error -e corrupt— errorsfsck -n / xfs_repair -n— dry-run checkzpool status -v— ZFS damaged files
ReferenceImportant terms & boundaries3 sections · depth on demand
Scope and what the checks show
A filesystem consistency error shows a filesystem structure is inconsistent; it does not by itself identify whether the cause was power loss, software, memory, media or transport.
In depth
Check without changing first
e2fsck(8) is the checker for ext2/3/4. The manual says it is generally unsafe to run it on a mounted file system; the read-only -n mode is the only exception, and even then the results are not valid for a mounted system. Unmount, or boot a rescue system.
# umount /srv
# e2fsck -fn /dev/sdb1
e2fsck 1.47.0 (5-Feb-2023)
Pass 1: Checking inodes, blocks, and sizes
Inode 393218 has illegal block(s). Clear? no
...
/dev/sdb1: ********** WARNING: Filesystem still has errors **********
# echo $?
4
Options
| Option | Use |
|---|---|
-n | Read-only, answer "no" to everything — assessment |
-f | Force a check even if the file system looks clean |
-p | Automatically fix what is safe to fix |
-y | Answer "yes" to everything — only after a backup/image |
-b <superblock> | Use a backup superblock when the primary is damaged |
Exit codes are a bit mask
| Bit | Meaning |
|---|---|
| 0 | No errors |
| 1 | Errors corrected |
| 2 | Errors corrected, reboot required |
| 4 | Errors left uncorrected |
| 8 | Operational error |
Safe order
1. Find out why the corruption happened (I/O errors, power loss, host crash) — fixing metadata on a failing disk makes it worse.
2. Image the device (ddrescue) if the data matters and the disk is suspect.
3. e2fsck -fn, then e2fsck -fp or -fy on the image or the device.
4. Look in lost+found for recovered files.
5. Restore from backup when the check removes more than it saves.
*The e2fsck transcript and exit status demonstrate a read-only integrity check; no real volume was scanned.*
Method
Filesystem corruption is usually a symptom: find the cause before repairing.
1. Stop writes (unmount or remount read-only) to avoid spreading damage.
2. Check hardware: dmesg I/O errors, SMART, RAID status, memory (ECC errors in edac-util/rasdaemon).
3. Take an image or snapshot of the device if the data matters (ddrescue).
4. Run the filesystem's check in read-only mode first (e2fsck -n, xfs_repair -n, chkdsk /scan).
5. Repair, then compare against backups and restore damaged files.
Recurring corruption on a filesystem without checksums points to hardware, firmware, unclean shutdowns with volatile write caches, or two hosts mounting the same non-cluster filesystem.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Storage Troubleshooting → Filesystem Corruption. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/block/index.html · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Storage Troubleshooting → Filesystem Corruption proof map
Fast scope, dependency, failure-boundary and acceptance checks for Storage Troubleshooting → Filesystem Corruption.
| Troubleshooting boundary | What to verify | Proof limit |
|---|---|---|
| Scope / identity | Exact workload, object/device identity, affected hosts and incident window | Symptom naming alone is not root-cause proof |
| Dependency path | Application symptom → filesystem metadata/data structures → block device/volume → path/controller → media/backend → read-only check → repair → read-back | Healthy adjacent layers do not prove end-to-end health |
| Failure boundary | A filesystem consistency error proves a filesystem structure is inconsistent; it does not by itself identify whether the cause was power loss, software, memory, media or transport. | Correlate evidence for the same operation and timestamps |
| Acceptance | Healthy evidence shows clean filesystem-specific verification, stable backing I/O and successful application/file read-back after recovery. | Close only after the original workload/recovery test and regression check |