KVM : Logical volume xxxx is used by another device.
If you facing an issue when try to remove KVM img, below is the workaround :
[root@ssdvps06 ~]# lvscan |grep kvm530 ACTIVE '/dev/ssdvps06data/kvm530_img' [120.00 GiB] inherit
[root@ssdvps06 ~]# lvchange -an /dev/ssdvps06data/kvm530_img Logical volume ssdvps06data/kvm530_img is used by another device.
Find Out device-mapper’s Mapping
Well, the culprit in this case seemed to be device-mapper creating a mapping which counted as ‘in-use’. Check for the mapping via:
[root@ssdvps06 ~]# dmsetup info -c | grep kvm530 ssdvps06data-kvm530_img1 253 72 L--w 0 1 0 part1-LVM-mCrb7RNRzIsZ2V3WP0kSJwoPwchSokeqcpJp3DxPS22509KmbuuIuq0v3ZUAfLDV ssdvps06data-kvm530_img 253 51 L--w 1 1 0 LVM-mCrb7RNRzIsZ2V3WP0kSJwoPwchSokeqcpJp3DxPS22509KmbuuIuq0v3ZUAfLDV
Find Out Mapped Device
Then use that to find out what is holding it:
[root@ssdvps06 ~]# ls -la /sys/dev/block/253\:51/holders total 0 drwxr-xr-x 2 root root 0 Sep 23 10:15 . drwxr-xr-x 8 root root 0 Sep 23 10:15 .. lrwxrwxrwx 1 root root 0 Oct 9 16:50 dm-72 -> ../../dm-72
Remove Device (via dmsetup remove)
Then do a dmsetup remove on that device-mapper device:
[root@ssdvps06 ~]# dmsetup remove /dev/dm-72
[root@ssdvps06 ~]# lvremove /dev/ssdvps06data/kvm530_img Do you really want to remove active logical volume ssdvps06data/kvm530_img? [y/n]: y Logical volume "kvm530_img" successfully removed
