Jump to content
Toggle menu
  • 51 articles
  • 24 files
  • 4 users
  • 750 edits
Tech-Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Adding and extending disks/volumes in LVM

From Tech-Wiki


Extend an LVM-backed Linux filesystem by adding a new partition or disk to the existing volume group and logical volume.

!
Check the target disk and filesystem first
Partitioning and volume-management commands can destroy data if the wrong device is selected. Confirm the disk, volume group, logical volume and filesystem type before making changes, and ensure a recoverable backup exists.
✓
Prerequisites
  • Additional free disk capacity has been presented to the Linux host.
  • The target volume uses LVM.
  • The device and volume names used below are replaced with values from the target host.

Create the LVM partition

The original procedure uses fdisk and an LVM partition type of 8e.

>_Open the disk in fdisk
fdisk /dev/sdb

Within fdisk:

  1. Press p to print the partition table.
  2. Press n to create a new primary partition.
  3. Select the required partition number and accept the appropriate start/end sectors.
  4. Press t to change the partition type.
  5. Select the newly created partition.
  6. Set the partition type to 8e for Linux LVM.
  7. Press w to write the changes.

Create the physical volume

>_Create the physical volume
pvcreate /dev/sdb1

Verify the new physical volume and the existing volume groups:

>_Verify LVM state
pvs
vgdisplay

Extend the volume group

>_Add the new physical volume to the volume group
vgextend vg_root /dev/sdb1

The same approach can be used when spanning a volume group across an additional disk.

>_Check free space
vgs
pvscan

Extend the logical volume

Identify the logical-volume path and available capacity:

>_Review volume group and logical volume
vgdisplay
lvdisplay

Extend by a fixed amount:

>_Add 100 GB
lvextend -L +100G /dev/vg_root/vol1

Or use all remaining free extents:

>_Use all free space
lvextend -l +100%FREE /dev/vg_root/vol1

Grow the filesystem

The original article uses resize2fs:

>_Resize the filesystem
resize2fs /dev/vg_root/vol1
ⓘ
Filesystem-specific step
Use the filesystem resize command appropriate to the filesystem on the target logical volume. The command above is the method retained from the original article.

Verify

>_Review the final LVM size
vgdisplay
lvdisplay

See also