Linux Applications

How Does Logical Volume Manager (LVM) Works on Linux

Logical Volume Manager (LVM) is a powerful disk management tool for Linux. LVM can manage multiple disks at once – hard drives, SATA SSDs, NVME SSDs, etc. Instead of creating physical partitions on the disks, LVM uses logical volumes that can span over multiple disks (managed by LVM). This feature gives LVM greater flexibility in storage management.

In this article, we will discuss how Logical Volume Manager (LVM) works and the features of LVM.

Topic of Contents:

  1. Basic Working Principles of LVM
  2. Logical Volume Manager (LVM) Features
  3. Conclusion

Basic Working Principles of LVM

The process on how LVM manages the disks is illustrated in the following figure:

Some of the important terms of LVM are explained as follows:

Physical Volume (PV): The physical disks (HDDs, SSDs, etc.) that are added to the LVM system for management are called LVM physical volumes (PV). In the figure, Disk 1, Disk 2, and Disk 3 are called the LVM Physical Volumes (PV).

Volume Group (VG): One or more physical disks form an LVM Volume Group (VG). As illustrated in the figure, Disk 1, Disk 2, and Disk 3 form an LVM Volume Group (VG).

Logical Volume (LV): In each LVM Volume Group, you can create as many as 256 LVM Logical Volumes (LV). LVM logical volumes (LV) are like disk partitions. You can format them and mount them on the Linux filesystem in the same way that you format and mount the disk partitions. This is illustrated in the previous figure.

Logical Volume Manager (LVM) Features

The features of Logical Volume Manager (LVM) are explained shortly in the following:

Logical Volume Management: The main purpose of LVM is to abstract the physical disks such as HDDs/SSDs into logical volumes/partitions so that they can be managed easily and with greater flexibility. Once you read about the other features of LVM, these terms will be clearer.

Dynamic Resizing: Dynamic resizing of logical volumes is one of the major features of LVM. One of the limitations of MBR or GPT partitions is that it’s very difficult to resize the partitions once they are created. You also can’t resize the MBR or GPT partitions while they are mounted. LVM dynamic resizing features allow you to resize (shrink/expand) the LVM logical volumes (LV) on the fly without ever needing to unmount the logical volumes.

Thin Provisioning: If you create a 10 GB LVM logical volume and you store only 2 GB of files in it, the LVM logical volume will only allocate 2GB from the LVM volume group, not 10 GB. This feature of LVM is called thin provisioning. You can create as many logical volumes in an LVM volume group as you need as long as the total used disk space of all the logical volumes of an LVM group is less than the total available disk space of the LVM volume group.

Snapshots: You can take snapshots of an LVM logical volume and restore the logical volume from the snapshot if anything goes wrong. The LVM snapshot feature is very useful for backing up the data, testing things, and recovering the data.

Stripping the Data Across Multiple Disks: We already discussed this feature of LVM. LVM spreads the data that are stored on the LVM logical volumes across all the physical volumes (HDDs/SSDs) that are added to the LVM volume group. This enhances the read/write performance of the LVM logical volumes. In a sense, the LVM volume group works like a RAID-0 array. It glues the physical disks together to increase the total available disk space.

Mirroring the Data on Multiple Disks: LVM can also be configured to replicate the data of one physical disk into the other physical disks that are added to the same LVM volume group. This works in the same way as a RAID-1 array. Even if one of the disks of the LVM volume group fails, the data of the LVM volume group will still be safe.

Works with RAID: LVM works flawlessly with the software and hardware RAID. You can set up a RAID array and use LVM to manage the volumes/partitions of the RAID array.

Data Migration: LVM can migrate the data between physical volumes with ease. The LVM data migration works even if the physical volume is an iSCSI device. So, you can migrate the LVM data over the network via iSCSI.

Conclusion

We explained how Logical Volume Manager (LVM) works. We also showed you a figure that explained how LVM abstracts the physical disks and manages the disks logically and discussed the features of the Logical Volume Manager (LVM) as well.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.