The Outage Nobody Saw Coming
Disk full. Two words that have caused more production outages than most people realize. Applications crash, databases corrupt, logs stop writing—all because nobody was watching disk usage.
Disk management isn’t glamorous, but it’s essential. Knowing how to check space, find what’s consuming it, and manage storage is fundamental sysadmin work. The difference between reactive (“it’s full, fix it now!”) and proactive (“we’ll hit 80% in two weeks, let’s plan”) is career-defining.
Checking Disk Space
df – Filesystem Space
# Human-readable output
df -h
# Show filesystem type
df -hT
# Specific filesystem
df -h /
# Only local filesystems (exclude network)
df -hl
# Inode usage (small files can exhaust inodes)
df -i
Understanding df output:
| Column | Meaning |
|---|---|
| Filesystem | Device or mount source |
| Size | Total capacity |
| Used | Space consumed |
| Avail | Space remaining |
| Use% | Percentage full |
| Mounted on | Where it’s accessible |
Warning sign: Anything over 80% needs attention. Over 90% is urgent.
Inode Exhaustion
Sometimes you have space but can’t create files—inodes are exhausted.
# Check inode usage
df -i
# Find directories with many files
find / -xdev -printf '%h\n' | sort | uniq -c | sort -rn | head -20
Common causes: mail queues, session files, log rotation gone wrong.
Finding What’s Using Space
du – Directory Usage
# Current directory size
du -sh .
# Subdirectory sizes
du -sh */
# All items sorted by size
du -sh * | sort -rh
# Top 10 largest directories
du -sh /* 2>/dev/null | sort -rh | head -10
# Specific directory depth
du -h --max-depth=2 /var
# Exclude pattern
du -sh --exclude="*.log" /var
Finding Large Files
# Files over 100MB
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null
# Top 20 largest files
find / -type f -exec du -h {} \; 2>/dev/null | sort -rh | head -20
# Large files modified recently (might be growing)
find / -type f -size +100M -mtime -7 2>/dev/null
ncdu – Interactive Disk Usage
# Install
sudo apt install ncdu
# Analyze directory interactively
ncdu /var
# Navigate with arrows, delete with 'd', quit with 'q'
ncdu is the fastest way to drill down into what’s consuming space.
Viewing Storage Devices
lsblk – Block Devices
# Simple view
lsblk
# With filesystem info
lsblk -f
# With sizes
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
# All details
lsblk -a
lsblk shows the relationship between physical disks, partitions, and mounts.
fdisk – Partition Info
# List all partitions
sudo fdisk -l
# Specific disk
sudo fdisk -l /dev/sda
blkid – Filesystem IDs
# Show UUIDs and filesystem types
sudo blkid
# Specific device
sudo blkid /dev/sda1
Mounting and Unmounting
Temporary Mounts
# Mount a device
sudo mount /dev/sdb1 /mnt/data
# Mount with options
sudo mount -o ro /dev/sdb1 /mnt/data # Read-only
# Mount ISO file
sudo mount -o loop image.iso /mnt/iso
# Unmount
sudo umount /mnt/data
# Or by device
sudo umount /dev/sdb1
Permanent Mounts (/etc/fstab)
# View current fstab
cat /etc/fstab
# Format:
# device mount-point fstype options dump pass
# /dev/sdb1 /data ext4 defaults 0 2
# Using UUID (preferred - survives device reordering)
# UUID=xxxxx /data ext4 defaults 0 2
# Get UUID
sudo blkid /dev/sdb1
# Test fstab entry without rebooting
sudo mount -a
Critical: Test with mount -a before rebooting. A broken fstab can prevent boot.
Common Mount Options
| Option | Effect |
|---|---|
defaults |
Standard options (rw, suid, dev, exec, auto, nouser, async) |
ro |
Read-only |
rw |
Read-write |
noexec |
Can’t execute programs from this mount |
nosuid |
Ignore setuid bits |
noatime |
Don’t update access times (performance) |
nofail |
Continue boot if mount fails |
Managing Space
Quick Wins
# Clean apt cache
sudo apt clean
# Remove old kernels (careful!)
sudo apt autoremove
# Clear systemd journal
sudo journalctl --vacuum-time=7d
# Find and remove old log files
find /var/log -name "*.gz" -mtime +30 -delete
# Truncate a large log (keeps file, empties content)
sudo truncate -s 0 /var/log/large.log
Identifying Problems
# What's in /var (common culprit)
du -sh /var/*
# Log directory breakdown
du -sh /var/log/*
# Docker (often a surprise)
docker system df
docker system prune -a # Clean unused
LVM Basics
Logical Volume Management allows flexible disk management.
# View physical volumes
sudo pvs
# View volume groups
sudo vgs
# View logical volumes
sudo lvs
# Detailed info
sudo pvdisplay
sudo vgdisplay
sudo lvdisplay
Extending LVM
# Extend logical volume
sudo lvextend -L +10G /dev/vg0/lv_data
# Extend to use all available space
sudo lvextend -l +100%FREE /dev/vg0/lv_data
# Resize filesystem (ext4)
sudo resize2fs /dev/vg0/lv_data
# For xfs
sudo xfs_growfs /dev/vg0/lv_data
Real Scenarios
Scenario 1: Disk Full Alert
# Check overall usage
df -h
# Find the problem directory
du -sh /* 2>/dev/null | sort -rh | head
# Drill down
du -sh /var/* | sort -rh | head
# Find large files
find /var -type f -size +100M -exec ls -lh {} \;
# Quick cleanup
sudo journalctl --vacuum-time=3d
sudo apt clean
Scenario 2: Add New Storage
# See new disk
lsblk
# Create partition
sudo fdisk /dev/sdb
# n for new, p for primary, accept defaults, w to write
# Create filesystem
sudo mkfs.ext4 /dev/sdb1
# Create mount point
sudo mkdir /data
# Mount
sudo mount /dev/sdb1 /data
# Get UUID
sudo blkid /dev/sdb1
# Add to fstab
echo "UUID=xxx /data ext4 defaults 0 2" | sudo tee -a /etc/fstab
# Test
sudo umount /data
sudo mount -a
df -h /data
Scenario 3: Database Needs More Space
# Check current usage
df -h /var/lib/postgresql
# If LVM, extend the volume
sudo lvextend -L +20G /dev/vg0/lv_postgres
sudo resize2fs /dev/vg0/lv_postgres
# Verify
df -h /var/lib/postgresql
Monitoring and Prevention
# Simple alert script
#!/bin/bash
THRESHOLD=80
USAGE=$(df -h / | awk 'NR==2 {print $5}' | tr -d '%')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
echo "Disk usage is ${USAGE}%" | mail -s "Disk Alert" [email protected]
fi
# Add to cron
crontab -e
# 0 * * * * /home/admin/disk-check.sh
Interview Questions
- “The disk is 100% full. How do you diagnose and fix it?”
“First,
df -hto confirm which filesystem is full. Thendu -sh /*and drill down to find what’s consuming space. Usually it’s /var—logs, cache, or databases. Quick fixes: clear apt cache, vacuum journals, truncate large logs. Long-term: identify root cause and implement monitoring.” - “How do you add a new disk to a server?”
“Identify the disk with
lsblk, partition it withfdisk, create a filesystem withmkfs.ext4, create a mount point, mount it, then add to/etc/fstabusing UUID for persistence. Always test withmount -abefore relying on it.” - “What’s the difference between df and du?”
“
dfshows filesystem-level usage—how much space is used on each mounted filesystem.dushows directory-level usage—how much space individual directories and files consume. A file can be deleted but still held open by a process, showing space in df but not in du.”
Quick Reference
# Check space
df -h # Filesystem usage
df -i # Inode usage
# Find what's using space
du -sh /path # Directory size
du -sh * | sort -rh # Sorted sizes
ncdu /path # Interactive browser
# Find large files
find / -size +100M # Files over 100MB
# View devices
lsblk # Block devices
lsblk -f # With filesystem info
sudo blkid # UUIDs and types
# Mounting
sudo mount /dev/sdb1 /mnt # Temporary mount
sudo umount /mnt # Unmount
cat /etc/fstab # Permanent mounts
sudo mount -a # Mount all fstab entries
# Cleanup
sudo apt clean # Clear apt cache
sudo journalctl --vacuum-time=7d # Clear old journals
docker system prune # Clean Docker
The Career Translation
| Skill | Demonstrates | Role Level |
|---|---|---|
| Check disk space | Basic awareness | Helpdesk (£25-30k) |
| Find and fix full disks | Troubleshooting | Junior Sysadmin (£32-40k) |
| Manage mounts, LVM | Storage management | Mid-level (£40-50k) |
| Capacity planning, automation | Infrastructure thinking | Senior (£50k+) |
Next Steps
- LVM deep dive – Snapshots, thin provisioning
- ZFS/Btrfs – Modern filesystems with advanced features
- RAID – Redundancy and performance
- Storage monitoring – Prometheus, Grafana dashboards
Disk space problems are preventable. Good administrators monitor usage, plan capacity, and never get surprised by a full disk.
This concludes the Linux Fundamentals series. You now have a solid foundation in the commands and concepts that matter for infrastructure roles. Build on this with hands-on practice in your homelab—that’s where theory becomes career-ready skill.
Linux Fundamentals Series – Part 12 of 12
Previous: Text Processing: grep, sed, awk
View the full series – You’ve completed the series!

