Linux Disk Management: fdisk, lsblk, df, and du Explained

Disk management is a critical sysadmin skill. Running out of disk space can crash services, corrupt databases, and cause data loss. Knowing how to inspect disks, manage partitions, create filesystems, and monitor usage is non-negotiable. This guide covers the essential disk management tools on Linux.

Listing Disks and Partitions

lsblk                     # List block devices in tree format
lsblk -f                  # Include filesystem type and UUID
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE

fdisk -l                  # Detailed partition table (run as root)
fdisk -l /dev/sda         # Specific disk only

parted -l                 # Alternative to fdisk, supports GPT

Output of lsblk shows device names (sda, sdb, nvme0n1), sizes, and mount points. Partitions appear as sda1, sda2, etc.

Disk Usage: df and du

df — Disk Free (filesystem level)

df -h                     # Human-readable sizes
df -hT                    # Include filesystem type
df -h /var                # Usage for specific mount point
df -i                     # Inode usage (important — can fill up separately)

du — Disk Usage (directory level)

du -sh /var/log           # Total size of directory
du -sh /var/log/*         # Size of each item
du -h --max-depth=1 /     # Top-level directories (great for finding hogs)
du -sh * | sort -rh | head -10   # Top 10 largest items in current dir

When a disk fills up, run du -h --max-depth=1 / then drill down into the largest directories to find what is consuming space.

Partitioning with fdisk

Assume you have added a new disk at /dev/sdb:

sudo fdisk /dev/sdb

Inside fdisk:

m       # Help/menu
n       # New partition
p       # Primary partition
1       # Partition number 1
        # Accept defaults for start/end (use full disk)
w       # Write changes and exit

Creating Filesystems

sudo mkfs.ext4 /dev/sdb1            # Format as ext4
sudo mkfs.xfs /dev/sdb1             # Format as XFS (common on RHEL)
sudo mkfs.vfat /dev/sdb1            # Format as FAT32 (USB drives)

# Check filesystem type
blkid /dev/sdb1
file -s /dev/sdb1

Mounting Filesystems

sudo mkdir /mnt/data
sudo mount /dev/sdb1 /mnt/data         # Temporary mount
mount | grep sdb1                      # Verify mount
sudo umount /mnt/data                  # Unmount

Permanent Mounts via /etc/fstab

First get the UUID (more reliable than device names, which can change):

sudo blkid /dev/sdb1
# /dev/sdb1: UUID="a1b2c3d4-..." TYPE="ext4"

Add to /etc/fstab:

UUID=a1b2c3d4-xxxx  /mnt/data  ext4  defaults  0  2

Test without rebooting:

sudo mount -a         # Mount all entries in fstab
df -h /mnt/data       # Verify

Logical Volume Management (LVM) Basics

LVM allows flexible resizing of volumes without repartitioning:

pvdisplay                # Physical volumes
vgdisplay                # Volume groups
lvdisplay                # Logical volumes

# Extend a logical volume
sudo lvextend -L +10G /dev/vgdata/lvdata
sudo resize2fs /dev/vgdata/lvdata     # Resize ext4 filesystem
sudo xfs_growfs /mnt/data             # Resize XFS filesystem

Checking Filesystem Health

sudo fsck /dev/sdb1           # Check and repair (must be unmounted)
sudo e2fsck -f /dev/sdb1      # Force check on ext4
sudo dmesg | grep -i error    # Check for disk errors in kernel log
sudo smartctl -a /dev/sda     # SMART disk health (install smartmontools)

Finding What Is Using a Mount Point

lsof +D /mnt/data             # Processes with files open in /mnt/data
fuser -m /mnt/data            # PIDs using the mount point

Summary

Disk management on Linux requires understanding the full stack: physical disks, partitions, filesystems, and mount points. Use lsblk and fdisk to inspect hardware, df and du to monitor usage, and /etc/fstab for persistent mounts. When space runs low, du -h --max-depth=1 is your fastest way to find the culprit directory.