Can't unmount a loop backed file but there's no open files?

Solution 1:

I believe this is what fuser is for. Specifically, fuser -km /path/to/mount/point - note that the -k flag kills processes with files open on this filesystem. You can omit this flag to see a list first.

Solution 2:

In your question, you wrote grep pathofimagefile. Have you tried with grep pathofmountpoint?

Also verify that no process running on your machine has your mount point (or a subdirectory of it) set as its current working directory.

sudo ls -l /proc/*/cwd | grep pathofmountpoint will give you those process numbers.

Solution 3:

Wow, this is really old, but to benefit those finding this in the future, here is what I found -- I had nested mounts. That is, I mounted a root filesystem image with a loopback device on /mnt. Under that mount point I had then mounted proc and sysfs filesystems mounted under /mnt/proc and /mnt/sys. Later I had forgotten about the proc and sysfs filesystems when trying to umount the filesystem image.

# mount -o loop rootfs_disk.img /mnt
# mount proc /mnt/proc -t proc
# mount sysfs /mnt/sys -t sysfs
# # ... ages pass
# umount rootfs_disk.img
umount: /mnt: device is busy.
# umount /mnt
umount: /mnt: device is busy.

-- Noah Spurrier