5

Is it possible to create a volume group from a logical volume instead of a physical volume? If so, are there any pitfalls in doing so?

Use case:

Installing OpenStack Compute on a a system that already has all of the physical volumes assigned to a singe volume group. The nova-volume service requires a separate volume group, as described in the documentation. I want to know if I can carve off a logical volume and then create the "nova-volumes" volume group.

  • 1
    I don't know for sure that you can't create a PV from a LV and make a VG containing that PV, but it sounds like a maintenance nightmare. I strongly suggest that you carve off a PV and put it in its own VG called nova-volumes. – Gilles 'SO- stop being evil' Mar 05 '12 at 17:15

1 Answers1

3

Yes, it is possible, though you are adding complexity.
I would use this approach either experimentally or as a last resort, only after you have explored other solutions.

paraphrasing man pvcreate "pvcreate initializes PV for later use by the LVM. Each PV can be a ... or meta device ...

Apparently an LV qualifies as a meta device.

Empirically speaking, the following worked just fine

pvcreate /dev/sda16
vgcreate demo /dev/sda16
lvcreate --name lv -l '100%VG' demo
pvcreate /dev/mapper/demo-lv  
vgcreate wrappervg /dev/mapper/demo-lv  
lvcreate --name lv -l '100%VG' wrappervg  
mkfs.ext4 /dev/mapper/wrappervg-lv  
mkdir /mnt/wrapper  
mount /dev/mapper/wrappervg-lv /mnt/wrapper  
touch /mnt/wrapper/foo
bsd
  • 11,036
  • Added the use case description. – Lorin Hochstein Mar 05 '12 at 14:16
  • 1
    Guess you could do it this was, but I would reconfigure the vg to use less space, (backup/restore), then create nova-volume vg/lv separate instead of layered. Regardless, it will work. I don't know where issues might arise, say with snapshots. – bsd Mar 05 '12 at 15:48
  • @bdowning Is it really possible? I thought only supported block devices could be LVM physical volumes, not including LVM logical volumes. – Gilles 'SO- stop being evil' Mar 05 '12 at 17:13
  • 1
    Empirically speaking, it works. As I said I would not pursue this path except either experimentally or as a last resort. I have no idea what implications this config holds. Try it, it does work. – bsd Mar 05 '12 at 17:46
  • @bdowning Ok, thanks. I fully agree that I'd only do this as a last resort, it sounds high-maintenance. – Gilles 'SO- stop being evil' Mar 05 '12 at 18:20
  • Just a remark: In order to "play" with PVs I use loopback-devices, that are made out of files on mounted LVs. Even that is possible. – Nils Mar 05 '12 at 20:55
  • Separate volume group (instead of one inside a logical volume) has same drawbacks than using physical disk partitions: resizing is complicated and somewhat risky. I do understand the critical attitude on this one. That's why I am also trying to find some facts about this.

    Volume group on top of logical volume does create some extra complexity, but as far as I can see, I personally could live with the level of that. However, I'd like to know if there are some other practical reasons why it might not be a recommended way to go.

    – montiainen Nov 21 '14 at 17:42
  • I don't agree that resizing is complicated or risky, assuming one has a current backup handy. Occam's razor is the principle I admin by, adding no more complexity than necessary. If one must configure a nested VG/LV, then there should be a good reason to do so (use case). In my experience I've found the greatest risk to data usually comes from human error, again: backup! – bsd Nov 22 '14 at 14:27