Resizing root partition on CentOS 6 in the cloud

If your unfortunate enough to still be using CentOS 6 in AWS than more than likely be stumped why the root partition isn’t resizing like most other distros you launch.

TL;DR

yum install cloud-utils-growpart
growpart /dev/xdva 
reboot now

The why and how

Usually if you launch an EC2 instance and increase the root EBS volume’s storage capacity, the root partition and filesystem on it will automatically expand to fill the disk. This happens via cloud-init, namely the growpart and resizefs modules. At first I had just thought that they were disabled on CentOS 6 as I have seen them missing from /etc/cloud/cloud.cfg. Using a #cloud-config user-data populated with the modules and configuration to drive them did help.

I came across an issue raised against CentOS 7, which was a similar problem. Both distros were missing cloud-utils-growpart. There were some instructions there on how to fix it but I found a better write up here.

An important caveat is that online resizing of the partition is not supported in the old old kernel that makes up CentOS 6. So after resizing the partition you’ll need to restart (or wait until after the AMI bakes and the new EC2 instance starts up is fine).

Comments