Increase CentOS7 Root Disk Size

One of my VMs filled up the root filesystem today so I had to remember how to fix it.

  • Shutdown the VM and increase the size of the disk image using VSphere or XenCenter or whatever.
  • Boot the VM off the CentOS ISO and choose the “Troubleshooting” then “Rescue a CentOS Linux system” options. Once it boots, choose the “Skip to shell” option to get to a prompt.
  • Recreate the partition:
    • Run fdisk /dev/xvda
    • Delete partition 2 and recreate it using the defaults. It should start at the same point as the original and end and the end of the disk now.
    • Write the new partitions and quit.
  • pvresize /dev/xvda to resize the PV
  • vgscan and vgchange -ay to update the mapper
  • lvresize -l +100%FREE /dev/centos_dev/root to resize the LV
  • xfs_repair /dev/mapper/centos_dev-root to check the FS
  • Reboot the machine then xfs_growfs dev/mapper/centos_dev-root
CentOS 
comments powered by Disqus