Skip to main content

LFCS Certification Course

Chapter #11: Create, Resize & Mount LVM Volumes in Linux

In this chapter, you'll learn how to create, format, resize, and mount logical volumes in Linux using LVM for daily use.

One of the most important decisions while installing a Linux system is the amount of storage space to be allocated for system files, home directories, and others.

If you make a mistake at that point, growing a partition that has run out of space can be burdensome and somewhat risky.

Logical Volumes Management (also known as LVM), which have become a default for the installation of most (if not all) Linux distributions, have numerous advantages over traditional partitioning management.

Key Benefits of LVM

Perhaps the most distinguishing feature of LVM is that it allows logical divisions to be resized (reduced or increased) at will without much hassle.

The structure of the LVM consists of:

  • One or more entire hard disks or partitions are configured as physical volumes (PVs).
  • A volume group (VG) is created using one or more physical volumes. You can think of a volume group as a single storage unit.
  • Multiple logical volumes can then be created in a volume group. Each logical volume is somewhat equivalent to a traditional partition - with the advantage that it can be resized at will as we mentioned earlier.
πŸ’‘
LVM also supports features like snapshots (used for backups or testing changes), striping, and mirroring for better performance and reliability. Snapshots allow you to capture the state of a volume at a particular point in time, which can be useful before risky operations.

In this chapter we will use three disks of 8 GB each (/dev/sdb, /dev/sdc, and /dev/sdd) to create three physical volumes. You can either create the PVs directly on top of the device, or partition it first.

Although we have chosen to go with the first method, if you decide to go with the second (as explained in Part 4 of this series) make sure to configure each partition as type 8e.

Creating Physical Volumes (PVs)

To create physical volumes on top of /dev/sdb, /dev/sdc, and /dev/sdd, do:

pvcreate /dev/sdb /dev/sdc /dev/sdd

You can list the newly created PVs with:

pvs

And get detailed information about each PV with:

pvdisplay /dev/sdX

(Where X is b, c, or d)

If you omit /dev/sdX as a parameter, you will get information about all the PVs.