I regularly mount the partitions inside an image file as loop devices:
sudo kpartx -a test.img
That creates loop devices such as
When I'm done, I get rid of them with
sudo kpartx -d test.img
and usually the loop devices go away. But sometimes, they don't, and I don't know why. If I then do a:
sudo losetup -d /dev/mapper/loop0p1
losetup seems happy enough, except that the device stays. How do I get rid of them without rebooting?