What is LVM?

W

Linux Logical Volume Manager (LVM) is a disk virtualization mechanism. LVM is a technology similar to RAID arrays or Windows storage in some ways. Although this technology is especially useful on servers, it can also be used on desktop Pcs. The first question is whether you even want to use LVM with the Ubuntu installation. Ubuntu makes it easy to activate by simply clicking, but this option is not enabled by default. As the installer says, it allows you to resize partitions, create snapshots, merge multiple disks into a single logical volume, and so on – all while the system is running.

The average Ubuntu desktop user probably will not know whether or not they are using LVM. But if you want to do more advanced things later, LVM can help you.

LVM is much more complex, which could cause problems if you need to recover data later, especially if you do not have enough experience. I’ve explained beforehand what LVM is. It provides a layer of abstraction between physical disks and partitions presented in the operating system.
For example, the computer might have two hard drives inside it, with 1 TB each. You will need to have at least two partitions on these disks and each of these partitions would have a size of 1 TB. LVM offers an abstraction layer in this regard. Instead of a traditional disk partition, LVM would treat disks as separate “physical volumes” after initializing them. You can then create bulky volumes based on these physical volumes. For example, you can combine the two 1 TB disks into a single 2 TB partition.
The operating system will only see a volume of 2 TB, and LVM will treat everything in the background.

A group of physical volumes and logical volumes is known as a “volume group”. A typical system will have only one volume group. This layer of abstraction makes it easy to resize partitions, combine multiple disks in a single volume, and even retrieve the partitions file “snapshots” while running, all without being disassembled. Note that merging multiple disks into a single volume may be a bad idea if you do not back up. It’s just like RAID 0 – if you combine two 1TB volumes into a single 2TB volume, you can lose important volume data if one of the hard drives fails. Backups are essential if you go on this route.

LVM volumes are managed with Linux terminal commands. In LVM we have 3 levels of abstraction, and a set of commands for each level that is intuitively simple to memorize:

1. PV (Physical Volume) – Physical disks can be either partitions, either rigid disks in their entirety.
pvcreate – initiates physical disks for use in LVM
pvdisplay – displays information about physical disks
pvremove – delete a physical volume

2. VG (Volume Group) – The group of disks that will be part of the LVM
By creating the group, we find out which partitions or HDDs will be part of the LVM.
vgcreate – creates the volume group
vgdisplay – displays information about volume groups
vgreduce – deletes a volume group

3. LV (Logical Volume) – The partitions that will be created from the volume group (VG).
lvcreate – creates the logical volume
lvdisplay – displays information about logical volumes
lvremove – delete a logical volume

As an alternative to administering LVM you can use system-config-lvm, which must of course be installed in the system.

Recent Posts

Archives

Categories