Unmounting stuck Linux filesystems…

It’s not uncommon, especially when using chroot() gaols, to find that “modern” systemd-equipped Linux distributions seem to get a bit possessive when it comes to mounting filesystems such as devtmpfs on /dev or tmpfs on /run, and when you want to remove the gaol this filesystems can show as still in use – although lsof/fuser -m output suggests that everything using root-dev and nothing respectively are actually using these mount-points.

Generally, a umount -f dev fails with the same error – indeed, I can’t actually think of an occasion where umount -f succeeded when umount alone failed.

The fix for this is to use the -l lazy-unmount option which removes the mount-point immediately, but defers cleaning-up of any affected open file-descriptors to occur at an unspecified future point, as convenient.

Therefore, to remove stuck mount-points the quickest and easiest solution is:

umount -lf /usr/src/chroot/dev

… referring, of course, to whichever mount-point is causing a problem.