26

I had created a Windows XP image disk. It is of 5 GB, but I would like to know if there is any simple way to increase the size to 20 GB.

6 Answers 6

26

As of VirtualBox 4.0.0, the VBoxManage command line tool offers a simple resize option:

VBoxManage modifyhd /path/to/vdi --resize <mbytes>

After the virtual disk container resize, boot into the VM and resize the partitions to make use of the extra space.

See also: VirtualBox manual, Chapter 8. VBoxManage: modifyhd

2
  • 1
    this could be updated as the new answer, I test it and is extreme simple.
    – mjsr
    Jun 7, 2011 at 19:28
  • 1
    Worth noting: this can only increase the size of vdi drives (not decrease), and only of dynamically sized drives.
    – Russ
    Sep 1, 2011 at 4:03
11

There is no simple way to do this that I'm aware of. There's no app that lets you just adjust a number to increase the hard drive size. However, there's a pretty easy tutorial on modhul.com that walks you through a process similar to what others have posted here.

Basically, you:

  • create new virtual disk with larger size
  • add that drive as a slave to your virtualbox
  • boot to gparted Live CD in virtual environment
  • use gparted to copy from old hd to new hd
  • mark new drive as bootable

One of the commenters on that article state that it took less than 15 minutes to go from 4GB to 10 GB, FWIW.

3
  • How do you make the drive bootable?
    – jon077
    May 25, 2011 at 13:15
  • Ahhh! Add the boot flag!
    – jon077
    May 25, 2011 at 13:19
  • Not 100% related, but for anybody looking for similar instructions, but the guest os is centos/fedora/etc with a LVM partition, the instructions won't work. BUT, some nice fella posted instructions in the comments of the above mentioned page: modhul.com/2008/10/21/… - the instructions worked for me
    – sdek
    May 27, 2011 at 16:05
2

Here are alternate methods using one of the many live cds available, both commercial and open source, with a disk/machine cloning tool. (clonezilla, ghost, etc.)

Network cloning

  1. Create a new virtual machine with a new empty disk. (20gb per your requirement)

  2. Boot the old virtual machine to the cloning livecd iso image. Set up old virtual machine as source for cloning.

  3. Boot the new virtual machine to the same livecd iso image. Set up new virtual machine as destination for cloning.

  4. Clone system over virtual network. (This takes longer than disk cloning but it is practice for physical network cloning.)

  5. Power off old virtual machine.

  6. Reboot new/cloned virtual machine.

This method can also be used between two physical machines, each running Virtualbox. Or from physical to virtual or vice versa. Or for transferring between Virtualbox and Vmware, Virtualpc, Vmfusion, Xen, Kvm or any virtual client that can boot to a cd or iso image. 5gb is a little heavy but with a good connection even cloning over the internet is possible. I do this for linux clients often but the larger virtual disks I use are only ~700mb (used space), takes less than a hour - setup time included.

or

Disk Cloning

  1. Create a new virtual machine with a new empty disk. (20gb per your requirement)

  2. Add the disk created from the new virtual machine to the old virtual machine to use as the clone destination. Boot old virtual machine to livecd iso image.

  3. Clone system on old virtual machine from the smaller disk to the larger disk.

  4. Power off the old virtual machine. Remove the new/cloned virtual disk from the old virtual machine.

  5. Start the new virtual machine.

These have the advantage of updating the virtual machine to the current version. (The virtual hardware and virtual machine file format may change with VM server updates. This may cause new drivers to be "discovered" in a cloned client from an older version or from a different VM server.) Installing/Updating the VirtualBox client tools should now give you a current virtual machine with a larger drive and you'll still have your original virtual machine unchanged. Just don't run both virtuals at the same time. There may be naming collisions and license issues with windows.

In the case of windows products for virtual clients you may need to re-activate the new virtual. I haven't run into that but I'd heard from others that they had to. I think it has to do with how many things are changed at a time during the clone. (memory, cpu(s), disk, etc.)

1

One solution that you could probably do fairly easily is to just make a new 20GB virtual disk and then boot your VM off of a rescue disk and dd the 5G onto the 20GB and then boot off the 20G.

1

You can't, but you can clone it to a larger virtual disk. It's nontrivial but if you need to do it see this link

1
  1. Create a new disk at the size you want.
  2. Connect the new disk to the original machine. You'll need to go into Windows disk manager to format the newly created disk so that windows can use it.
  3. Use Acronis EasyMigrate to clone your original disk to the new one.
  4. Close the Virtual Machine (once Acronis is done), detach the old drive, attach the new one (make sure you set it as IDE Master at this step).
  5. Boot using your new bigger, cloned, drive...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .