LVM

LVM (Logical Volume Manager)*

It is a software that allows the implementation of RAID from partitions and offer them to the operating system as new devices. For its operation, it assigns the disks to one or more physical volumes that must be partitioned as LVM type. LVM storage volumes have the ability to be resized and transported depending on the user’s needs and using the updated device tools.

This manager uses the RAID0 or stripe of logical volumes, which does not perform redundancy for storage. In addition, this array performs the function of accelerating data by combining multiple hard disks within a logical drive.

Logical Volume Management makes use of the device-mapper function of the Linux kernel to provide a partition system independent of the underlying disk structure. With LVM it is possible to create an abstract storage space as well as different virtual partitions, making it easier to enlarge/shrink partitions (always subject to possible limitations).

The basic building blocks of LVM are:

  • PV (Physical Volume): Unix block device node, usable for LVM storage. Examples: a hard disk, a partition MBR or GPT, a loopback file, a device mapper device (dm-crypt). It hosts an LVM header.
  • VG (Volume Group): A group of physical volumes that serves as a container for logical volumes. Physical extents are allocated from a volume group for a logical volume.
  • LV (Logical Volume): A virtual/logical partition that resides in a volume group and is composed of physical extents. Logical volumes are Unix block devices analogous to physical partitions, they can be formatted directly with a file system.
  • PE (Physical Extent): The smallest contiguous extent (default 4 MiB) on the physical volume that can be mapped to a logical volume. Think of physical extents as parts of physical volumes that can be mapped to any logical volume.
**Physical Disks**

  Disk 1 (/dev/sda):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|Partition1 50 GiB (Physical volume)|Partition2 80 GiB (Physical volume)|  
|/dev/sda1                          |/dev/sda2                          |  
|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|

  Disk 2 (/dev/sdb):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|Partition1 120 GiB (Physical volume)               |
|/dev/sdb1                                          |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _|
**Logical Volumes LVM**

Volume Group1 (/dev/MyStorage/ = /dev/sda1 + /dev/sda2 + /dev/sdb1):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
|VL1 15 GiB             |VL2 35 GiB             |VL3 200 GiB            |
|/dev/MyVolGroup/root   |/dev/MyVolGroup/home   |/dev/MyVolGroup/media  |
|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _| _ _ _ _ _ _ _ _ _ _ _ |

Advantages of LVM

  • Being able to use any number of disks as one large disk.
  • Have logical volumes stretched over several disks.
  • Create small logical volumes and dynamically resize them when they fill up.
  • Resize logical volumes regardless of their order on disk. It does not depend on the position of the logical volume within the volume group, nor is there any need to secure the surrounding available space.
  • Resize/create/delete the size of logical and physical volumes online. File systems on them will still need to be resized, but some (such as ext4) support online resizing.
  • Online/live migration of logical volumes, being used by services for different disks without having to restart the services.
  • Perform snapshots that allow backups of the file system, while keeping service downtime to a minimum.

As disadvantages of this technology we can highlight, the additional steps to configure the system with LVM, which makes it more complicated, and you can not configure a Dual-Boot set to Windows, as this is not compatible with LVM, so you can not access any LVM partition.

All Linux systems in their initial installation will give you the ability to configure LVM when installing the system, it is recommended to perform the configuration in a virtual machine before performing it in native.