Disk errors in Linux often appear as I/O error messages, slow reads, or files that become inaccessible without warning. Prompt correction reduces the risk of prolonged downtime, unexpected crashes, and difficult data recovery on critical systems.

At a technical level, problems can exist in several layers: filesystem metadata, block-device mapping, or the physical storage medium. Tools such as fsck repair journal and metadata inconsistencies, smartctl queries on-disk S.M.A.R.T. attributes, and badblocks performs sector-level read tests to uncover unreadable regions.

Safe repair depends on working against unmounted filesystems, reliable power, and current backups for important data. Root filesystems or busy volumes typically require booting from a live Linux environment before running checks, and long scans on large disks can take hours, so maintenance windows and log monitoring are essential.

Steps to repair disk errors in Linux:

  1. List the block devices and partitions present on the system.
    $ lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0   20G  0 disk 
    ├─sda1   8:1    0    1M  0 part 
    ├─sda2   8:2    0  513M  0 part /boot/efi
    └─sda3   8:3    0 19.5G  0 part /

    The lsblk output helps identify the device and partition names to target during repair.

  2. Unmount the target filesystem that requires repair.
    $ sudo umount /dev/sda3
    [sudo] password for user:

    Replace sda3 with the correct partition identifier and ensure the filesystem is fully unmounted before continuing; if unmount fails because the filesystem is in use, run the repair from a live Linux environment instead.

  3. Run fsck on the unmounted filesystem to detect and repair logical errors.
    $ sudo fsck -f /dev/sda3
    fsck from util-linux 2.36.1
    e2fsck 1.45.7 (28-Jan-2021)
    /dev/sda3: recovering journal
    /dev/sda3: clean, 11/1310720 files, 126322/5242880 blocks

    Running fsck against a mounted filesystem risks immediate data corruption, so checks must occur only after a successful unmount of the target partition.

  4. Display the disk S.M.A.R.T. health summary to identify hardware faults.
    $ sudo smartctl -H /dev/sda
    === START OF READ SMART DATA SECTION ===
    SMART overall-health self-assessment test result: PASSED

    If smartctl is unavailable, install the smartmontools package from the distribution repositories; any failing or pre-fail attributes warrant an immediate backup and planned disk replacement.

  5. Scan the filesystem for unreadable sectors using badblocks in non-destructive mode.
    $ sudo badblocks -sv /dev/sda3
    Checking blocks 0 to 20971519
    Checking for bad blocks (read-only test): done                                                 
    Pass completed, 0 bad blocks found. (0/0/0 errors)

    Non-destructive scans with badblocks -sv only read data, but enabling write-mode with -w overwrites existing contents and should be used only after verified backups and a planned maintenance window.

  6. Mount the repaired filesystem at a temporary mount point.
    $ sudo mount /dev/sda3 /mnt

    Use the original mount point or adjust /etc/fstab entries as needed before returning the filesystem to production workloads.

  7. Verify that the filesystem mounts cleanly and that space usage looks normal.
    $ df -h /mnt
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda3        20G   11G  8.0G  58% /mnt

    Absence of new I/O error messages in dmesg or system logs, combined with a successful mount and expected capacity values, indicates that disk errors have been addressed.

Discuss the article:

Comment anonymously. Login not required.