Growing the file system of a default Centos 7 install

If you’re deploying a RHEL VM image and need to resize it, there are two options:

  • Add an additional disk add incorporate it as a LVM physical volume
  • Extend the current physical volume and grow the PV and LV

I’m usually going for the second one in my test setup – these are the steps:

  1. Power off the VM.
  2. Increase the size of the disk.
  3. Power on and run disk, removing the current LVM partition and recreating it to expand it to the new size (in my test setup, this is /dev/sda and the second partition, /dev/sda2).
  4. Reboot again, in order to make the kernel pickup on the new partitioning.
  5. Resize the physical volume: pvresize /dev/sda2
  6. Verify the new size with pvdisplay
  7. Grow the logical volume by adding all the available space:
    lvresize -l +100%FREE /dev/centos/root
  8. Finally, grow the actual root partition – no need to reboot:
    xfs_growfs /


Publicerat

i

av

Etiketter: