1

I have a physical volume that is 49.8GB and I want to have a 2GB logical volume which is at the end of the physical volume and the rest of the physical volume being another logical volume. I read through the man pages for LVM and I didn't find a distinct way to add logical volumes to the end of a physical volume.

  • I don't think LVM lets you decide where to put a logical volume inside a physical volume. Why don't you split the PV? – Gilles 'SO- stop being evil' Oct 11 '14 at 14:52
3

If this is your objective, you can create the logical volume and specify the extents for its placement:

lvcreate -l 100 -n lvol1 vg01 /dev/sdb1:900-999

In this example, you would be creating a 100-extend logical volume named 'lvol1' on 'vg01', using the physical volume 'sdb1', extents 900 through 999.

In the case of existing logical volumes, if you have free extents within the volume group, you can use pvmove to shuffle extents within a physical volume or among physical volumes of the volume group.

1

How to calculate LV size in extents:

  • pvdisplay -m and see max extent number for required PV (in my case /dev/sda).
  • caclulate size in extents = [size in you need GB] * 1024 * 1024 / 4kb

    e.g. 800GB = 800 * 1024 * 1024 / 4096 = 204800

  • calculate starting extend number: max extent - size in extents + 1
  • execute command: lvcreate -n MyLV1 -l204800 vg-raid5 /dev/sda:start_extent-max_extent

e.g.: lvcreate -n INSTALL -l204800 vg-megaraid /dev/sda:1224995-1429794

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.