LVM, or the Logical Volume Manager, is a Linux volume partitioning solution that has been around for some time and provides a number of advanced features.

While many people confuse LVM with the file system, it actually works on a separate layer in order to create a virtual partitioning scheme on top of the actual disk layout.

LVM provides more flexibility when compared with traditional partitions, which can be extremely useful in many cases. However, there are also scenarios when it is pointless to use it or there are better options available.

We will discuss in this article what are the advantages and disadvantages of LVM, as well as some potential use cases.

How does LVM work?

The basic building blocks of the system are Physical volumes (PV). These can be any kind of available storage devices like actual discs (hard drives, SSDs, etc), RAID arrays, MBR and GPT partitions or various other block device nodes.

The physical volumes are combined into Volume groups (VG), which serve as storage pools. They create a unified storage space, combining the capacity of all underlying devices. Volume groups can be quickly resized by adding or removing physical volumes.

From a volume group, the Logical volumes (LV) are created. These are the actual partitions that can be formatted with various file systems and used by the operating system.

Unlike traditional disk partitions, the logical volumes are very flexible because they are abstracted in their volume group. A logical volume doesn’t have to be contiguous, it can stretch on multiple disks, can be easily migrated and you can assign it a name instead of a number for easier identification.

LVM splits physical volumes into small chunks names Physical extents (PE). These have a default size of 4 MB, must be contiguous and are the smallest units that can be allocated. PEs can be added and removed from volumes on the fly and are the core concept that powers LVM.

Advantages of LVM

The biggest advantage of LVM is that both logical and physical volumes can be created, deleted and resized online, without any restarts.

Logical volumes can also be resized dynamically, so you can start for example with a small partition and configure it to expand as data is written on it.

Any number of disks and partitions can be unified into a big one, or a single physical disk can be quickly split into many partitions of any size.

In addition, LVM allows the creation of instant logical volume snapshots while the operating system is running and supports advanced encryption features.

Disadvantages

The main disadvantage of LVM is that it adds another layer to the storage system. While the overhead of LVM is usually small, any decrease in performance can be critical on busy systems.

While the ability to resize logical volumes is very useful, the file systems installed on them must be resized separately. Since most Linux file systems don’t support online resizing, a period of downtime is needed.

Many users have reported significant performance issues when creating snapshots, which limits their use in a production system.

Finally, modern file system like zfs or btrfs support most of the advanced features of LVM (online resizing, snapshotting), without the need to add another layer.

When to use LVM?

The option to setup LVM is presented during the installation of any modern Linux distribution, should you use it? The answer depends on the actual use case.

LVM can be extremely helpful in dynamic environments, when disks and partitions are often moved or resized. While normal partitions can also be resized, LVM is a lot more flexible and provides extended functionality.

As a mature system, LVM is also very stable and every Linux distribution supports it by default. It is easy to install and configure, with plenty of online documentation available, unlike the modern file systems alternatives that require advanced knowledge and are not as reliable in a production setting.

Another common use case for LVM is in testing environments, when you need for example to create multiple partitions for different file systems. It is also 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.

Some system administrators install LVM solely because of the snapshots, which preserve an image of a partition that can later be merged with the original in order to restore it to an earlier state.

However, in a static environment where partitions and disks are never changed, there is no reason to configure LVM unless you need to create snapshots.

 

LVM is a complex service with many other features that are described in detail in the official documentation.

Looking into the future, it is very likely that LVM will be phased out as the new generation of file systems like zfs and btrfs become mature. At the moment, it is still a very powerful and flexible tool that remains the best choice in many situations.

Facebooktwittergoogle_plusredditpinterestlinkedinmail