Friday, April 29, 2011

Increasing disk size for virtualbox running Ubuntu

Yes, I am running Ubuntu in a VirtualBox, and have been refusing to upgrade to version 10.10 or even version 11, since I have no compelling reasons to do so (actually, I have good reason not to do so). However, end of last week, I hit to an issue with MySQL - a limitation that I will write in another blog entry.

Anyway, I did run out of disk space on my virtualbox guest. Came across a few web entries that discussed on how to overcome it, but most of them are applicable to Windows guest virtualbox setup.

Here are some of my attempts that didn't work out that well, and possible reasons:

1. Used Clonezilla

Use Clonezilla to back up the old VM and restore it into the new expanded disk.

Yup, I boot up my old version of Ubuntu using Clonezilla LiveCD and make a clone copy. Then boot up my new empty virtual image using Clonezilla LiveCD and tried to restore the image to the expanded disk image.

I was able to backup image of old Ubuntu VM, and managed to restore the image to the expanded VM volume, but when I boot up, it was not able to start up. This is due to GRUB loader. During the restoration of image, I briefly saw a message that there could be an issue since they detected GRUB and was not able to change to root to change some settings... I guess.

Failed (you might have better luck than me)

2. Use GPart 


Create an empty (larger diskspace disk) virtual disk using VirtualBox Virtual Media Manager. Attached the larger virtual disk to the SATA port 1 (the old smaller virtual disk on SATA port 0). Mount GPart LiveCD  and boot from it. Copy the old disk (/sda1) to the new disk (/sdb). Mark the new disk as bootable. Reboot with the new disk as primary (might also want to unmount the old disk).

No problem with the copy and paste using GPart. No problem with the flag "boot" for the new disk. Just didn't boot after when switch to primary boot disk!

Unknown. Still figuring it out.

Here is what worked for me.


I have the following:

1. Oracle VirtualBox 3.2.12 r68302
2. Ubuntu 9.10.2 (8 GB HD)

What I want to do is to add more hard disk space (increase to 16 GB HD).


1. Create a virtual disk of larger size
  •  Through Oracle VirtualBox GUI, select File > Virtual Media Manager > Actions > New
  • Fill up the 'Create New Virtual Disk' form
2. Open a command prompt and do:

C:\Documents and Settings\user\.VirtualBox\HardDisks>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd "MyFirstSmallerDisk.vdi" "MyLargerSecondDisk.vdi" --existing

Oracle VM VirtualBox Command Line Management Interface Version 3.2.12
(C) 2005-2010 Oracle Corporation
All rights reserved.

Clone hard disk created in format 'VDI'. UUID: 2fe48578-ade7-48fa-873b-2245714074f5

(some of the information are scrumbled and replaced, especially those in blue. Replace the name of the vdi files appropriately)

This will clone the smaller virtual disk to the larger one.

3. Create a new VM through the Oracle VirtualBox GUI, select Machine > New
  • Enter a new name for this VM (e.g. "MyLargerSecondVM")
  • Choose Linux, Ubuntu for OS Type
  • Enter the memory size
  • Check "Boot Hard Disk" and select "Use existing hard disk" > "MyLargerSecondDisk.vdi"
4. Reboot the new VM ("MyLargerSecondVM") to see that things are still bootable and in order, but do note that the primary partition is still the same and has not been modified. The extra disk space has not been allocated yet.

5. Shutdown the VM after everything looks fine. Back up the VMs.
  • I copied all the files under "C:\Documents and Settings\user\.VirtualBox" to another secondary storage.

It is now time to resize the partition to fill up the entire new virtual disk.

6. Ensure that the boot order for the new VM ("MyLargerSecondVM") is (CD/DVD-ROM, Floppy, Hard disk) via Setting > System > Motherboard

7. Ensure that the GPart LiveCD is mounted. Setting > Storage > IDE Controller > CD/DVD Device > [select the gpart iso file, e.g. gparted-live-0.8.0-5.iso]

8. Reboot the VM ("MyLargerSecondVM")

9. Enlarge the primary boot partition. You might need to move the swap partition to the end of the disk before enlarging the primary boot partition. I did the changes in a series of small steps rather than applying all changes at one go. I actually hit to a slight problem initially if I will to consolidate all my steps.

10. Once the swap partition is moved to the end, and primary partition has been enlarged successfully, quit GPart and reboot. Remember to unmount the GPart LiveCD through Setting > Storage > IDE Controller > CD/DVD Device > [Select "Empty"]

11. Reboot "MyLargerSecondVM" and login. You can check that you have more disk space now. e.g.

% cd /
% df -k .

Good luck.

Thursday, April 28, 2011

A father's chronicle (A song which still touches my heart)

Four years back, I blog on my kids' school orientation. The song was 'In whom I can trust'.

I want to include here two other clips which I found on this song. Yes, one of them is also filmed in Presbyterian Primary school.

This is the other clip that I came across which is taken one year after my son went into Pei Hwa. I guess, my son must be one of those singing it again....

I cannot underestimate the importance of immersing my kids into such environment, though I do hope that there are even more being done to showcase christian leadership in the school environment.

A little sober warning (Matthew 18:6):

But if anyone causes one of these little ones who believe in me to sin, it would be better for him to have a large millstone hung around his neck and to be drowned in the depths of the sea.

Let those who handle the lives of these little ones be careful and not do anything that might stumble them.