Recently, the box that I was using to try out Ansible ran out of memory. Resizing the disk turned out to be a bit of a pain.
First problem, we were using VMDK format for the virtual hard disk. This format cannot be resized. You would have to convert it into an expandable VDI format. But since root file system was on this drive, we could not take the risk of running resizing the file system on the drive. Hence we created a new virtual hard disk in the VDI format and attached it to the VM.
Once that was done, we had to just expand the logical volume on which / was mounted. On a high level, we had to
- Run fdisk on the drive and create a primary volume with an LVM label
- Add the newly created physical volume to the Volume group
- lvextend the root partition
Once this was done, we repackaged the box and normal services were returned.