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.
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.
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
lvcreate -n INSTALL -l204800 vg-megaraid /dev/sda:1224995-1429794