Container Basics On Linux (Namespaces/Cgroups)
Stop mount namespaces from trapping your manual filesystem changes
đź§© The Challenge
Trying to unmount a drive inside a containerized app only to realize the host is still holding onto a “ghost” mount that won’t go away is infuriating. I spent half a day once trying to figure out why my device was still busy before realizing the namespaces were hiding the truth from my shell.
đź’ˇ The Fix
You have to switch your shell into the target process’s mount namespace to actually see and interact with those specific mounts. It saves you from rebooting the container or, worse, the whole host just to clear a stale lock.
nsenter -t <pid> -m /bin/bash
⚙️ Why It Works
By hitting the -m flag, you are telling the kernel to drop your current process into the mount namespace of the specified PID, which lets you see the filesystem exactly as that container sees it.
🚀 Pro-Tip: Run mount | grep <path> immediately after entering the namespace to verify you are actually looking at the right environment.
Linux Tips & Tricks | © ngelinux.com | 8/2/2026
