Linux – How to really force unmount a filesystem (without manual investigation why is it busy)

linuxumount

How to unmount a filesystem in Linux without investigating why is it busy?

I want to do it in one command. It should handle applications using that filesystem, submounts, containers (lxc-execute -n qqq <command>) and all other things.

Just "unmount. No objections!". Special kernel patches or configuration is allowed.

Filesystem should be really unmounted, so umount -l is certainly not an option. For example, for cryptsetup remove (BTW how to forcibly cryptsetup remove? Update: cryptsetup luksSuspend, but you won't be able to cryptsetup luksResume if it is not LUKS).

How to make all filehandles on that filesystem invalid?

The only reliable way I know is mounting the filesystem through the FUSE (there is usually no problem to unmount FUSE thing because of I can just kill it's process).

P.S. Already know mount fuser, lsof | grep, cat /proc/*/mounts | grep and obsolete non-working "badfs patch".

Best Answer

umount --force or umount -f (equivalent)

If that fails, then use:

umount --lazy or umount --l (equivalent)

The "lazy" option will "detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)" It might cause instability, but it will get the thing unmounted. Any programs using the drive may crash.

Related Question