Linux – umount Device or resource busy; already tried: mount, lsof, fuser, exportfs, ps axf

linuxmountunmount

As part of an automated VM creation system a block device is mounted to a temporary folder ( /tmp/whatever ) . Various scripts install and configure the VM prior to it's first run.

Recently something changed, the temporary mount is busy and refuses to umount. In trying to determine what might still be keeping a file open I've checked:

Tests run as root

  • mount
  • lsof | grep /tmp/
  • fuser -m /tmp/…
  • exportfs -rv
  • Restarting the daemon which runs the creation scripts anyway…
  • ps axf
  • dmsetup table
  • losetup -a
  • fuser -vm /tmp/tmp.random-chars/ (yields two lines)
    • USER PID ACCESS COMMAND
    • /tmp/tmp.random-chars: root kernel mount /tmp/tmp.random-chars

None of the above tests have results that point to filesystem use, however umount -f still complains "Device or resource busy" / "device is busy".

What other tests should I try so that I can get to the true root cause and thus hopefully fix the stuck mount without reboot on a system I can't presently restart for a while as well as prevent this from reoccurring?

It is also /doubtful/ (but I don't know how to check) that kernel modules from the temporary mount are loaded, as the temporary mount has a different version of Linux installed than the host is running.

edits

  • From various search results it appears that /modules/ are simply read in to memory. I am unaware of if the kernel could have open files and of how to access any such list.
  • Added the dmsetup / losetup to the lists of "tests that don't show issues"
  • fuser -vm as suggested in freenode ##linux

Best Answer

If it's part of a build process, I'm assuming you'll need to reboot at some point anyway. Try inserting a "lazy" unmount into the process. Use umount -l /tmp and see if that helps you get past this barrier in the process.