[HOWTO] Increase Ubuntu VM disk size

Status
Not open for further replies.

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
I've been testing the VM support in 11-RC, and I just tested how to grow the VMs disk successfully, so I thoughht I'd document it.

Firstly, I've created a bootable Ubuntu 16.04.2 install according to this post

https://forums.freenas.org/index.php?threads/how-to-how-to-boot-linux-vms-using-uefi.54039/

You basically boot off CD, then install ubuntu. Then fix up the bootloader. One of the issues you'll find is that the VM won't stop when its time to remove the CD, you can stop the VM with (bug #23975)

bhyvectl --force-poweroff --vm=<vm name>

Anyway, I create a 10GiB sparse Zvol when I installed Ubuntu. I then fixed the bootability, and ran all the updates and installed SSHD, and fixed the poweroff 'bug'. BTW, that adds about a GiB to the original clone I had.

Now I only have a handful of GiB free on the image. Which is not a helluva lot, so since I'm planning on spinning up various VMs, and basing those on a cloned zvol for disk efficiency reasons, I wanted to test resizing.

So, its very easy.

1) For safety reasons, clone your zvol by taking a snapshot, and cloning the snapshot. If the worst happens, you can just go back.
2) edit the zvol and increase its size to your desired size, in my case, 20GiB.
3) make sure the vm is stopped, then edit the disk, point it to the new zvol, and then add the CD and point it to your ubuntu 16.04.2 iso
4) start the VM, connect to VNC, and selete "Try Ubuntu"
5) when Ubuntu Live finishes booting, you can use these instructions to resize your partitions, but briefly, open "gparted" (by searching for it). It should offer to "fix" the partitions, do so, then you should see your extra space. Swapoff the swap, then move the swap to the end of the disk, then resize the main partition to use all the space, then apply the changes to the disk, and exit, and shutdown.
6) you might need to force-poweroff the vm again. bhyvectl --force-poweroff --vm=<vm name>
7) remove the CD, and you're done :)

Resizing the cloned zvol only added 2MB when I tested. Neat.

If you're happy, you could remove your original zvol...
 
Last edited:
Status
Not open for further replies.
Top