Expanding Stackato VM's root partition on vSphere

Posted by troyt on 2013-11-26 13:31
OS: All / Any | Product: Stackato | tags: admin filesystem stackato vsphere

How do I expand the root partition of a Stackato VM running in vSphere?

  1. Stop the VM that is being resized.
  2. Edit VM settings in vSphere client (Right Click -> Edit Settings)
  3. Select Hard Disk and adjust Provisioned Size to desired size

The VM will need to have this additional space allocated to the right partition. This can be done with partitioning software such as GParted Live CD.

These instructions are GParted specific:

  1. Download GParted LiveCD and make it available to the Stackato machine by uploading it to the Datastore
  2. Right click the VM to resize and Edit Settings. Choose 'CD/DVD drive' and select 'Datastore ISO File' for Device Type.
  3. Click 'Browse' and select the GParted LiveCD image that was uploaded.
  4. Click 'Options' in the Edit Settings interface, select 'Boot Options' under 'Advanced'. Check the 'Force BIOS Setup' box. Click 'OK'.
  5. Open a console for the VM and start it. In the BIOS, navigate to the 'Boot' tab and adjust the Boot Order such that CD-ROM Drive is at the top of the list. Save this change and exit. This will reboot the system.
  6. Boot into GParted Live. Select 'Don't touch keymap' and whatever language setting you prefer.
  7. Once GParted boots you'll see a list of all discs used by the machine. In the graphical display of the size of the discs you should see a grey block at the end which is marked 'Unallocated'.
  8. Right click on the device you'd like to resize (by default it should be /dev/sda2) and select 'Resize/Move'
  9. Click on the side of the bar representing the disc and drag it over the 'unallocated' disc space so that 'Free space following(MiB)' shows 0.
  10. Click the 'Resize/Move' button. This may take some time depending on write speeds and the amount of space being allocated.

Once the process finishes (a popup should indicate that the process completed successfully), double click on the 'exit' button and shutdown the VM. After the VM is stopped you should unmount the GParted disc in the Edit Settings window. After you do that you can restart the machine and the additional space should be available.

matthewf | Tue, 2013-11-26 16:28

Note that this was done using Virtualbox, but the hypervisor should not matter in any case.

To resize the disk in Virtualbox, hop into your favourite terminal emulator, change directories to your stackato VM folder (~/VirtualBox\ VMs/Stackato-880-v2.10.6/ by default for v2.10.6) and run:

    $ VBoxManage clonehd <some long name>.vmdk cloned.vdi --format vdi
    $ VBoxManage modifyhd cloned.vdi --resize <some new size in MB>
    $ VBoxManage clonehd cloned.vdi resized.vmdk --format vmdk

Then head back into the VirtualBox settings to swap the hard drive from the old one to the resized version.

Now, onto the cfdisk tutorial!

1. Boot into the VM with a liveCD of your choice (I'm using the Ubuntu liveCD in this example, but any liveCD with cfdisk will do), then run the following:

$ sudo cfdisk /dev/sda

2. Delete both the swap partition and /dev/sda2, which is the partition mounted to root
3. Create a new primary partition from all of the free space available, saving a bit of space left for the swap drive (about 2GB)
4. create the swap partition
5. press SHIFT + W to write to disk
6. press 'q' to quit
7. reboot the virtual machine, and boot to your hard drive.

When you reboot into the VM, you should see that /dev/sda3 now has more space than it used to have. Enjoy!