Lvm – “Logical volume in use” — cannot remove logical volume

disk-volumelsoflvmxen

On a Xen 4.8 hypervisor, running on Debian Stretch, I am trying to remove the logical volume of a domU that is no longer used.

I stopped the domU and successfully removed the logical volume for the swap file.

However, when trying to remove the logical volume of the main disk, I get the error:

Logical volume xen3-vg/vmXX-disk in use.

As I need the disk space on the hypervisor for other domUs, I successfully resized the logical volume to 4 MB.

To make it obvious which logical volume needs to be deleted, I renamed the logical volume to "xen3-vg/deleteme".

Nevertheless:

> lvremove -vf /dev/xen3-vg/deleteme

Returns:

Logical volume xen3-vg/deleteme in use.

On searching, I have tried all the following, but to no avail.

> lvdisplay

--- Logical volume ---
LV Path                /dev/xen3-vg/deleteme
LV Name                deleteme
VG Name                xen3-vg
LV UUID                iL2tB4-4tjc-0dlj-ibBX-nQup-oZsX-g81XXO
LV Write Access        read/write
LV Creation host, time xen3, 2017-01-04 07:16:26 +0100
LV Status              available
# open                 1
LV Size                4.00 MiB
Current LE             1
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           254:7

> dmsetup info -c | grep deleteme

xen3--vg-deleteme   254   7 L--w    1    1      3 LVM-aAW4aSeLjqJPPWlF1s1WxAgzeXAjWmXiiL2tB44tjc0dljibBXnQupoZsXg81XXO

> lvchange -an -v /dev/xen3-vg/deleteme

Logical volume xen3-vg/deleteme in use.

> lvremove -vf /dev/xen3-vg/deleteme

Logical volume xen3-vg/deleteme in use.

> umount /dev/xen3-vg/deleteme

umount: /dev/xen3-vg/deleteme: not mounted

> lsof | grep "254,7"

[no output]

> lsof | grep deleteme

[no output]

> fuser /dev/xen3-vg/deleteme

[no output]

If someone could offer advice on how to remove xen3-vg/deleteme I would be very happy.

Rebooting the hypervisor is the final option (to be executed out of office hours), but I would prefer not rebooting.

Thank you in advance.


Thank you, Brandon for your suggestion.

Following the instructions at http://naveen161089.blogspot.com/2014/03/forcefully-remove-lvm.html I tried the following:

> dmsetup ls

[..]
xen3--vg-deleteme   (254:7)
[..]

> dmsetup info -c xen3--vg-deleteme

Name              Maj Min Stat Open Targ Event  UUID                                                                
xen3--vg-deleteme 254   7 L--w    1    1      3 LVM-aAW4aSeLjqJPPWlF1s1WxAgzeXAjWmXiiL2tB44tjc0dljibBXnQupoZsXg81XXO

> dmsetup remove xen3--vg-deleteme

device-mapper: remove ioctl on xen3--vg-deleteme failed: Device or resource busy
Command failed

> lvremove -f /dev/xen3-vg/deleteme

Logical volume xen3-vg/deleteme in use.

I already followed the instructions at: Can't remove open logical volume as stated in my original post.

Neither approach solved the problem.

Does anyone have any further suggestions?

Best Answer

I think the main mistake was to execute lsof/fuser on the device-file "/dev/xen3-vg/deleteme" and not on the mount-point (e.g.: "/mnt/myDataMount").

(Thats misleading and I also tripped into it: but it's the same, as if you wanted to run lsof on "/dev/sda3" - that does not work. But you can run lsof on /mount/somedrive)

The steps to do in short:

  1. search the "LV path" in the mounts with mount |grep deleteme # where "deleteme" stands for the lv-name. this exemplary outputs something like "/my/mountpoint"
  2. lsof /my/mountpoint to find out which process is using it
  3. kill the process (kill -9 naggingprocess) or stop the service (service something stop)
  4. check (2.) again
  5. umount /dev/xen3-vg/deleteme
  6. lvremove /dev/xen3-vg/deleteme (or lvremove -f)
Related Topic