Disk integrity in Linux: fsck and smartctl
Updated November 1, 2026
fsck checks and repairs a filesystem, while smartctl reads the health of the disk itself from its SMART data.
Common cases
sudo umount /dev/sdb1 # unmount before checking
sudo fsck /dev/sdb1 # check and repair the filesystem
sudo fsck -n /dev/sdb1 # -n check only, change nothing
sudo smartctl -H /dev/sda # an overall health verdict for the disk
sudo smartctl -a /dev/sda # all SMART attributesSample output
$ sudo fsck -fy /dev/loop1
fsck from util-linux 2.39.3
e2fsck 1.47.0 (5-Feb-2023)
Pass 1: Checking inodes, blocks, and sizes
Inode 17 seems to contain garbage. Clear? yes
...
Pass 2: Checking directory structure
Entry 'f5.txt' in /docs (12) has deleted/unused inode 17. Clear? yes
...
data: ***** FILE SYSTEM WAS MODIFIED *****
data: 16/16384 files (6.3% non-contiguous), 2070/16384 blocksHow it works: two different checks
These are about different layers.
fsck(file system check) repairs the LOGIC of a filesystem: lost blocks, broken links, a count left inconsistent after a power cut. You run it only on an unmounted partition. On a mounted one you can corrupt the filesystem; usually the system runsfsckitself at boot if it spots a problem.smartctllooks at the HARDWARE: disks run their own SMART self-diagnostics (reallocated sector count, read errors, power-on hours). A rising reallocated-sector count is a sign the disk is dying and should be replaced before it fails.
Common mistakes
fsck does not work on a mounted filesystem. It refuses out loud: /dev/loop1 is mounted. and e2fsck: Cannot continue, aborting.. With -n it does run, but it warns Warning! /dev/loop1 is mounted. and adds Warning: skipping journal recovery because doing a read-only filesystem check - a 'clean' verdict after that check guarantees nothing. The order is fixed: umount first, then fsck.
fsck skips a filesystem flagged as clean. It prints data: clean, 14/16384 files, 2068/16384 blocks and exits in a fraction of a second, without running any of the five passes. -f turns on the real check, and -y answers yes to every question, where a repair means a delete: after fsck -fy on a damaged image, 4 of the 20 files in /docs were left, the rest went out through lines like Entry 'f5.txt' in /docs (12) has deleted/unused inode 17. Clear? yes, and lost+found stayed empty. Take a dd copy of the partition before you repair.
smartctl talks to hardware, so it has nothing to say in a container or on a virtual disk. As an ordinary user it stops at Smartctl open device: /dev/vdb failed: Permission denied. As root on a virtio disk it stops at /dev/vdb: Unable to detect device type, because a virtual disk carries no SMART data. smartctl --scan shows what is reachable at all; when that list is empty, no flag will help.
In the book
This topic is covered in full in the chapter Advanced storage and data integrity.