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 size -
du -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 usage -
du -sh→ Folder size -
find→ Locate large files -
df -i→ Check inodes -
lsof | grep deleted→ Find deleted open files -
ncdu→ 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.
Top comments (0)