Can’t remove open logical volume

While trying to clear up an unused Logical Volume i came across this error:

#lvremove /dev/datavol/testbuild
Can't remove open logical volume "testbuild"

After a little investigation i could see the Open status for this LV was set to 2:

#dmsetup info -c  /dev/datavol/testbuild
Name              Maj Min Stat Open Targ Event  UUID                                                                
datavol-testbuild 252   2 L--w    2    1      0 LVM-6d36fbop48S1KvuFtoUnn8vFJyoRSKANfX5ViDNAl3h2d3WiAIcou4oprHDRJpvB

I had 2 patitions setup in this LV so i removed them using the commands below

#dmsetup remove /dev/mapper/datavol-testbuild2

#dmsetup remove /dev/mapper/datavol-testbuild1

The open status was now 0 so i could remove the LV.

  --- Logical volume ---
  LV Name                /dev/datavol/testbuild
  VG Name                datavol
  LV UUID                fX5ViD-NAl3-h2d3-WiAI-cou4-oprH-DRJpvB
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                40.00 GiB
  Current LE             10240
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:2

Remove the LV:

# lvremove /dev/datavol/testbuild
Do you really want to remove active logical volume testbuild? [y/n]: y
  Logical volume "testbuild" successfully removed

Leave a Reply

Your email address will not be published. Required fields are marked *