BiX BiX - 8 months ago 100
Linux Question

Cannot delete device /dev/loop0

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

losetup -a
/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
. Are there any ways to get rid of the loop device?


are you sure, that the device isn't busy? Have you ever tried fuser to determine an possible PID? Precautionary get all possible informations:

fuser -c /dev/loop0
fuser -d /dev/loop0
fuser -f /dev/loop0

try to stop the process, which could use /dev/loop0 if necessary use kill -9 or: try fuser -k to send the kill signal -> look at man fuser