How to Manage LVM Volume Groups and Logical Volumes in Linux

The Flexibility of Logical Volume Management

Historically, Linux administrators partitioned hard drives using fixed sizes (e.g., 50GB for /var and 100GB for /home). If the /var partition filled up, the server would crash, even if /home had 90GB of free space, because standard partitions cannot easily be resized across different physical disks. Logical Volume Management (LVM) solves this abstraction problem. It pools multiple physical hard drives together into a single “Volume Group”, allowing you to create fluid, resizable “Logical Volumes” that can easily span across multiple physical disks and be expanded on the fly without rebooting.

Step 1: Create Physical Volumes (PV)

Before LVM can use a new hard drive, you must initialize it as a Physical Volume. This places an LVM header on the disk so the system recognizes it as LVM-managed storage.

Assuming you have added two brand new unformatted hard drives (/dev/sdb and /dev/sdc) to your server, initialize them both using the pvcreate command:

sudo pvcreate /dev/sdb /dev/sdc

The terminal will output: Physical volume “/dev/sdb” successfully created. You can view all available PVs by running sudo pvs.

Step 2: Create a Volume Group (VG)

Now, you must group these individual physical disks into a single, large storage pool called a Volume Group. We will name this group vg_data.

sudo vgcreate vg_data /dev/sdb /dev/sdc

If /dev/sdb is 500GB and /dev/sdc is 500GB, you have just created a massive 1TB unified storage pool. You can verify the total size and free space of the pool by running sudo vgs.

Step 3: Create a Logical Volume (LV)

With your 1TB pool ready, you can “carve out” Logical Volumes. These act exactly like traditional partitions; you will format them and mount them. However, they are fluid. We will create a 200GB volume for a database and name it lv_database:

sudo lvcreate -n lv_database -L 200G vg_data

The new block device path for this volume is now /dev/vg_data/lv_database. You can view your LVs by running sudo lvs.

Step 4: Format and Mount the Logical Volume

Like any partition, the new LV needs a file system (such as EXT4 or XFS) before you can store files on it.

sudo mkfs.ext4 /dev/vg_data/lv_database

Create a mount point and mount the volume:

sudo mkdir -p /mnt/db_storage

sudo mount /dev/vg_data/lv_database /mnt/db_storage

(Remember to add this to your /etc/fstab so it persists across reboots).

Step 5: Expand the Logical Volume On the Fly

The true power of LVM is resizing. Six months later, your database has grown, and the 200GB LV is 99% full. Because your vg_data pool still has 800GB of free space left, you can instantly expand the volume by 50GB without taking the server offline.

First, extend the Logical Volume block device:

sudo lvextend -L +50G /dev/vg_data/lv_database

Second, resize the underlying EXT4 file system to “fill” the newly allocated block space:

sudo resize2fs /dev/vg_data/lv_database

Your database partition is now 250GB, and your server experienced absolutely zero downtime.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.