Is there an easy way to increase virtual hard disk space on VirtualBox?
There is not an easy way to do this.
There is a complicated one, though:
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.
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.
If you are running Windows Server 2012 and VirtualBox version 4 and above, there are only 4 steps:
- run the "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd .vdi --resize
- Boot Up Virtual Box
- In server managaer -->File And Storage Services --> Volumes --> Disks --> Tasks --> Rescan Storage
- 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!!
This worked perfectly (from Windows 7 and using VirtualBox 4.x).
Do the following:
- Open cmd as administrator.
- Go to the folder where the VirtualBox is installed so you can use the
From there, run the following command:
VBoxManage modifyhd <file path and name> --resize <size in MB>
VBoxManage modifyhd C:\V-MACHINES\SERVER2008\WIN-2008.VDI --resize 26000
- You will see a message from 0 to 100% and done.
- 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.
- If necessary restart the VM.
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.
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
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