Skip to main content

Extend Logical Volume

How to extend LVM volume to use free space

  • Create a Partition: If the free space is not yet partitioned, you'll need to create a partition. You can use tools like fdisk or parted for this purpose.
  • Initialize the Partition as a Physical Volume (PV): Once you have a partition, you need to initialize it as a Physical Volume for LVM. Use the pvcreate command for this.
pvcreate /dev/sdXY
  • Extend Volume Group (VG): Add the newly created Physical Volume to your Volume Group. You can use the vgextend command for this.
vgextend <VolumeGroupName> /dev/sdXY
  • Extend Logical Volume (LV): Finally, extend your Logical Volume to use the available space in the Volume Group. You can use the lvextend command for this.
lvextend -l +100%FREE /dev/<VolumeGroupName>/<LogicalVolumeName>
  • Resize the File System: After extending the Logical Volume, you need to resize the file system to make use of the added space. The command to resize the file system depends on the file system type. For ext4, you can use resize2fs. For XFS, you can use xfs_growfs.
resize2fs /dev/<VolumeGroupName>/<LogicalVolumeName>