Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

6.2.1. Filesystem and Disk Diagnostics

# Capacity
df -h                            # Block space usage by mount point
df -i                            # Inode usage (can fill independently of blocks)
du -sh /*                        # Space by top-level directory
du -sh /var/* | sort -h          # Find large directories in /var
find / -size +500M               # Files larger than 500 MB

# Filesystem integrity
# MUST unmount before checking (or use read-only root for /)
fsck -n /dev/sda1                # Dry run — report errors without fixing
fsck -y /dev/sda1                # Auto-fix all errors (use carefully)
xfs_repair -n /dev/sdb1          # XFS read-only check
xfs_repair /dev/sdb1             # XFS repair

# Force fsck on next boot (ext4)
touch /forcefsck                 # Some distros honor this file
tune2fs -C 100 /dev/sda1        # Set mount count to trigger fsck threshold

# Disk health
smartctl -a /dev/sda             # Full SMART data
smartctl -H /dev/sda             # Health summary only
smartctl -t short /dev/sda       # Run short self-test
badblocks -v /dev/sdb            # Scan for bad blocks (read-only mode)

# LVM diagnostics
pvdisplay                        # Physical volume status
vgdisplay                        # Volume group status  
lvdisplay                        # Logical volume status
lvs -o +devices                  # Show which PVs each LV spans
vgck                             # Check VG consistency
Common Storage Error Patterns:
Error MessageLikely CauseInvestigation
No space left on deviceBlocks OR inodes fulldf -h and df -i
Read-only file systemFilesystem auto-remounted RO on errorsdmesg for I/O errors
Structure needs cleaningFilesystem corruptionfsck after unmounting
Input/output errorHardware failuresmartctl -a, dmesg
wrong fs type or bad superblockWrong filesystem type or corrupted superblockblkid to confirm type
Recovering from Read-Only Remount:

When a filesystem encounters I/O errors, Linux automatically remounts it read-only to prevent further corruption. Fix the underlying hardware issue first, then:

# Check for errors
dmesg | tail -50                 # I/O errors, SMART alerts
smartctl -a /dev/sda             # SMART status

# If hardware is healthy — filesystem corruption
umount /data
fsck -y /dev/sda1
mount /data

# If hardware is bad — replace disk first
# Do NOT try to repair filesystem on a failing drive — you'll lose data

⚠️ Exam Trap: Running fsck on a mounted filesystem is dangerous and will corrupt data. The only exception is the root filesystem during boot (when a special journal-aware check can run). For all other filesystems: unmount first, then fsck. If you can't unmount (root), boot to rescue mode.

Reflection Question: A server shows df -h at 60% for /var/log, but every new log write fails with "No space left on device." What command reveals the actual problem, and what could cause this discrepancy?

Alvin Varughese
Written byAlvin Varughese
Founder18 professional certifications