Chapter 3. Deploying LVM
The following procedures represent the basic configuration for LVM logical volumes on a freshly installed operating system.
3.1. Creating LVM physical volume
This procedure describes how to create and label LVM physical volumes (PVs).
Prerequisites
-
The
lvm2
package is installed.
Procedure
To create multiple physical volumes, use the space-delimited device names as arguments to
pvcreate
command:# pvcreate /dev/vdb1 /dev/vdb2
This place a label on /dev/vdb1 and /dev/vdb2, marking them as physical volumes belonging to LVM.
For more information, see
pvcreate
man page.
3.2. Creating LVM volume group
This procedure describes how to create an LVM volume group (VG).
Prerequisites
-
The
lvm2
package is installed. - One or more physical volumes are created. See the instruction how to do so in Section 3.1, “Creating LVM physical volume”.
Procedure
To create a volume group, use the following command:
# vgcreate myvg /dev/vdb1 /dev/vdb2
This creates a VG with the name of myvg. The PVs /dev/vdb1 and /dev/vdb2 are the base storage level for the VG myvg.
For more information, see
vgcreate
man page.
It is possible to extend the above VG with the PVs later. To extend a VG, use the following command:
# vgextend myvg /dev/vdb3
3.3. Creating LVM logical volume
This procedure describes how to create LVM logical volume (LV).
Prerequisites
-
The
lvm2
package is installed. - The volume group is created. See the instruction how to do so in Section 3.2, “Creating LVM volume group”.
Procedure
To create a logical volume, use the following command:
# lvcreate -n lv01 -L 500M myvg
The
-n
option allows the user to set the LV name to lv01. The-L
option allows the user to set the size of LV in units of Mb in this example, but it is possible to use any other units. The LV type is linear by default, but the user can specify the desired type by using the--type
option.ImportantThe command will fail if the VG does not have a sufficient number of free physical extents for the requested size and type.
For more information, see the
lvcreate
man page.