Updated: 4 November 2026 · Applies to: smartmontools 7.2 to 7.4, e2fsprogs badblocks and xfsprogs on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13

Disk errors show up as I/O errors in the logs, slow file access, or a file system that turns read-only. Modern disks (HDD and SSD) replace bad sectors themselves and report their health through S.M.A.R.T., so that is the first thing to check. Scanning the surface with badblocks is a second step, mainly for hard disks. We ran the commands on AlmaLinux 9.

1. Look for errors in the logs

journalctl -k -p err | tail -30
dmesg -T | grep -i -E "i/o error|medium error|ata[0-9]+.*error|nvme.*error"

2. Check the disk's own health (S.M.A.R.T.)

dnf install smartmontools     # or: apt install smartmontools
smartctl -H /dev/sda          # overall result: PASSED or FAILED
smartctl -a /dev/sda          # all attributes and the error log
smartctl -t short /dev/sda    # start a short self-test (about 2 minutes)
smartctl -l selftest /dev/sda # result of the self-tests

Warning signs on hard disks are rising values for Reallocated_Sector_Ct, Current_Pending_Sector and Offline_Uncorrectable; on NVMe SSDs, Media and Data Integrity Errors and a high Percentage Used. For details, see how to install and use smartctl and how to monitor disk health with smartd.

On virtual servers, the virtual disks have no S.M.A.R.T. data; disk health is your provider's responsibility there.

3. Scan for bad blocks (hard disks)

A read-only scan is safe on a disk with data, but it takes hours on large disks and should run when the disk is not busy:

badblocks -sv /dev/sdb

-s shows progress and -v reports what it finds; the end result looks like Pass completed, 0 bad blocks found. Never use the write test (-w) on a disk with data: it overwrites everything.

4. Check the file system

The file system must be unmounted (for the root file system, from a rescue system):

xfs_repair -n /dev/sdb1       # XFS: check only, no changes
e2fsck -fn /dev/sdb1          # ext4: check only, no changes

For ext4, e2fsck -c runs a read-only bad block scan and records bad blocks in the file system so they are not used. XFS has no such list; it relies on the disk to remap bad sectors.

What to do when a disk is failing

  • Back up the data immediately. A disk with growing reallocated or pending sectors usually gets worse.
  • Replace the disk. In a RAID array, replace the failed member and let the array rebuild.
  • On a dedicated server, contact your provider with the smartctl -a output so the disk can be swapped.

Official documentation: smartmontools and badblocks manual.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $131.99 a month.

Was this answer helpful?

Still stuck? Open a ticket