This tutorial walks through extending an existing Logical Volume Manager (LVM) setup by creating new disk partitions, turning those partitions into LVM physical volumes, adding them to an existing volume group, and finally growing the logical volume and filesystem.
The examples below use two NVMe disks, /dev/nvme0n1 and /dev/nvme2n1, and assume the new partitions will be /dev/nvme0n1p2 and /dev/nvme2n1p2. Replace the device names, volume group name, logical volume name, partition numbers, and sizes with the values from your own system.
Table of Contents
Prerequisites
- Root or
sudoprivileges. - A current backup of important data.
- An existing LVM volume group and logical volume.
- The correct disk devices identified with
lsblk,pvs,vgs, andlvs. - Enough unallocated disk space to create the new partitions.
Before changing partition tables, inspect the current layout:
lsblk
sudo pvs
sudo vgs
sudo lvs
In this tutorial, the example volume group is vg_storage, and the example logical volume is /dev/vg_storage/lv_storage.
Step 1: Unmount File Systems If Necessary
If the partitions you are about to modify are mounted, unmount them first. Do not unmount unrelated mounted filesystems, and do not unmount the filesystem you are actively booted from unless you know exactly what you are doing.
sudo umount /dev/nvme0n1pX
sudo umount /dev/nvme2n1pX
Replace X with the appropriate partition number. If the disks contain only free space where the new partitions will be created, this step can usually be skipped.
Step 2: Create New Partitions Using fdisk
The following commands create one new primary partition of 465G on each disk. This uses fdisk non-interactively, which is convenient, but also unforgiving. Confirm the target device names before running the commands.
For /dev/nvme0n1:
echo -e "n\np\n\n\n+465G\nw" | sudo fdisk /dev/nvme0n1
For /dev/nvme2n1:
echo -e "n\np\n\n\n+465G\nw" | sudo fdisk /dev/nvme2n1
The input sequence means:
n: create a new partition.p: create a primary partition.- blank line: accept the default partition number.
- blank line: accept the default first sector.
+465G: create a partition of 465 GiB/GiB-like size as interpreted byfdisk.w: write the changes to disk.
If your system uses GPT and you want to explicitly mark the partition type as Linux LVM, use interactive fdisk or parted and set the partition type appropriately. LVM can often detect usable physical volumes without the partition type flag, but setting it makes the disk layout clearer to future readers.
After writing the partition table, ask the kernel to re-read it:
sudo partprobe /dev/nvme0n1
sudo partprobe /dev/nvme2n1
If the kernel cannot reload the partition table because a disk is busy, a reboot may be required before the new partitions appear correctly.
Step 3: Verify the New Partitions
Verify that the new partitions were created:
lsblk
You should see the new partitions, for example:
/dev/nvme0n1p2
/dev/nvme2n1p2
Also confirm that the partition numbers match the paths you plan to use in the next steps. If the new partitions are not p2, adjust the commands accordingly.
Step 4: Create Physical Volumes
Create LVM physical volumes on the new partitions:
sudo pvcreate /dev/nvme0n1p2 /dev/nvme2n1p2
Verify them:
sudo pvs
Step 5: Extend the Volume Group
Add the new physical volumes to the existing volume group. Assuming the volume group is named vg_storage:
sudo vgextend vg_storage /dev/nvme0n1p2 /dev/nvme2n1p2
Check the additional free space:
sudo vgs
Step 6: Extend the Logical Volume
Extend the logical volume using all free space in the volume group:
sudo lvextend -l +100%FREE /dev/vg_storage/lv_storage
You can verify the new logical volume size with:
sudo lvs
Many systems also support resizing the filesystem at the same time with lvextend -r, but the separate resize step below keeps the process explicit.
Step 7: Resize the Filesystem
Resize the filesystem so it can use the newly added logical volume space.
For ext4:
sudo resize2fs /dev/vg_storage/lv_storage
For XFS, the filesystem must be mounted, and you resize by mount point rather than by block device. For example, if the logical volume is mounted at /mnt/storage:
sudo xfs_growfs /mnt/storage
Check the filesystem type if you are unsure:
lsblk -f
Finally, confirm the available space:
df -h
Complete Command Sequence
The exact command sequence depends on your device names, partition numbers, volume group, logical volume, and filesystem type. For the example used in this tutorial:
# Inspect current disks and LVM state
lsblk
sudo pvs
sudo vgs
sudo lvs
# Create new partitions on /dev/nvme0n1 and /dev/nvme2n1
echo -e "n\np\n\n\n+465G\nw" | sudo fdisk /dev/nvme0n1
echo -e "n\np\n\n\n+465G\nw" | sudo fdisk /dev/nvme2n1
# Re-read partition tables
sudo partprobe /dev/nvme0n1
sudo partprobe /dev/nvme2n1
# Verify the new partitions
lsblk
# Create physical volumes
sudo pvcreate /dev/nvme0n1p2 /dev/nvme2n1p2
# Extend the volume group
sudo vgextend vg_storage /dev/nvme0n1p2 /dev/nvme2n1p2
# Extend the logical volume
sudo lvextend -l +100%FREE /dev/vg_storage/lv_storage
# Resize an ext4 filesystem
sudo resize2fs /dev/vg_storage/lv_storage
# Verify the result
sudo pvs
sudo vgs
sudo lvs
df -h
This process extends an LVM-backed filesystem by adding new partitions as physical volumes, expanding the existing volume group, growing the logical volume, and resizing the filesystem to use the added capacity.
