Powered By Blogger

Tuesday, February 27, 2024

Extend LV in AWS EC2


One of our disk configured with LVM is running out of disk space , we need to increase disk space without downtime. 

LVM stands for logical volume manager which allows to add raw disk to volume group and attached to logical volume.
In Practical it will be different hard drive but under volume group and logical volume treated as same . 

Please follow the instructions   to extend LVM

Create EBS Volume and attach the same to instance 

$lsblk
Find the latest disk name

$ sudo gdisk /dev/<DiskName>
Command (? for help): n
Partition number (1-1218, default 1): 1
First sector (34-20971486, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-20971486, default = 20971486) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00        
Changed type of partition to 'Linux LVM'
...
OK; writing new GUID partition table (GPT) to /dev/xvdh.
The operation has completed successfully.

Above will create disk parition with LVM standard, Now Create PV

##Create PV

sudo pvcreate /dev/xvdh1
  Physical volume "/dev/xvdh1" successfully created.
 
##Attach PV to existig VG

$vgextend vgroup1 /dev/nvme3n1p1
$vgs

##Extend LV
$lvextend -L +512G /dev/vgroup1/lvgroup1 /dev/nvme3n1p1
$resize2fs /dev/mapper/vgroup1-lvgroup1 
$xfs_growfs /dev/mapper/vgroup1-lvgroup1
$df -h