Linux Disk Usage Explained Simply
One of the fastest ways to break a Linux system is this:
β Running out of disk space
When disk fills up:
apps crash logs stop writing deployments fail servers become unstable
π Thatβs why disk usage monitoring is critical in Linux and DevOps.
Letβs simplify it.
Disk Usage Basics (You Must Know This First)
What is Storage in Linux?
Storage is where Linux keeps:
- Files
- Applications
- Logs
- Databases
Examples:
- HDD
- SSD
- Cloud volumes (AWS, etc.)
If storage becomes full:
- Applications may crash
- Logs may stop writing
- System can become unstable
Linux uses storage through filesystems.
What is a Filesystem?
A filesystem is how Linux organizes storage.
Examples:
- ext4
- xfs
Linux mounts filesystems into directories like:
//home/var
File Size vs Disk Usage
- File size β Size of a single file
- Disk usage β Total space consumed by files and directories
Commands:
ls -lhβ Check file sizedu -shβ Check directory disk usage
What is Mounting?
Linux attaches storage devices to directories using a process called mounting.
Examples:
/β Main filesystem/homeβ User files/varβ Logs and application data
This is why df -h shows a Mounted on column.
1. Check Overall Disk Usage with df
df -h
Example Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 32G 18G 65% /
Meaning:
- Size β Total disk
- Used β used space
- Avail β Free space
- Use% β usage percentage
- Mounted on β where disk is attached
π First command to run when server behaves weirdly.
2. Check Folder and Directory Size with du
du -sh /home
du -sh /var/log
-sβ Summary (total size only)-hβ Human readable (KB, MB, GB)
π Used to find which folder is consuming space
3. Find Large Files in the System
find / -type f -size +100M 2>/dev/null
find / -type f -size +500M 2>/dev/null
β οΈ Can take time on large systems.
π Common use:
large logs backups unused media files
4. Find Biggest Directories (Very Important)
du -sh /* 2>/dev/null | sort -hr | head -n 10
π Shows top 10 largest directories
This is one of the most used DevOps troubleshooting commands.
5. Disk Full but Space Looks Free? (INODES)
df -i
What are inodes?
Inodes store metadata about files.
π Problem:
Disk shows free space But system says:
No space left on device
π Cause: Too many small files.
This is very common in:
- log systems
- microservices
- temp file-heavy apps
6. Deleted Files Still Using Space
lsof | grep deleted
π Happens when:
file is deleted but process is still using it
So disk space is NOT freed.
Bonus Tool: ncdu (Best for Beginners)
sudo apt install ncdu # Ubuntu/Debian
sudo dnf install ncdu # Fedora/RHEL
Run:
ncdu /
Why itβs powerful:
- interactive UI
- easy navigation
- visual disk breakdown
π Widely used by DevOps engineers for fast debugging
Basic Cleanup Tips
- Remove old logs carefully
- delete unused backups
- Clear package cache when needed
- Always verify before using rm -rf
β οΈ Common Beginner mistakes
- Disk shows free space but system says full β Check inodes (
df -i) - using rm -rf without checking size
- ignoring /var/log growth
Simple Mental Model
Think of disk like a room:
/home β personal items /var β messy logs piling up /usr β installed apps /tmp β temporary trash
π When room is full β system slows down
Summary
In this guide you learned:
df -hβ Overall disk usagedu -shβ Folder sizefindβ Locate large filesdf -iβ Check inodeslsof | grep deletedβ Find deleted open filesncduβ Interactive disk usage analyzer
Why This Matters
Disk issues are one of the most common production failures in:
DevOps systems cloud servers databases CI/CD pipelines
π Knowing this = real-world Linux skill
Next Post: Linux Networking Basics for Beginners,(ping, curl, ip, ss, etc.)
Question for You
Have you ever faced a server where disk was full but you couldnβt find why?
Thatβs usually inode or deleted file issues β Iβll show debugging tricks in Part 7.
Discussion in the ATmosphere