Resize logical volume to occupy all space

Published on September 30, 2021 at 12:57:30 AM GMT+8 by Administrator

Steps to resize logical volume to occupy all available spaces


Resize logical volume to occupy all space

Resize root logical volume to occupy all space

Resize the physical volume

$ sudo pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

$ sudo pvs
  PV         VG   Fmt  Attr PSize   PFree 
  /dev/sda2  rhel lvm2 a--  <39.00g 10.00g


Check the size of the volume group configured.

$ sudo vgs
   VG      #PV #LV #SN Attr   VSize   VFree 
   centos   1   2   0 wz--n- <39.00g 10.00g


Then resize logical volume used by the root file system using the extended volume group:

lvextend -r -l +100%FREE /dev/[nameOfVolumeGroup]/root

EXAMPLE:
lvextend -r -l +100%FREE /dev/centos/root