Stop mounting drives to empty directories by accident
Disk & Filesystem Management (Du/Df/Lsblk/Fstrim)
Stop mounting drives to empty directories by accident
🧩 The Challenge
You ever mount a new disk, run your app for three days, and then realize you were actually dumping gigabytes of data into the local folder on your root partition instead of the external drive? I have, and cleaning up that mess after a production crash is a special kind of hell.
💡 The Fix
Use the mount command with the -n flag or just double check your mount point contents while the filesystem is actually unmounted. It stops you from writing to a folder that is secretly hiding your mount.
lsblk -M && mount | grep /mnt/your_mount_point && ls -la /mnt/your_mount_point
⚙️ Why It Works
Checking the directory contents while the drive is unmounted reveals if you left junk behind in the underlying folder. Running the mount command simultaneously ensures the filesystem is currently attached exactly where you think it is.
🚀 Pro-Tip: Always keep a hidden “marker” file like .is_mounted in the root of your data drives so you can immediately tell if you’re looking at the empty mount point or the real disk.
Linux Tips & Tricks | © ngelinux.com | 11/2/2026
