Ever since my desktop broke down six months ago, I was without a Linux machine. Lately the urge to get back to Linux kicked in and immediately setting up a VM came to my mind. I had already used VirtualBox earlier so I got started and installed Linux Mint. During the installation I had setup the HDD size to be 8GB and dynamic which could grow if required. Within a week as Dropbox and Thunderbird sync started the free space came to zero very quickly. So I set on to find a way to increase the HDD size where Windows XP is setup as the host and Linux Mint is setup as the guest OS.
The process to re-size an existing VirtualBox hard disk for a Linux Guest OS is as follows:
-
Run the command vboxmanage as shown below, where “F:\VirtualBox\' is the directory where the vdi file exists and ‘Mint 12.vdi’ is the name of the vdi file. The re-size option takes the final size (in MB) of the disk after resizing (below I have set it to 15GB).
vboxmanage modifyhd "F:\VirtualBox\Mint 12.vdi" –-resize 15360
-
Download GParted Live CD ISO from http://sourceforge.net/projects/gparted/
-
Setup the ISO to load as a CD Drive in VirtualBox. (Goto Settings -> Storage -> Click on one the CD Drive -> Under Attributes click on the CD icon and select ‘Choose a Virtual CD/DVD Disk file’)
-
Start the VM machine and let it boot into GParted screen.
-
Once GParted is loaded, you should be able to see the unpartitioned size available along with the primary partition and the swap partition.
-
It is not possible to move the swap partition to the end of the partition table directly and use the free space for the primary partition, hence follow the below steps one by one.
-
Select the Extended partition which contains the swap partition and right click and choose ‘Resize/Move’.
-
In the Popup window, note down the size of the partition. I had the primary partition as 6.75GB, Extended Partition which held the swap at 1.25 GB and the unallocated space stood at 7GB.
-
Now drag the right edge of the partition to the very end, this would mean that the free space following would become zero. Click on ‘Resize/Move’ button and then click on Apply button.
Step Result: The extended partition size increased from 1.25 to 8.25GB, with 7GB unallocated space moving inside the extended partition.
-
Now select the swap partition and choose ‘Resize/Move’ option. Note the size of the partition. Drag the right edge of the partition to the end and then drag the left edge of the swap partition to bring it to the actual swap file size. Click on ‘Resize/Move’ and then Apply.
Step Result: The swap partition moved to the end of the partition table and unallocated space of 7GB moved to the left of the swap partition.
-
At this point, we are still unable to expand the primary partition to use up the free unallocated space, hence click on the extended partition again, choose ‘Resize / Move’, this time drag the left hand edge of the partition to be same size as the initally noted value, for me it was 1.25 GB. Click on Resize/Move button and then Apply. Step Result: The extended partition is now back to 1.25 GB and is again at the end of the partition table, with the unallocated space moving to the left of the extended partition.
-
Click on the primary partition and now drag the right edge of the partition to use up the free space. Click on the Resize/Move button and then click on Apply. Step Result: The primary partition increased to 13.75GB and there is no unallocated space left.
Though I would have loved to include screenshots, I had already followed the process before writing this. In case you run into issue or have an easier way of doing this do let me know using the comments section below.