Linux Disk and Storage Management Commands

Linux provides powerful command-line tools for checking disk usage, inspecting storage devices, managing filesystems, and troubleshooting storage problems. These commands are useful for both desktop users and system administrators.

Why Learn Linux Storage Commands?

Disk space and storage problems can cause applications to fail, logs to stop writing, and systems to become unstable. Linux storage commands help identify available space, locate large files, and understand how disks and filesystems are being used.

TEXT
Inspect Disk → Check Space → Find Large Files → Check Filesystem → Mount Storage → Monitor Usage

Checking Disk Space with df

The df command displays available and used disk space for mounted filesystems.

BASH
df -h
df -Th

Checking Directory Usage with du

The du command shows how much disk space files and directories are using. It is useful for finding directories that consume large amounts of storage.

BASH
du -sh /var/log
du -sh *
du -h --max-depth=1

Listing Storage Devices with lsblk

The lsblk command displays information about block devices such as disks, partitions, and logical volumes.

BASH
lsblk
lsblk -f

Checking Disk Information with fdisk

The fdisk command can display and manage disk partition tables. Use partitioning commands carefully because incorrect changes can result in data loss.

BASH
sudo fdisk -l

Understanding Filesystems

A filesystem defines how data is organized and stored on a storage device. Linux supports filesystems such as ext4, XFS, Btrfs, and others.

FilesystemCommon UseGeneral Characteristic
ext4General Linux systemsMature and widely supported
XFSServers and large filesystemsDesigned for scalability
BtrfsAdvanced storage managementSupports snapshots and other features

Mounting a Filesystem

The mount command attaches a filesystem to a directory in the Linux filesystem hierarchy.

BASH
sudo mount /dev/sdb1 /mnt/data
mount | grep /mnt/data

Unmounting Storage

The umount command safely detaches a mounted filesystem. The filesystem should not be actively used when unmounting it.

BASH
sudo umount /mnt/data

Checking Inodes

A filesystem can run out of inodes even when free disk space remains. The df -i command displays inode usage.

BASH
df -i

Linux Storage Command Table

CommandPurposeExample
dfCheck filesystem spacedf -h
duCheck directory usagedu -sh /var/log
lsblkList block deviceslsblk -f
fdiskInspect partitionssudo fdisk -l
mountMount a filesystemsudo mount /dev/sdb1 /mnt/data
umountUnmount a filesystemsudo umount /mnt/data

Example Storage Troubleshooting Scenario

TEXT
Application Fails → Check df -h → Find Full Filesystem → Use du → Locate Large Data → Clean or Expand Storage

Common Linux Storage Problems

  • Filesystem running out of space
  • Too many files consuming inodes
  • Large log files
  • Incorrect mount configuration
  • Unmounted storage devices
  • Filesystem errors

Common Mistakes to Avoid

  • Deleting files without checking their purpose
  • Running partitioning commands without backups
  • Unmounting an active filesystem
  • Ignoring inode usage
  • Editing filesystem configuration incorrectly

Advanced Linux Storage Concepts

  • Logical Volume Management
  • RAID
  • Filesystem snapshots
  • Disk quotas
  • Storage encryption
  • Network-attached storage
  • Persistent storage for containers

Practice Exercises

  • Check available disk space
  • Find the largest directories
  • List all block devices
  • Identify mounted filesystems
  • Check inode usage
  • Mount a test filesystem
  • Safely unmount the filesystem

Conclusion

Linux disk and storage commands make it easier to understand how storage is being used and to troubleshoot common filesystem problems. Commands such as df, du, lsblk, mount, and umount are essential tools for Linux administration.

Note: Note: Always verify storage devices and mount points before making changes, and maintain backups before performing partition or filesystem operations.