Automated Growroot for EL7
When deploying RHEL instances to services like AWS, one typically uses an template with a default partitioning-scheme (or, no partitioning at all). Because of the vintage of the EL6 kernel, it used to be necessary to include the dracut-modules-growroot RPM from EPEL into to template.
I'd assumed that the same functionality was built into RHEL 7. I'd made this assumption since the RHEL 7 kernel has better support for re-writing live partition-tables and since there doesn't appear to be an equivalent RPM in the EPEL 7 repositories. However, when I launch my RHEL 7 AMIs and specify a larger-than-default size for the boot disk, it's not automagically picked up by the OS. While I can live-repartition the boot drive with the standard dracut modules, I get the dreaded:
Error: Partition(s) 2 on /dev/xvda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
From partprobe when I attempt to make the space available. If I want the space to be usable, I need to reboot.
I dug through the stock dracut RPMs' modules, and I'm not seeing one that attempts a growroot operation. Before I muck about with trying to port the functionality from the EPEL 6 RPM to an RHEL 7 RPM, is there RHEL 7-native functionality that I'm overlooking?
Responses
Looks like the cloud-init RPM updates in 7.4.1708 included the requisite fixes to its growpart functionality. If I add:
growpart:
mode: auto
devices: ['/dev/xvda2']
ignore_growroot_disabled: false
To my AMIs' instance-launches, the resulting instance's LVM2 now sees the space without having to inject a reboot prior to pvresize and lvresize working properly. This means I can add something like:
runcmd:
- pvresize /dev/xvda2
- lvresize -r -L 10G VolGroup00/rootVol
- lvresize -r -L +2G VolGroup00/varVol
- lvresize -r -l +100%FREE VolGroup00/auditVol
to my UserData ahead of my app-installations. I'll probably need to see whether cfn-bootstrapper can do this too, or if I have to leave storage relayout tasks in UserData.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
