losetup -d giving : device busy

7,890

See if it's used by device-mapper still (dmsetup table) and if so, flush the appropriate map (dmsetup clear mapname).

Share:
7,890

Related videos on Youtube

Lucas Kauffman
Author by

Lucas Kauffman

I'm a Belgian security consultant living in Singapore, I'm here to learn and help others out. Opinions are my own. Advice provided with no warranty. Find me on http://cloud101.eu Sometimes you can have a craving only hands can satisfy!

Updated on September 18, 2022

Comments

  • Lucas Kauffman
    Lucas Kauffman almost 2 years

    I am mounting a KVM disk (LVM) following these commands :

    # losetup /dev/loop0 foo.img
    # kpartx -av /dev/loop0
    # mount /dev/mapper/loop0p1 /mnt
    
    # unmount /mnt
    # kpartx -dv /dev/loop0
    # losetup -d /dev/loop0
    

    Problem is when I want to do kpartx -d /dev/loop0 I get :

        device-mapper: remove ioctl failed: Device or resource busy
        device-mapper: remove ioctl failed: Device or resource busy
    

    I tried looking for it with lsof, but I can't find anything, anyone any idea how I can force this or what I am doing wrong?

  • MathematicalOrchid
    MathematicalOrchid almost 11 years
    Oh thank Christ! This has been driving me insane...