Basic concepts

LVM acronym and basic concepts

Logical volume manager (LVM) introduces an extra layer between the physical disks and the file system allowing file systems to be :

– resized and moved easily and online without requiring a system-wide outage.

– Using discontinuous space on disk

– meaningful names to volumes, rather than the usual cryptic device names.

– span multiple physical disks

LVM comprises of few conceptual layers such as physical volume, logical volume and file systems.

The conceptual layers are in turn made up of smaller units like Physical extents(in case of Physical volumes) and Logical extents (in case of Logical Volumes).

LVM is a tool implemented in the Linux Kernel that let’s you work with logical volumes (LV from now on), volumes that lay between the physical hard drives and the filesystems that will bring these LV to life. A LV needs to belong to a Virtual Grup (VG) in order to operate, as well as a VG can only exist after a Physical Volume (PV), which is the adaptation of a HDD or HDD partition so it can work with LVs. LVs, on its way, are divided in Physical Extents (PE), and they are the ones that determinate the size of a LV, though it is easily translatable to a human readable value. So, more or less, this is what we have:

  • Physical Volume (PV): This can be created on a whole physical disk (think /dev/sda) or a Linux partition. Each Physical Volume can be a disk partition, whole disk, meta-device, or a loopback file. Use the command pvcreate to initialize storage for use by LVM. Initializing a block device as physical volume places a label at the start of the device.

  • Volume Group (VG): This is made up of at least one or more physical volumes. A Volume Group gathers together a collection of Logical Volumes and Physical Volumes into one administrative unit. Volume group is divided into fixed size physical extents. The command vgcreate creates a new volume group using the block special device Physical Volume path previously configured for LVM with pvcreate. – VGs are made up of PVs, which in turn are made up of physical extents (PEs). The size of PE can differe in different VGs and is defined at the time of creating VG. – The default size of PE is 4MB, but you can change it to the value you want at the time of VG creation. – Generally, larger the PE size, better the performance (though less granular control of LV).

  • Logical Volume (LV): This is sometimes referred to as the partition, it sits within a volume group and has a file system written to it. A Logical Volume is the conceptual equivalent of a disk partition in a non-LVM system. Logical volumes are block devices which are created from the physical extents present in the same volume group. You can use command lvcreate to create a logical volume in an existing volume group.

  • File System: A file system such as ext4 will be on the logical volume. File systems are built on top of logical volumes. The command mkfs can be used to create file system on top of a logical volume. Once the file system is created we can mount the logical volume as per our need.

Basic commands associated with PV , VG , LV and file system is listed here.

Last updated