1

I have an unusual LVM arrangement where a single logical volume span two physical volumes (occupying an entire volume group):

  1. 2 MB, read-only, temporary image in RAM
    • 1 LVM2 physical volume
      • Volume group XYZ
        • Logical volume ABC
          • LUKS header
  2. Physical media of an arbitrarily large size
    • 1 LVM2 physical volume
      • Volume group XYZ
        • Logical volume ABC
          • Encrypted payload

I don’t remember where I got the idea from, but the setup works pretty well for the most part:

  1. I have a script that automatically creates the first physical volume in RAM, attaches it as a loop device.
  2. The script deletes it immediately after mounting, forces the system to scan for and activate the volume group using udevadm trigger.
  3. And then it runs losetup --detach on the loop device which will remove the loop device automatically once all of the logical volumes are unmounted and the volume group is deactivated.
  4. My system ends up with one LUKS device ready to open. I have to mount it from Nautilus and unmount it when I’m finished.
  5. Currently, I have to open up the terminal and deactivate the volume group manually using vgchange -an after unmounting everything from the GUI.

Is there a way I can lazily remove a specific volume group like I did with losetup --detach? The manual page for losetup states this for the --detach argument:

Detach the file or device associated with the specified loop device(s). Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not return EBUSY error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later.

I’m interested in an “autoclear” functionality for LVM2 volume groups or something equivalent.

(I understand that I can also migrate my data to a setup that uses LUKS detached headers, but I am still interested in an autoclear functionality for LVM2 volume groups.)

0

You must log in to answer this question.

Browse other questions tagged .