Cannot delete device /dev/loop0

BiX picture BiX · May 4, 2011 · Viewed 100.4k times · Source

I unsafely removed a USB device that was attached to loop0 with losetup and could not delete nor detach loop0 afterwards.

losetup -a shows /dev/loop0: [0005]:145606719 (/dev/sdb1)

When I remount the device to /dev/sdb1, umount it and try losetup -d /dev/loop0, I will still get the same error loop: can't delete device /dev/loop0: Device or resource busy. Is there a way to get rid of the loop device?

Answer

Aaron Flin picture Aaron Flin · Jun 21, 2012

You may have to also use dmsetup to remove the device mapping. Easiest way, if it doesn't interfere with any other mappings is to use a dmsetup remove_all.