42

Is there an easy way to increase virtual hard disk space on VirtualBox?

54

There is not an easy way to do this.

There is a complicated one, though:

http://www.my-guides.net/en/content/view/122/26/

Has a good screenshot-by-screenshot guide. Essentially you're copying your install onto a new virtual-disk file.

Update: As of VirtualBox 4 they added support for expansion.

VBoxManage modifyhd filename.vdi --resize 46080

That will resize a virtual disk image to 45GB.

  • 10
    Regarding the VirtualBox 4 version: after resizing the disk, you have to resize the partition as well which cannot be done when booted from so one has to boot into some sort of gparted livecd as well. – fikovnik Mar 14 '11 at 2:14
  • 1
    @fikovnik- Yes, the partition needs to be resized too. However, on Windows it can be done on the booted disk itself using the diskpart utility tool via the command-line or via the Disk Management GUI without booting from a separate disk. – Ray Vega Jun 8 '11 at 19:35
  • I don't have a vdi file what is it? I have .vmdk files – chobo2 Aug 2 '12 at 21:45
  • I provide a link to help with re-partition the ubuntu hard disk, after using VBoxManage connection.rnascimento.com/2011/01/25/…. After re-partition the hard disk, u need to resize the file system using resize2fs command. – Thang Pham Sep 4 '13 at 5:07
  • @fikovnik I managed to modifyhd to a larger number and I can clearly see it in the virtualbox manager the disk size has increased, however, i cannot see the extra space disk after i booted into gparted, weird. – B.Mr.W. Oct 19 '15 at 4:56
5

The Trivial Proof blog has a nice tutorial of the process for VirtualBox versions before and after 4.0. It includes the steps for adjusting the partition on the expanded disk.

  • That blog site no longer exists. – Barry Brown Aug 15 '11 at 17:52
  • The link was just broken, @Barry. Fixed now. – Don Kirkby Aug 17 '11 at 3:31
  • As of 2015, this answer is superior to the one that was accepted by the original questioner. – Michael Currie Sep 6 '15 at 4:04
2

If you are running Windows Server 2012 and VirtualBox version 4 and above, there are only 4 steps:

  1. run the "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd .vdi --resize
  2. Boot Up Virtual Box
  3. In server managaer -->File And Storage Services --> Volumes --> Disks --> Tasks --> Rescan Storage
  4. Go to server manager -->File And Storage Services --> Volumes --> Right click on volume --> choose expand volume.

Go to file explorer and right click on the drive. You will seethat the volume has increased in size!!

2

This worked perfectly (from Windows 7 and using VirtualBox 4.x).

Do the following:

  1. Open cmd as administrator.
  2. Go to the folder where the VirtualBox is installed so you can use the VBoxManage program.
  3. From there, run the following command:

    VBoxManage modifyhd <file path and name> --resize <size in MB>
    

    e.g.: VBoxManage modifyhd C:\V-MACHINES\SERVER2008\WIN-2008.VDI --resize 26000

  4. You will see a message from 0 to 100% and done.
  5. Start your machine and go to "Computer" (or "My Computer", if applicable), right click and select "Manage", go to "Storage" → "Disk Management", right click on the disk you want to expand, click on "Extend Volume" and resize the disk as you wish.
  6. If necessary restart the VM.
  • Yes, and, make sure you do that for snapshotted .vdi's. But note - once I've done all the above steps, my Win7 guest is very unstable. sfc /scannow hangs, even chkdsk hangs. – Greg Bell Jul 12 '16 at 23:13
1

Had to search a bit on how to run this command.

Navigate to folder having your-filename.vdi e.g:(cd /Users/binoy/VirtualBox\ VMs/)

Then run the command to increase the space to 25 gb.

VBoxManage modifyhd filename.vdi --resize 25000

You would now have to attach the additional space using resize2fs or Gparted.

0

There's also now a simple GUI too called Clone VDI for Windows users that @Eric Kigathi mentioned here: https://stackoverflow.com/a/5987875/1024735

0

Lets see the currently existing virtual hard drives of your virtual box(es) using the vboxmanage command

$ vboxmanage list hdds

In my case it lists only this one

UUID:           db753df8-de41-425b-b452-fab84f1f8b71
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       /home/anonyn/WIN81_64BITS.vdi
Storage format: VDI
Capacity:       39891 MBytes
Encryption:     disabled

Keep the location of the VDI file you want to resize /home/anonyn/WIN81_64BITS.vdi

Lets determine how much physical space is left on your real machine (Linux)

$ df -h

Filesystem      Size  Used Avail Use% Mounted on
udev            3,9G     0  3,9G   0% /dev
tmpfs           791M  1,4M  790M   1% /run
/dev/sda2       110G   29G   76G  28% /
tmpfs           3,9G   62M  3,8G   2% /dev/shm
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           3,9G     0  3,9G   0% /sys/fs/cgroup
/dev/sda1        38M   512   38M   1% /boot/efi
tmpfs           791M   28K  791M   1% /run/user/1000

Since in my case I have 76GB free on /dev/sda2 I can increase that WIN81_64BITS.vdi it by 36GB without any issues

Some simple math will allow you to get the desired new size

[CurrentSizeFrom first command] + [SizeToIncrease in MBytes too]
39891 MBytes + 36*1024 MBytes
39891 MB + 36864 MB = 76755 MB [NewSizeInMB]

Now you are ready to build the command that will help you solve the problem

VBoxManage modifyhd [path/To/File.vdi] --resize [NewSizeInMB]

$ VBoxManage modifyhd /home/anonyn/WIN81_64BITS.vdi --resize 76755

$ VBoxManage modifyhd /home/anonyn/WIN81_64BITS.vdi --resize 76755 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Now boot that virtual machine and extend the desired partition following this steps

enter image description here enter image description here enter image description here enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.