Creating a Volume Group
Before we get into the details of creating a volume group its best we know more about physical volumes, since physical volumes are the foundation to building a volume group.
Using fdisk you should be able to list available partitions and disks on your server. Lets assume you have 3 disks:
- /dev/sda
- /dev/sdb
- /dev/sdc
Lets assume /dev/sda has already been divided into partitions like so
/dev/sda1 -> /root /dev/sda2 -> /swap /dev/sda3 -> /boot
So we have only 2 free disks /dev/sdb and /dev/sdc, we can use these non-partitioned disks to create a Physical Volume.
pvcreate /dev/sdb /dev/sdc
Now by running pvscan
command we can get a list of available physical volumes or you can get a more detailed information from pvdisplay
command.
pvscan
PV /dev/sdb lvm2 [120.00 GB / 120.00 GB free]
PV /dev/sdc lvm2 [240.00 GB / 240.00 GB free]
Now that we have 2 physical volumes we can create a volume group in the following format
vgcreate VGNAME /dev/sdb /dev/sdc
When physical volumes are used to create a volume group, its disk space is divided into 4MB extents, by default. This extent is the minimum amount by which the logical volume may be increased or decreased in size. Large numbers of extents will have no impact on I/O performance of the logical volume.
For KVM its recommended that we use 128M extents by using the -s option while creating the volume group
vgcreate VGNAME [pv1,pv2,...pvN] -s <Size-of-PE>