Cannot deactivate LV due to partition device

9,786

The helpful folks at the #lvm channel on Freenode found a solution for me! One simply needs to deactivate the partition mapping using the command kpartx -d /dev/vg/mylv

This removes the partition device entry and allows me to once against deactivate the LV without problems.

Share:
9,786

Related videos on Youtube

Joe
Author by

Joe

SOreadytohelp

Updated on September 17, 2022

Comments

  • Joe
    Joe almost 2 years

    I need to be able to deactivate an LV but cannot after partprobing it and finding gaining access to its partitions in /dev/mapper. It seems I need some way of 'un-partprobing' the disk, but I have no idea how and would welcome some advice.

    Here's what's happening, in case I'm missing something else:

    lvchange -a y /dev/vg/mylv activates the lv fine

    partprobe /dev/vg/mylv results in lv partition being found and device creation at /dev/mapper/vg-mylvp1

    lvchange -a n /dev/vg/mylv now fails - LV vg/mylv in use: not deactivating

    Just to be clear I've checked that this volume is not mounted using every method I know how (including those suggested here). I presume it is in use/being held somewhere, but I cannot determine where. It is only after running partprobe that I can no longer deactivate the LV. Is there any way to force the deactivation? Has anyone else come across this?

    26/7 - Still not managed to progress on from this issue. I did, however, come across this forum post talking about an LV staying 'open' if mounted as a loop. Could this be what is happening here? Does partprobe read using a loop mount? How can I see a list of active loop devices?

    • elmo
      elmo almost 14 years
      Can not reproduce that problem. Doing a "lvchang -a n" works just fine even if partprobe has been run, there is a /dev/mapper/ entry etc. Are you sure there is no automatic mounting happening? Because the error message you get I exactly what I get after I've also mounted the logical volume.
    • Joe
      Joe almost 14 years
      Definitely does not seem to be mounted.
  • Joe
    Joe almost 14 years
    I'm trying to provision the initial template (os file system etc) in a partition before running each vm for the first time. And fuser reports nothing, checked both the partition device and the lv device in three locations - /dev/mapper/vg-mylv, /dev/dm-3 (as fdisk shows it to exist as) and /dev/vg/mylv.
  • Allen
    Allen almost 14 years
    Try using another VM for the provisioning. Has the benefit of testing the LV as a disk for a VM.
  • Stephan
    Stephan over 10 years
    A device lock doesn't necessarily imply a mount.