Operations 14 min read

Master LVM: Create, Resize, and Delete Logical Volumes on Linux

This tutorial walks through preparing physical disks, creating physical volumes, a volume group, and multiple logical volumes, formatting and mounting them, dynamically expanding storage, and safely removing LVM components on a Linux system.

Raymond Ops
Raymond Ops
Raymond Ops
Master LVM: Create, Resize, and Delete Logical Volumes on Linux

1. Prepare physical devices

List the target disks:

lsblk /dev/sdb /dev/sdc

2. Create physical volumes

Initialize the disks as physical volumes: pvcreate /dev/sdb /dev/sdc Verify with:

pvs
pvdisplay /dev/sdb
pvdisplay /dev/sdc

3. Create a volume group

Create a volume group named myvg01 and add the physical volumes: vgcreate myvg01 /dev/sdb /dev/sdc Check the group:

vgs myvg01
vgdisplay myvg01

4. Create logical volumes

Parameter explanation: -n: logical volume name -L: size in absolute units (e.g., 5G) -l: size in extents or percentage (e.g., 100 extents or 50%FREE)

Examples:

lvcreate -n mylv01 -L 5G myvg01
lvcreate -n mylv02 -l 100 myvg01
lvcreate -n mylv03 -l 50%FREE myvg01

View logical volumes:

lvs /dev/myvg01/mylv01
lvs /dev/myvg01/mylv02
lvs /dev/myvg01/mylv03

5. Format logical volumes

Format mylv01 with XFS:

mkfs.xfs /dev/myvg01/mylv01

6. Mount and use

mkdir /funlyp-lv01
mount /dev/myvg01/mylv01 /funlyp-lv01
df -Th | grep funlyp
touch /funlyp-lv01/lvm_practice.log

7. Dynamic expansion

Task: The partition is too small, how to expand?

Steps:

Identify the mounted logical volume (e.g., /dev/mapper/myvg01-mylv01).

Check free space in the volume group with vgs myvg01.

If free space exists, extend the logical volume and grow the filesystem.

Example – add 5 GiB:

lvextend -L +5G /dev/myvg01/mylv01
xfs_growfs /dev/myvg01/mylv01

Further expansion to 20 GiB after adding a new disk sde:

pvcreate /dev/sde
vgextend myvg01 /dev/sde
lvextend -L +10G /dev/myvg01/mylv01
xfs_growfs /dev/myvg01/mylv01

8. Delete LVM components

When you need to delete a logical volume, how to operate?

Procedure:

Unmount the filesystem.

Remove logical volumes.

Remove the volume group.

Remove physical volumes.

umount /funlyp-lv01
lvremove /dev/myvg01/mylv01
vgremove myvg01
pvremove /dev/sdb /dev/sdc /dev/sde
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxstorageSystem AdministrationLVMFilesystemLogical Volume
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.