brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: umount -l detaches a hung network share, but read the fine print

Linux
~/tips/tip-disk-umount-lazy

sudo umount -l /mnt/nas

Frees the mount point of a hung network share so the machine can shut down cleanly.

The NAS went offline, and now umount on its share just hangs or says the target is busy. Shutdown can get stuck on the same thing. That’s the case the umount man page names as the recommended use for a lazy unmount.

sudo umount -l /mnt/nas

-l (--lazy) detaches the filesystem from the directory tree right away, so /mnt/nas is free again for new work. The kernel cleans up the remaining references to the old mount once nothing is using it anymore. Programs that already had a file open keep it open. New ones just see an empty mount point.

Now the fine print. A lazy unmount doesn’t make the filesystem go away while it’s still in use: it only hides it. On a local disk that means data can still be written to it after the mount point looks empty, so this is never a way to free up a USB disk before you pull it out. For a busy local disk I’d find the program that holds it and stop that, then do a normal umount.

The man page also says that after a lazy unmount of a network filesystem, or a local one with submounts, you should expect to reboot soon. It also warns that remounting the same share won’t be possible. So I see umount -l as a way to get a stuck machine to a clean reboot, not as a fix. If the share keeps hanging, the real fix is on the mount side, like an automount with a timeout.

Further reading: umount(8) manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link