How to extend the size of a logical volume by expanding the OS disk on CentOS / RHEL

There are two options:

  • Delete and recreate /dev/sda2 partition
  • Create a new partition /dev/sda3

Delete and recreate /dev/sda2 partition 10 steps

  1. Extend disk with vSphere Client or using CLI

  2. Make snapshot

  3. Rescan the disk

echo 1 > /sys/block/sda/device/rescan

  1. Check the new size of the disk

fdisk -l /dev/sda or lsblk

  1. Delete the partition (/dev/sda2) and recreate it with the new size
fdisk /dev/sda
c
u
d
2
n
p
2
enter
enter
t
2
8e
p
w
  1. Reboot the server, partprobe or kpartx -v -a /dev/sda will not work since the disk is in use

  2. Check the new partition

cat /proc/partitions | grep sda2

  1. Resize the LVM disk

pvresize /dev/sda2

pvs

  1. Extend the logical volume

lvextend -L +<Size> /dev/<vg_name>/<lv_name>

lvs

  1. Extend the file system
  • ext3/4: resize2fs /dev/<vg_name>/<lv_name>
  • xfs: xfs_growfs /dev/<vg_name>/<lv_name>

df -f <filesystem>