DEV Community

Arun Kumar for AWS Community Builders

Posted on

1 1

How to increase/decrease FileSystem under LVM

Steps

a. Before starting, ensure the following packages are installed

e2fsprogs
lvm2
Enter fullscreen mode Exit fullscreen mode

b. Run pvdisplay to check which EBS is under LVM.

sudo pvdisplay
Enter fullscreen mode Exit fullscreen mode

c. Run vgdisplay to check unallocated space available for a volume group

sudo vgdisplay
Enter fullscreen mode Exit fullscreen mode

d. Find the lvm fs that you want to increase/decrease.

sudo lvscan
Enter fullscreen mode Exit fullscreen mode

e. Example: Increase vol17 size from 5Gb to 15Gb

>>lvextend -L15G /dev/vgs1/vol17 --resizefs
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

h. Resize the physical volumes using the pvresize command.

pvresize /dev/xvdg1
Enter fullscreen mode Exit fullscreen mode

i. Use vgdisplay to see the increased free size. To see what fs type that the LVM fs is run,

lsblk -f
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

ii. If doing pvdisplay shows an unknown physical volume, then run command

vgreduce — removemissing <VG NAME>
Enter fullscreen mode Exit fullscreen mode

k. To increase swap space under LVM, do the following

>>swapoff -v /dev/vgs1/vol54swap
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

[https://superuser.com/questions/1250895/converting-between-gpt-and-mbr-hard-drive-without-losing-data]

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Best Practices for Running  Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK cover image

Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK

This post discusses the process of migrating a growing WordPress eShop business to AWS using AWS CDK for an easily scalable, high availability architecture. The detailed structure encompasses several pillars: Compute, Storage, Database, Cache, CDN, DNS, Security, and Backup.

Read full post

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay