frequently I notice that after a

$ sudo lvcreate vg -L 10G

immediately followed by a

$ sudo lvremove vg/<created volume>

I get the error message

Can't remove open logical volume "..."

while a

$ sudo lvs

shows me for that volume

  lvol2         vg   -wi-a-  10,00g
  • so there os a - after the a in the flags, where there should be an o if the volume was really open.

After some time, deletion works.

Why is that the case? How can I make it work immediately?

EDIT: The following did not lead to something useful:

$ sudo rm /dev/mapper/vg-lvol24 
$ sudo lvremove /dev/vg/lvol24
  Can't remove open logical volume "lvol24"
$ sudo lvs vg/lvol24
  LV     VG   Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lvol24 vg   -wi-a- 10,00g                                      
$ sudo lvremove /dev/vg/lvol24
  Can't remove open logical volume "lvol24"
link|improve this question
feedback

2 Answers

Remove all mappings to that LV from /dev/mapper/ by deleting the symlinks and then you will be able to remove it.

link|improve this answer
Didn't work, see my edit. – glglgl Jan 15 at 7:38
feedback
up vote 2 down vote accepted

It seems that there is a problem with the cooperation between lvm and udev.

On a lvremove, there are udev change events for every available block device. Their processing seems to disturb the removal process, and removal fails.

The solution is to deactivate the LV(s) to be removed with lvchange -an <given LV>. In this case, only a handful of "remove" events is created, which results from the associated dm device being removed.

If I lvremove the now deactivated LV, there are still a lot of udev change events, but they do not affect the LV to be removed (because it doesn't exist in the dm any longer), so it works without problems.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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