Troubleshooting Linux Storage

Storage issues in Linux can lead to data loss, performance degradation, and system instability. This guide will help you troubleshoot common storage problems, ensuring your Linux environment remains reliable and efficient.

Common Storage Issues

Disk Space Full

Symptoms:

  • Error messages indicating that the disk is full.
  • Inability to write files or install software.

Troubleshooting Steps:

  • Check Disk Usage: Use df -h to check available disk space:
    df -h
  • Find Large Files: Identify large files consuming space using:
    sudo du -ah / | sort -rh | head -n 20
  • Clean Up: Remove unnecessary files or logs, clear package cache (sudo apt-get clean), and consider archiving old data.

Disk Read/Write Errors

Symptoms:

  • Input/output errors when accessing files.
  • Slow performance or system hangs during disk operations.

Troubleshooting Steps:

  • Check Disk Health: Use smartctl to assess the health of your disk:
    sudo smartctl -a /dev/sda
  • Run fsck: Use fsck to check and repair the filesystem:
    sudo fsck /dev/sda1
  • Monitor Disk Activity: Use iostat or iotop to monitor disk activity and identify problematic processes.

Filesystem Corruption

Symptoms:

  • Files or directories that are inaccessible or missing.
  • Errors when mounting filesystems.

Troubleshooting Steps:

  • Unmount and Check: Unmount the filesystem and run fsck to repair it:
    sudo umount /dev/sda1
    sudo fsck /dev/sda1
  • Restore from Backup: If corruption is severe, restore the affected files from a backup.

Inaccessible Partitions

Symptoms:

  • Partitions not mounting at boot or manual mount attempts fail.

Troubleshooting Steps:

  • Check Partition Table: Use fdisk -l or parted to verify the partition table:
    sudo fdisk -l
  • Manual Mount: Try mounting the partition manually:
    sudo mount /dev/sda1 /mnt
  • Update fstab: Ensure the partition is correctly listed in /etc/fstab for automatic mounting at boot.

LVM Issues

Symptoms:

  • Logical Volumes not available or showing incorrect sizes.
  • Problems resizing volumes or extending Volume Groups.

Troubleshooting Steps:

  • Check LVM Status: Use lvdisplay, vgdisplay, and pvdisplay to check the status of LVM components.
  • Resize Volumes: Ensure you resize the filesystem after resizing the Logical Volume:
    sudo lvextend -L +5G /dev/vgname/lvname
    sudo resize2fs /dev/vgname/lvname

Advanced Troubleshooting Tools

dmesg

  • Use dmesg to check kernel messages for disk errors or hardware issues.

lsof

  • Use lsof to list open files and identify processes using a particular disk or filesystem.

mount

  • The mount command can be used to manually mount or remount filesystems and troubleshoot mounting issues.