Read more

How to enlarge a VirtualBox VDI disk file

Arne Hartherz
July 15, 2011Software engineer at makandra GmbH

VirtualBox does not offer anything for this task -- you need to do it yourself. It's not that hard:

Get more disk space

  1. Add an extra virtual hard disk to the machine with the disk size you want to achieve.
  2. Get a Linux live CD (like the Ubuntu live image) that offers fdisk, dd and gParted.
  3. Boot the guest from the CD, open a terminal (on the guest, not the host!) and become root: sudo su
  4. fdisk -l to see the disk information. \
    There should be one drive with some partitions and one without any. The first is the source (e.g. /dev/sda), the latter your target for cloning (e.g. /dev/sdb).
  5. Clone the drive content with dd:
    dd if=/dev/sda of=/dev/sdb bs=1024000
    This will copy any content from your source to the target. Be careful to not use the wrong device names, dd does not ask for confirmation! The bs parameter sets the block size and may increase transfer speed. If you are curious about dd's progress, check the corresponding note.

Expand partition

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Now your virtual drive has more space but the partition is still of the same size. You probably also want to enlarge it as well (these step are especially useful for Windows guests as they cannot resize their system partition themselves):

  1. Shutdown the virtual machine, disconnect the old drive, boot the live CD again. If you do not restart after cloning, gParted will be confused by the disk layout.
  2. Start gParted (on Ubuntu: System → Administration) and resize the partition on the target drive to its full size.
  3. Shutdown the VM, remove the live CD and boot up your guest system.

This should be it. Windows will notice the drive change and run CHKDSK on its next boot but should come up fine afterwards.


As always: Have a backup of important data before doing such things.

Posted by Arne Hartherz to makandra dev (2011-07-15 14:57)