Logical Volume Management
LOGICAL VOLUME MANAGEMENT
The most popular flexible approach of managing disk storage for Linux.
Fig. 1: Traditional standard partitions based on individual drive capacity.
Flexible Management of Storage
What can we do when the root partition space is full? The option we have is to expand the size of the root volume. And with LVM we can easily do so.
LVM offers us a flexible approach to allocate space on a mass storage device, so it is well suited for the management of partitions of various sizes, like the ones used to store logs that start small but can significantly increase in time.
LVM can perform a lot of jobs while the server is live.
You can create/resize/delete LVM “partitions” (they’re called “Logical Volumes” in LVM-speak) from the command line while your Linux system is running: no need to reboot the system to make the kernel aware of the newly created or resized partitions.
Easily Manageable Logical Volumes.
The Volume Groups can be subdivided into one or more Logical Volumes (LVs). These Logical Volumes are then used as if they were traditional standard partitions. The VG has a total capacity, and then some part of that capacity is allocated to a Logical Volume. (Refer fig.2)
Fig. 2: LVM as total combined storage space.
LVM functions by layering abstractions on top of physical storage devices. The basic layers that LVM uses are:
1. Physical Volumes:
- LVM utility prefix: pv…
- A Physical Volume is a one-to-one mapping of individual partitions. So we need to convert these individual partitions as “Physical Volume” which makes them usable in an LVM environment.
2. Volume Groups:
- LVM utility prefix: vg…
- LVM combines physical volumes into storage pools known as “Volume groups”, which is the abstraction of all available storage. “The abstraction” means that the volume group is not something that is fixed, but that it can be resized when needed, which makes it possible to add more space on the volume group level when volumes are running out of disk space.
3. Logical Volumes:
- LVM utility prefix: lv…
- On top of the volume group are the “Logical Volumes” which represents the block device that can be shared. These do not act on disks directly but get their disk space from available disk space in the volume group. That means that a logical volume may consist of available storage from multiple physical volumes.
Note: The actual File Systems are created on the logical volumes. As the logical volumes are flexible with regard to size, that makes the file systems flexible as well. If a file system is running out of disk space, it is relatively easy to extend the file system, or to reduce it if the file system allows that.
Benefits Over Traditional Standard Partition
- Scalability: One of the benefits of LVM configurations is the ability to scale storage capacity easily and quickly. Usually, of course, sysadmins need to scale up (increase capacity). It’s worthwhile to note that you can also scale storage capacity down with LVM. That means that if storage capacity is over-allocated (you configured far more storage than you needed to), you can shrink it.
- Flexibility: Let us suppose you have a server of 6TB of capacity. And you have created two LVs of 3TB each. After a few weeks, you discover that you should have created LVs of 4TB and 2TB instead. You can remove 1TB of capacity from one volume group and add it to another volume group. This flexibility is provided to you in LVM partition which is far more than traditional partitioning.
- Snapshots: LVM volume snapshots allow you to create a backup from a point- in-time view of the file system. The snapshot is created instantly and persists until you delete it. You can back up the file system from the snapshot while the volume itself continues to be available for users. In a virtual host environment, you can use the snapshot function to back up the virtual machine’s storage back-end, or to test changes to a virtual machine image, such as for patches or upgrades, without modifying the source logical volume.
Hybrid volumes can be created using the dm-cache target, which allows one or more fast storage devices, such as flash-based SSDs, to act as a cache for one or more slower hard disk drives.
LVM also supports RAID configurations, mirroring, and other advanced settings that make it an even more attractive solution.
Logical Volume Manager provides much greater flexibility to your storage needs and it’s not very complicated. The majority of its management commands are related and also user-friendly, therefore relatively easy to remember.