Increasing disk space on VirtualBox

42

26

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

Casebash

Posted 2010-08-06T03:10:53.613

Reputation: 5 677

Answers

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.

SysAdmin1138

Posted 2010-08-06T03:10:53.613

Reputation: 5 239

@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. – 2015-10-19T04:56:18.513

Quick tutorial to resize partition: https://support.microsoft.com/en-in/help/325590/how-to-extend-a-data-volume-in-windows-server-2003,-in-windows-xp,-in

– Nilesh Rajani – 2017-07-16T10:17:40.640

10Regarding 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 – 2011-03-14T02:14:02.020

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 – 2011-06-08T19:35:43.967

I don't have a vdi file what is it? I have .vmdk files – chobo2 – 2012-08-02T21:45:49.797

I provide a link to help with re-partition the ubuntu hard disk, after using VBoxManage http://connection.rnascimento.com/2011/01/25/expanding-virtual-box-hard-disk-ubuntu-guest-os/. After re-partition the hard disk, u need to resize the file system using resize2fs command.

– Thang Pham – 2013-09-04T05:07:16.290

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.

Don Kirkby

Posted 2010-08-06T03:10:53.613

Reputation: 883

As of 2015, this answer is superior to the one that was accepted by the original questioner. – Michael Currie – 2015-09-06T04:04:25.913

That blog site no longer exists. – Barry Brown – 2011-08-15T17:52:11.050

The link was just broken, @Barry. Fixed now. – Don Kirkby – 2011-08-17T03:31:43.347

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.

Mauricio Luca

Posted 2010-08-06T03:10:53.613

Reputation: 21

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 – 2016-07-12T23:13:27.403

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!!

user230405

Posted 2010-08-06T03:10:53.613

Reputation: 21

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.

binoy

Posted 2010-08-06T03:10:53.613

Reputation: 11

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

Mauricio Gracia Gutierrez

Posted 2010-08-06T03:10:53.613

Reputation: 209

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

kevinmicke

Posted 2010-08-06T03:10:53.613

Reputation: 740