Logical Volume Management (LVM) – ciscostuff

Logical Volume Management can be done using Logical Volume Manager (LVM) which creates an abstraction layer in between Physical devices such as Physical Disks or Volumes which are formatted with a file system on it.

In order to understand the LVM, you need to understand how partitions are configured. Basically, a process initializes the physical disk or partitions to be used for Logical Volume. Later on, Volume Groups (VGs) are created on physical devices. These Volume Groups contain manageable disk chunks known as Physical Extents(PEs). Further, these Physical Extents can be used to create Logical Volumes (LVs) which uses Logical Extents(LEs).

Create a physical volume

For this demonstration, as you can see in the picture, we will use two newly added disks (sdb and sdc). These disks were just added to the sytem and there is no file system or partition on these.

[root@app-rh1t ~]# pvcreate /dev/sdb /dev/sdc

Physical volume "/dev/sdb" successfully created.

Physical volume "/dev/sdc" successfully created.

Once executed the command above on these physical disks, these disks will be ready (initialized) for Volume Group creation. If the command execution was successful, you should see an output as below when issues the command



*Note: You can also use partitions to be configured as the PV if these disks had any partitions available.

Creating Volume Group

Volumes Groups (VGs) are created from one or more PVs. Volume Groups can be taken as manageable containers which can be further divided into Logical Volumes. For example, you may have a volume group, made up from two PVs, named as HRVolumeGroup and then Logical Volumes named HR-Data, HR-Archive etc on it.

Issue the following command in order to create Volume Group

[root@app-rh1t ~]# vgcreate HRVolumeGroup /dev/sdb /dev/sdc

Volume group "HRVolumeGroup" successfully created


Volume Group creation can be verified using the vgdisplay command.


As you can see in the screenshot above that both physical disks (sdb and sdc) were 20GB respectively. Since we choose Volume Group “HR Volume” to be spanned across multiple disks it combined the Physical disks and became 40 GB (39.99 usable). We can create as many Logical Volumes on it now.

Create Logical Volume

Suppose, HR department now wants to have a folder named HRArchive to archive their old documents and also another folder HRData for other stuff. You can achieve this very easily.

Creating HRArchive logical volume of space 10GB

[root@app-rh1t ~]# lvcreate -L 10G HRVolumeGroup -n HRArchive

Logical volume "HRArchive" created.


Again, you can verify if the logical volume was created using the lvdisplay command.


Similarly, you can create the HRData Logical Volume assuming that they wanted all the remaining space (30G) for this volume.

[root@app-rh1t ~]# lvcreate -l 7678 HRVolumeGroup -n HRData



Did you see any difference?

HRData Logical Volume has been created and is assigned the remaining space (almost 30G), however, the command syntax is different this time. I used the lowercase L (-l) instead of uppercase L (-L). Why?

If you remembered; as mentioned earlier, that a volume group has Physical Extents or PEs. These PEs can also be used to create volume group. Assigning PEs to Volume group can determine the size of the volume. In our case, the since HRData Volume group needed an entire remaining space to be used, I just used the number of available PEs in our Volume Group. So how can you find the PEs? VGDisplay is your friend here.

Issue the command on volume group you are trying to find the PEs and look for the section where it reads Total PE, Alloc PE / Size, Free PE / Size.


[root@app-rh1t ~]# vgdisplay HRVolumeGroup


As you can see that PE and Size options are pretty much similar and can be a personal preference; of which one to use, depends on you. Just remember if you are using uppercase L (-L) option, you will have to define the Size unit in MB(M), GB(G) as stated above while creating HRArchive Volume group.

Hope this has been informative. We will discuss other available options and tweaks in next article.

Share your thoughts