I have several VM's in an OpenStack cluster (KVM) and when they get built from an image that had say a single 5GB partition they too will have this same HDD geometry configured. I've found several methods to resize them from the actual OpenStack hosts, but I'd like to be able to resize them from within the VM's as well, just so I have that method available too.
One approach would be to use fdisk
to delete and then recreate & write out the partition metadata, then do a reboot and a resizefs after booting back into the VM. When I recently tried this though it didn't work as expected. Resulting in a VM that is hanging at a GRUB prompt. This is a CentOS 6.7 VM so the bootloader is GRUB legacy.
What are my options here to get a filesystem on this VM? I suspect I could use virtmanager to gain access to the VM and then expose a LiveCD ISO at it so that I can "boot" it with that and then get a filesystem associated but is there a more direct way to recover access and boot this VM?
Best Answer
So my issue was with how I was doing the deletion and recreation of the partition. I was getting tripped up by
fdisk
and the fact that it was showing the starting location not in sectors. When I properly invokedfdisk
like so:It was pretty obvious that I was not keeping the starting sector aligned when I created the new partition.
From fdisk's usage guidance:
So simply paying special attention to this detail, and I was able to do the following process to extend my VM's partition using all of the available HDD space.
Process for resizing
To delete the existing partition:
Now add the new one:
Make it bootable:
And confirm all this:
Commit it to the HDD:
Now reboot the system and do a resize2fs if needed:
And confirm: