I love virtual box! In a matter of just a few days, I've had Fedora, Ubuntu, Open Suse, Mandriva, Free BSD and Mac OS X installed on every one of my machines! Yes, even Mac OS. And I'm running out of space fast on these virtual disks.
Here's how I increase the size of the virtual disk for my Fedora on virtual box, from 8G to 40G.
0, Make a copy of your old VDI, just in case.
1, Create a new VDI with a bigger size, 40G.
2, Download Fedora live CD image. Alternatively, you may get a GParted Live CD image, if your virtual disk is not in LVM (Logical Volume Manager) format.
3, Create a new virtual machine on virtual box. I called mine "resize-vm". Attach the Fedora live CD, your old and new VDIs to it.
4, Boot your new virtual machine "resize-vm".
5, Open a terminal, become root by "su", then copy the old disk to new disk by "dd if=/dev/sda of=/dev/sdb".
6, Shut down "resize-vm".
7, Edit the original "Fedora" virtual machine, remove the old VDI, attach the new VDI. Boot "Fedora".
8, Go to Fedora menu "Applications/System Tools/Disk Utility", create a physical volume from the unallocated space, I named it "extra". Note down the device name, which is "/dev/sda3" in my case.
9, Open a terminal, become root by "su", then run "pvcreate /dev/sda3". This way, we created a new physical volume.
10, Run "vgdisplay", find out the name of the volume group, "VolGroup".
11, Run "vgextend VolGroup /dev/sda3" to add the newly create physical volume.
12, Run "vgdisplay" again, you will see "Free PE / Size" has been increased, in my case, it's now "8191 / 32.00 GB".
13, Run "df -kh", locate your old logical volume name, which is "/dev/mapper/VolGroup-lv_root".
14, Run "lvextend -L32G /dev/mapper/VolGroup-lv_root".
15, Shut down "Fedora". Boot "resize-vm", become root by "su".
16, Run "e2fsck -f /dev/mapper/VolGroup-lv_root".
17, Run "resize2fs /dev/mapper/VolGroup-lv_root".
18, Shut down "resize-vm". Boot "Fedora" with the new enlarged VDI.
19, Done!! Delete the old backup VDI if you want to save some disk space on your host machine.