Run lsblk
to confirm that the disk is correctly sized
Check the filesystem type with file -s /dev/sdX
where X
is the letter of the disk
Run sudo growpart /dev/sdX 1
where X
is the letter of the disk and 1
is the number of the partition - this grows the partition size
NOTE: If you're working with an NVMe disk, run lsblk
and find the partition holding the parition you need to expand.
Example partition: nvme0n1p1
Run sudo growpart /dev/nvme0n1 1
. If the partition were nvme0n1p2
, you'd run sudo growpart /dev/nvme0n1 2
First and foremost, resizing logical volumes can be tricky, so be careful. Run sudo pvdisplay
to show the physical volumes. Find the physical volume that has extra "Free PE". Usually > 2. For the sake of this example, we'll say the Physical Volume is /dev/sda2. Run sudo pvresize /dev/sda2. Run sudo vgdisplay. Find the volume group with "Free PE". For the sake of this example, we'll say the Volume Group is centos_volume. This should match roughly the amount of disk space you added. Run sudo vgextend . Example: sudo vgextend centos_volume /dev/sda2. Run sudo lvdisplay. This is where things get a little more complicated:
If all partitions are contained in the same Volume Group, run sudo lvextend -L +<size to increase by> /dev/<VG>/<LV>
. For this example, the Logical Volume is centos_lv
and we're increasing it to 50GB. sudo lvextend -L 50G /dev/centos_volume/centos_lv
.
If there are multiple volume groups, find the logical volume in the volume group you expanded earlier. If you increased the wrong VG, it's easier to cut your losses and add more disk space again. Once you know which VG you're working with, run sudo lvdisplay
and find the Logical Volume you want to extend. Make sure it uses the Volume Group you expect it to. From there, run sudo lvextend -L +<size to increase by> /dev/<VG>/<LV>
like in the example above.
Run sudo xfs_growfs -d /mntpoint
where /mntpoint
is the mountpoint of the partition
Run sudo e2fsck -f /dev/xvdX1
where X
is the disk letter and 1
is the partition number
Run sudo resize2fs /dev/sdX1
where X
is the disk letter and 1
is the partition number