0

I have a single (unpartitioned) block device in a server which is used as the single physical volume (pv1) to a volume group (vg1).

Without attaching more storage to the server, is there any way to create a second VG?

I'm aware PVs cannot be shared between VGs. Would it be possible to split the PV in two?

If this not at all possible without attaching storage, what is the best way to avoid running into this situation again? Does LVM have a mechanism to use a single block device as multiple PVs? Or should I partition the block device?

3

To avoid running into that situation again you normally just create many LVs out of the one VG on your block device. There's no limitation like that, and it works well.

If you want to do things like having a VG for the OS and one for data, then you would need to partition the block device (i.e. i have a 16GB partition for the OS -> vg00 and the rest is another partition for all data volumes -> vg01)

But this is not required, you can do fine with one VG.

For the current issue:

  1. Not recommended

In Linux, it is possible to create a PV on an LV, so you could add another VG on the existing space fully online. But it would be pretty ugly and probably fall on your head a year later.

  1. Not recommended

The other option is to shrink the existing VG using the pvresize command.

(and adjusting partitions. This is more risky. I'd recommend to be really careful and test in a VM first)

Once the first PV (and thus the VG) has been shrunk you could repartition the disk and create a new partition, that will be part another VG. This doesn't even work if the existing PV has data spread out to the end with gaps.

  1. I feel you can simply work with more LVs and forget about the new volume group, maybe you just didn't yet know that there's no limit on how many LVs you use?

  2. one hack I've actually used (required test-runs and ended with an hour of downtime) was to add another disk via iSCSI, mirror to that, and then rebuild my "local" storage. The problem is you need to boot off a rescue media to shrink your root partition (shrink is offline for anything but veritas vxfs).

1
  • Unfortunately I cannot go with option 2, since the block device is unpartitioned. Option 1 conceptually is very interesting (I didn't know you could stack block devices like that), but probably best avoided, as you said. I did know LVs are (practically) unlimited in number - I wanted to have multiple VGs as namespace separation, but the drawbacks you've outlined are so great that I'll probably stay with vg1. – loopbackbee Jan 7 '15 at 14:12
1

When you start, it's as easy as defining two partitions on the disk and assign them as PVs to separate VGs. Doing this retroactive is a lot more complicated to do sanely.

Of course, if you like to make your life miserable, you can define a logical volume on your first VG and use this as PV for another VG. This works flawless but it's hard to understand and should be avoided at all costs, not least because stacking block devices not exactly improves the systems performance.

1
  • I didn't know you could stack LVM on top of itself, it's interesting. Good point on the performance,in addition to what Florian Heigi said – loopbackbee Jan 7 '15 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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