I’ve been using VirtualBox pretty happily for the past couple of months on my commodity Windows laptop, but recently made a pretty unpleasant discovery. The install wizard had some poor wording in regards to setting up hard drives. They encourage a very small drive (8gb on my machine), and the installer says that it’s dynamic. Unfortunately this doesn’t mean that the drive grows as needed. It got to where I couldn’t pull from the git repo I was working on.
After much frustration, I managed to increase the size of my guest Ubuntu VBox drive. This is what I did. (If you have saved snapshots of your partition see this before continuing!)
On the Windows host system, find the VBoxManage.exe file and the .vdi file that is your virtual linux HD. Run VBoxManage with the following params: modifyhd (path_to_your.vdi) –resize (size in MB).
This is what my command looked like:
c:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd "C:\Users\LMason\VirtualBox VMs\ubuntu\ubuntu.vdi" --resize 32768
To the best of my knowledge, Ubuntu lacks a built in tool to resize its partitions. For this, I downloaded the latest ISO of GParted, then shut down my Ubuntu machine went into its Vbox Settings->Storage, added an IDE controller and loaded it with the gparted-live.iso, and checked the live CD/DVD box.
Then I restarted the Ubuntu box and it booted to GParted. I saw a display with my main partition on the left, my swap partition next to it, and a huge unpartitioned block to the right. At first, it still wasn’t clear how to increase the size of either partition. When I selected a partition and clicked resize, the increase arrows were grayed out and I could only decrease the size of the partitions. After a while, I discovered that in GParted, a light blue border around a partition means that it can’t be moved and that no other partition next to it may grow in its direction.
The key is to delete the swap partition first. After that, I was able to move it’s container to the far right end of the unpartitioned area, set the size I wanted for it and then create a swap partition inside it. Then with nothing next to the main partition, it was able to grow to take up the full space available.