Pages

Sunday, June 9, 2013

Changing the Virtualbox virtual machine(VM) disk size


After struggling for a few hours, I finally found one article and a little bit luck to solve this issue. I wanted to resize VM disk size from 8 GB to 25 GB. I was successfully able to either create a new disk and attach it separately or make it as primary but effect was not being reflected inside the machine.

Anyway, I am running Windows 7 on my host machine and Ubuntu 32-bit on my guest machine (VM). I guess, same will be true for any guest (Windows 7, XP etc.) machine.

Step 1:

Go to command prompt and navigate to the virtualbox installation folder. On my machine, it's installed at 'C:\Program Files\Oracle\VirtualBox\'. You should be able to see 'VBoxManage.exe' at this location.

Step 2:

Run following command to resize your VM disk.

> VBoxManage modifyhd "C:\Users\junaid\VirtualBox VMs\UbuntuForEverything\UbuntuForEverything.vdi" --resize 25000

Now after it, disk virtual size is changed to 25 GB but actual size remains the same. Story starts from here.

Step 3:

Make a clone of your disk with following command.

C:\Program Files\Oracle\VirtualBox> VBoxManage clonehd "C:\Users\junaid\VirtualBox VMs\UbuntuForEverything\UbuntuForEverything.vdi" "C:\Users\junaid\VirtualBox V
Ms\UbuntuForEverything\Ubuntu25GB.vdi"

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

So my new clone disk name is Ubuntu25GB.vdi which contains the same data.

Step 4:

Download GParted iso file from here.


Step 5:

5.1)   Go to Settings => Storage => Controller:SATA. and detach existing disk and attach Ubuntu25GB.vdi as a new disk.

5.2) Go to Settings => Storage => Controller:IDE and add a CD/DVD device(GParted.iso downloaded in step 4) as shown below.



 5.3) Go to Settings => System and uncheck the 'Hard disk' option as we want to load the system from iso file of step 5.2. In following picture, this option is selected, you have to deselect it. Click ok and start your machine.


Step 6:

6.1)  You will see following screen. Press Enter



6.2)  Press Enter


6.3)  For language, type 33 for US English and keep pressing Enter until you see following screen.



6.4)  As given in the above picture, I have 8 GB used space and almost 16 GB unallocated space. But if you see two rows in between these two disks, there are sda2 and sda5 disks. It was not allowing me to resize my 8 GB disk, so I deleted these two disks. If you see the similar type screen, first delete the child disk (sda5 here) and then parent one (sda2 here)

6.5)  After the deletion, it should look like this.


6.6)  Select the 8 GB disk and do right click. Select Resize/Move option as shown below.



6.7)  Drag the right side of the box such that it is expanded from

 
to



6.8)  You will see following screen.



6.9)  Don't forget the 'Apply' button. It will take some time to save changes.

Step 7:

Now do the opposite of step 5.2 and 5.3. We want to load from hard-disk under System settings and from Ubuntu25GB under Storage settings.

Once logged into Ubuntu, run Disk Analyzer from settings to confirm the disk size.