Steps
a. Before starting, ensure the following packages are installed
e2fsprogs
lvm2
b. Run pvdisplay to check which EBS is under LVM.
sudo pvdisplay
c. Run vgdisplay to check unallocated space available for a volume group
sudo vgdisplay
d. Find the lvm fs that you want to increase/decrease.
sudo lvscan
e. Example: Increase vol17 size from 5Gb to 15Gb
>>lvextend -L15G /dev/vgs1/vol17 --resizefs
f. Example: Reduce vol17 size from 5Gb to 1Gb ( you can only do this if no process is holding to the fs. Best is to unmount the fs)
- Important to ensure package e2fsprogs is installed, else the below command can cause superblock/partition table corruption.
>>lvreduce -L1G /dev/vgs1/vol17 --resizefs
g. If the EBS is resized, then need to do the following, example /dev/xvdg was resize from 950Gb to 1150Gb
lsblk
> growpart /dev/xvdg 1
h. Resize the physical volumes using the pvresize command.
pvresize /dev/xvdg1
i. Use vgdisplay to see the increased free size. To see what fs type that the LVM fs is run,
lsblk -f
j.
i. If you are restoring an EBS snapshot with LVM, after mounting the restored EBS volume, then you need to do the below.
sudo yum install lvm2 (if lvm command not found )
sudo vgchange -ay
ii. If doing pvdisplay shows an unknown physical volume, then run command
vgreduce — removemissing <VG NAME>
k. To increase swap space under LVM, do the following
>>swapoff -v /dev/vgs1/vol54swap
Disable the vol that contain the swap, might need to stop appls if swap is in-use and free memory not available.
>>lvextend -L32G /dev/vgs1/vol54swap
>>mkswap /dev/vgs1/vol54swap
>>swapon -va
>>cat /proc/swaps
l. If the disk increased is greater than 2Tb and is using MBR partition type, you need to convert to GPT partition type.
gdisk /dev/nvme1n1
Top comments (0)