A Quick Guide for Configuring LVM

So, you’ve got a hard disk or solid state drive that you need to partition and you’re thinking about configuring it with Logical Volume Manager (“LVM”). Here’s a quick walk-through of the steps needed to get LVM working on your drive.

LVM Basics

Let’s first look at some basic LVM terminology. It’s helpful to think of LVM as having three layers: physical volume, volume group, and logical volume (see Figure 1).

Figure 1 – The Three Layers of LVM


A physical volume is a physical disk device – or a partition on a physical disk device – that is initialized for use by the LVM. A list of physical volumes can be seen as an inventory of storage devices and partitions that may be allocated to a volume group.

In the volume group layer, one or more physical volumes are combined to create a volume group. Generating a new volume group creates the illusion of a new physical disk device that is larger, or smaller, than the original devices initialized as physical volumes.

A logical volume is created from allocated space within a volume group. If we consider a volume group to be an abstraction of a physical disk drive, then the logical volume is an abstraction of a partition. Following this understanding, to be activated, logical volumes must be mounted.

Initializing a Physical Volume

There are two[1] options when initializing a new physical volume for the LVM: (1) initialize the entire disk device, or (2) initialize a partition on the disk device.

Initialize the entire disk device:

# pvcreate /dev/sdb

Initialize partition 1 on the disk device:

# pvcreate /dev/sdb1

Note that all LVM commands are run with sudo or as root user.

The command pvs is used to print the status of all physical volumes initiated in the operating system.

# pvs

Creating a Volume Group

The next step is to allocate one or more physical volumes to a volume group. As with physical volumes, a volume group may be created from an entire disk device, a partition, or both.

Create a volume group named “vg0” using the entire disk device:

# vgcreate vg0 /dev/sdb

Create a volume group named “vg0” using partition 1 on the disk device:

# vgcreate vg0 /dev/sdb1

Create a volume group named “vg0” using entire disk devices “sdb” and “sdc”:

# vgcreate vg0 /dev/sdb /dev/sdc

The command vgs is used to print the status of all volume groups created in the operating system.

# vgs

Creating a Logical Volume

A logical volume may then be created from physical space allocated to the volume group.

Create a logical volume named “lv1” of size 8GB in volume group “vg0”:

# lvcreate --name lv1 --size 8G vg0

The command lvs is used to print the status of all logical volumes created in the operating system.

# lvs

Building a Filesystem on the Logical Volume

Before the new logical volume can be used by the operating system, it must be configured with a filesystem. The ubiquitous Linux utility mkfs is used for this task.

Build an ext4 filesystem on logical volume “lv1” in volume group “vg0”:

# mkfs.ext4 /dev/vg0/lv1

Note that the filesystem type of a partition may be listed in Linux using the utility lsblk with option ” -f “.

$ lsblk -f

Mounting the Logical Volume

The final step is to activate the logical volume partition using the mount utility. Simply mount the logical volume as you would any regular partition.

Mount logical volume “lv1” in volume group “vg0” to the directory “/mnt”:

# mount /dev/vg0/lv1 /mnt

To confirm that the logical volume was successfully mounted, view the partition’s MOUNTPOINT column after the lsblk command is run, or look for its appearance in the printout from the command mount -l [lower-case L].

As the logical volume is treated like a regular disk partition, to mount the logical volume automatically on boot, follow the standard practice of modifying the “/etc/fstab” file.

Manual Pages

For more detailed information on any of the above-mentioned LVM commands, please refer to the man page of the specific command.


[1] Actually you have four options. Per the pvcreate manpage: “Each PhysicalVolume can be a disk partition, whole disk, meta device, or loopback file.”

Leave a Reply

Your email address will not be published. Required fields are marked *