While we removing logical volumes, some times we get this error. When the lvs are in open status.
[root@manny ~]# lvremove /dev/mapper/test_vg-testlv
Can't remove open logical volume "testlv"
Can't remove open logical volume "testlv"
Device mapper maintains entry for logical drives, so first we need to delete it from there. Then it can't restrict us while removing logical volumes which are in open status.
[root@manny ~]# dmsetup info -c /dev/mapper/testvg-testlv
Name Maj Min Stat Open Targ Event UUID
testvg-testlv 253 1 L--w 1 1 0 LVM-CqaHxtgmt8hIOru9k6tYjYJU9oHyuvrtKiOnlIVuDElaLh4yFwJd9mCrpB0cJ
Name Maj Min Stat Open Targ Event UUID
testvg-testlv 253 1 L--w 1 1 0 LVM-CqaHxtgmt8hIOru9k6tYjYJU9oHyuvrtKiOnlIVuDElaLh4yFwJd9mCrpB0cJ
From above table you can see Open = 1 which means the logical volume testlv is open status, so we need to delete entry for this logical volume from dmsetup table then only we can delete any logical volume with open status. let's do it
[root@manny ~]# dmsetup remove /dev/mapper/testvg-testlv
[root@manny ~]# lvremove /dev/mapper/testvg-testlv
[root@manny ~]# Logical volume “lvswap2″ successfully removed
testlv is removed successfully, hope works for you also and enjoy.
1 Comments
If the logical volume has partitions inside you may need to remove their corresponding entries from device mapper before beign able to remove the logical volume:
ReplyDeletedmsetup remove /dev/mapper/testvg-testlvp1
dmsetup remove /dev/mapper/testvg-testlvp2
dmsetup remove /dev/mapper/testvg-testlvp3
Once all partitions are deleted, you may remove the whole logical volume:
dmsetup remove /dev/mapper/testvg-testlv
lvremove -f /dev/mapper/testvg-testlv
Good luck,
Miguel Castellanos