Resize CentOS LVM

February 09, 2020

I always have to look up how to do this, but I’d much rather use my own, known working, walkthrough than find the right things on StackExchange.

Extend Partition

fdisk /dev/sda

p # Print table
d # Delete
2 # Deletes second partition, since partition 1 is usually boot
n # New partition
p # New Primary Partition
2 # New Primary Partition #2
Accept Start Block and End Block
t # Partition Type
2 # Partition 2
8e # Change partition type to "Linux LVM"
p # Print new partition table
w # Write New Partition table

Update Kernel In-Memory Partition Table

Instead of rebooting, you can run the following command

partx -u /dev/sda

Resize Physical Volume

pvresize /dev/sda2

Resize Logical Volume and Filesystem

You can get the names of these by running pvs and lvs respectively.

lvextend -r centos_centos/root /dev/sda2