Site icon New Generation Enterprise Linux

Stop chasing sparse files that lie to your monitoring scripts

Disk & Filesystem Management (Du/Df/Lsblk/Fstrim)

Stop chasing sparse files that lie to your monitoring scripts

🧩 The Challenge

Ever notice your monitoring scripts reporting that a backup folder is massive, but when you look at the raw disk space it fits just fine? I spent an entire afternoon moving data between nodes thinking I had a capacity problem before realizing I was staring at a sparse file mess.

💡 The Fix

Use the apparent-size flag to see what the OS thinks is there, versus the actual disk space being consumed. It saves you from deleting perfectly good data because of a measurement confusion.

du -sh --apparent-size /var/lib/my-database

⚙️ Why It Works

Sparse files allocate blocks only when they are actually written to, so the file system reports a massive size that isn’t really taking up physical storage yet. Getting the apparent size confirms how much space the file would take if it were fully hydrated.

🚀 Pro-Tip: Always double check with du -S to make sure you aren’t accidentally counting the size of subdirectories twice.

Linux Tips & Tricks | © ngelinux.com | 8/26/2026

0 0 votes
Article Rating
Exit mobile version