Linux Filesystem Check: 3 Commands to Detect Disk Errors

Quick Linux Tip #123:

Question: How do I check if my mounted filesystem is corrupted?

Try: sudo touch /forcefsck && sudo shutdown -r +1 'Scheduled fsck'

Info: Triggers boot-time checks, while read-only flags safely audit mounted filesystems instantly.

Examples:

  • $ sudo tune2fs -c 1 /dev/sda1  # Force a filesystem check after every mount count
  • $ sudo fsck -y /dev/sdb1  # Automatically repair an unmounted filesystem
  • $ sudo xfs_repair -n /dev/sda1  # Perform a dry-run check on an XFS filesystem

Note: Read-only audits are safe but limited; actual repairs require unmounted filesystems. Different filesystems require dedicated utilities like xfs_repair or btrfs check. Always create a full backup before attempting repairs.




LinuxTeck.com
linuxteck:~$ sudo touch /forcefsck && sudo shutdown -r +1 'Scheduled fsck'
Shutdown scheduled for Mon 2026-11-09 11:35:00 IST, use 'shutdown -c' to cancel.

Broadcast message from root@server01 (Mon 2026-11-09 11:34:00 IST):

Scheduled fsck
The system is going down for reboot at Mon 2026-11-09 11:35:00 IST!

linuxteck:~$ sudo e2fsck -nf /dev/sda1
e2fsck 1.46.5 (30-Dec-2021)
Warning! /dev/sda1 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
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
/dev/sda1: 234567/6553600 files (0.3% non-contiguous), 2345678/26214400 blocks
linuxteck:~$

PREVIOUS ARTICLE Quick Linux Tip #122: Sudo Command Audit: Track Who Ran Commands in Linux NEXT ARTICLE Quick Linux Tip #124: Linux Scheduled Tasks: Find Every Cron Job and Timer
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.