Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

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

share|improve this answer
Oh thank Christ! This has been driving me insane... – MathematicalOrchid Sep 3 '13 at 10:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.