How do I increase the hard disk size of the virtual machine?
Solution 1
Since VirtualBox 6, you can use the GUI, as per lenooh's answer.
Otherwise, open a terminal and navigate to the folder with the VirtualBox disk image, then use the following command:
VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB
replacing YOUR_HARD_DISK
and SIZE_IN_MB
with your image name and desired size. sudo
might be necessary in some machines or you might encounter an error. This answer and a fuller explanation are here, on webupd8. Credit to Andrew there for posting this answer.
After resizing, the extra virtual hard drive space needs to be partitioned and formatted for the guest to use it. This can be done with gparted by booting the guest from a live ISO. We can also resize the existing partition using gparted. For this we may need to disable /swap
and create a new swap partition.
In case if VBoxManage
is not found in your system, just set the path to:
set PATH=%PATH%;"C:\Program Files\Oracle\VirtualBox"
and it should resolve path issue. Do make sure VBoxManage
is present at this path before setting it.
Solution 2
Since VirtualBox 6 we can use a GUI for resizing VMs' virtual disks.
To access it, click File
-> Virtual Media Manager ...
The following window will open
Select your disk, and click Properties
. Now just move the slider at the bottom or write the value you want for the size and click "Apply" when you’re done.
After you start the virtual machine, Windows will not recognize the new space.
In Windows, open Computer Management
(search for it in the start menu), select Storage
-> Disk Management
in the left menu (In Windows 10 you can find it as create and format hard disk partitions
directly from the start menu). Select your partition (probably C:), right-click on it, and select Extend Volume ...
. Now just click through the wizard and you're done.
Note that on your VM Windows might not detect the extra space if you have snapshots in your VM. To fix this, it is recommended that you delete the snapshots or (the easiest way) just clone it and perform the resize in the new one.
Solution 3
The following worked for me:
VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB
However, I understand how mileage can vary :-) As far as resizing the partition, in Windows 7, I was able to resize at the screen you showed by right clicking on the C: drive in the bottom panel and selecting extend volume.
Solution 4
Wim, I think you'll need to unregister it from Vbox first. File, Media Manager, Click on you hdd, and unregister it. Then try it again.
Solution 5
If you are on Windows host and trying to increase the size of Ubuntu's VDI size then the following information can help you:
Get your full path of vdi, for me, it was "D:\VirtualBoxImages\Ubuntu\Ubuntu.vdi".
Run the command mentioned in the "Marked as answered" post:
"C:\Program Files\Oracle\VirtualBox>VBoxManage modifyhd D:\VirtualBoxImages\Ubuntu\Ubuntu.vdi --resize 40000"
Above, "C:\Program Files\Oracle\VirtualBox" is the location of the folder where my Windows Virtual Box is installed, 40000 is 40 GB in the above command.
After doing the above-mentioned step, restart the Ubuntu VM.
Go to "Disks"
Resize the existing partition to make it 40 GB:
You can then confirm from the "Storage" that the above operation worked:
wim
Hi from Chicago! Python dev with interest in mathematics, music, robotics and computer vision. I hope my Q&A have been helpful for you. If one of my answers has saved your butt today and you would like a way to say thank you, then feel free to buy me a coffee! :-D [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*
Updated on September 18, 2022Comments
-
wim over 1 year
I have run out of space on my WinXP virtual machine, which I only gave 10 GB space for when I created it. Is there an easy way to increase it to, say, 20 GB? I can't see any obvious option in VirtualBox settings.
The suggestion below gives this error
wim@wim-ubuntu:/media/data/winxp_vm$ VBoxManage modifyhd wim.vdi --resize 20000 VBoxManage: error: Cannot register the hard disk '/media/data/winxp_vm/wim.vdi' {46284957-2c09-4e70-8a49-bfbe0f7f681d} because a hard disk '/home/wim/VirtualBox VMs/winxp_vm/wim.vdi' with UUID {46284957-2c09-4e70-8a49-bfbe0f7f681d} already exists VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, AccessMode_ReadWrite, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 210 of file VBoxManageDisk.cpp
Removing the .vdi from VirtualBox before calling VBoxManage command, then adding it back in, was successful. But now I can't boot the virtual machine, I get this worrying screen:
By the way, it says
FATAL: Could not read from the boot medium! System halted.
The vdi must be reattached to the VM after VBoxManage command. Further, the partition will need to be resized from WITHIN windows, because you will have this empty space:
I was able to resize the partition easily using a bit of freeware called EASEUS Partition Master 9.1.0 Home Edition.
-
stolsvik about 11 yearsYour problem is that you've symlinked the disk to a '/media/data' location and that it doesn't reside on the original '/home/wim/VirtualBox VMs' location. I've answered with how I fixed this.
-
kmonsoor over 9 yearsi have detailed my experience here: kmonsoor.wordpress.com/2012/05/26/virtualbox-increase-disk-size the "accepted" answer below is way far from being even right.
-
parasrish about 6 yearsThere is another possibility of "copying the existing vdi" to a "new empty vdi, whose size is bigger than existing" (refer- justintung.com/2011/01/06/… )
-
parasrish about 6 yearsalso, note that, just resizing might not help, as the "vdi" size would have increased, but based on the "vm-os-installation", your primary partition stays the same, and the newly allocated space is typically shown "unallocated". You need to hence do the "partition re-allocation" (Refer the link above).
-
Eric about 3 years
-
-
wim over 12 yearsunfortunately it does not work.. see my edit
-
Sanam Patel over 12 yearsSorry that didn't work. Judging from the comments over there it looks like it only works some of the time. Hopefully someone more experienced can reply here or over on webupd8. Don't bother trying to clone the .vdi either, you can't specify a larger partition. I just tried and all you can do is an exact clone. Just a thought, did you do a fixed 10GB initially, or dynamically expanding storage? That might be a clue.
-
wim over 12 yearsiirc it was dynamic
-
Jonik over 12 years+1. Just used this to increase the size of my Windows 7 disk from 20 to 30 GB, and it worked very smoothly (no unregistering etc needed).
$ VBoxManage modifyhd Windows7.vdi --resize 30720 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
At first Windows didn't detect the increased space, but after a poweroff it did, and then I was able to use the built-in Disk Management tool to increase the size of my C: partition. -
Lekensteyn about 12 years
sudo
is not necessary. It may corrupt permissions in your home directory, requiring you to usesudo
for virtualbox which is a bad idea. -
Richard Povinelli about 12 years@Lekensteyn: Good to know that it is not necessary. I used it because others had said it didn't work without being root. As far as permission corruptions go, chmod works well to fix such mistakes.
-
Richard Povinelli about 12 years@Lekensteyn: chown will fix ownership mistakes. I mention chmod and chown, because I have had to fix the problem you are referencing many times :-)
-
Starx about 12 years+1, This is certainly the cleanest way to do it.
-
Sanam Patel over 11 yearsCan you please explain the steps here? Answers with little more than a link to another site are generally frowned up here, and may be deleted.
-
szx over 11 yearsMy Windows 7 VM can't see any changes in disk size even after second reboot (yes, in Computer Management) but Settings/Storage shows the new value. Any ideas why?
-
Bruno over 11 years@asd Changing the disk size isn't enough, you also need to resize the partition.
-
Jon about 10 yearsThis is great for Windows, but if you have a Linux guest OS this link can help with re-sizing the partitions: forums.virtualbox.org/viewtopic.php?f=35&t=50661
-
Bob over 9 yearsWhat about if the path to the
HARD_DISK.vdi
contains blank spaces ? I get errors. Is there a way to type correctly the path ? -
Sanam Patel over 9 years@begueradj Sure, put a \ (backslash) character before any spaces in the path, like this: /PATH/HARD\ DISK.vdi.
-
Ajith R Nair over 7 yearsIf you are running windows inside linux you need to follow this options , and extend the disk, otherwise windows wont add the additional space we added
-
Jonathan over 7 yearsDid you have to reinstall / reformat / repartition? or did it just boot right back up?
-
Jonathan over 7 yearsSome people reported this causes the home dir to have bad permissions
-
Travis van der Font over 7 yearsTHIS WILL WORK! However, you need to increase the partition after so windows can register the new space. Best and quickest / easiest method: howtogeek.com/howto/windows-vista/…
-
Underverse over 7 yearsNot required on Linux in VirtualBox. Just had to shut down the guest OS completely first.
-
Dewsworld almost 7 yearsI used sudo before VBoxManage and it worked
-
marijnz0r almost 7 yearsThis worked for me, followed the guide here: yinfor.com/2015/05/…
-
Neurotransmitter over 6 yearsI think in recent versions of VirtualBox it is
.\VBoxManage.exe modifymedium disk 4d30d154-f8c2-4a3b-bd8b-ddcfbfe64aaf --resize 30720
now.modifyhd
is also works though — there is a backward compatibility with older commands. -
ollydbg23 over 6 yearsI just resize the vdi file size from 25G to 120G, but Windows7 system's disk-manager still can't see the unallocated space. Is is caused by a snapshot file(I have a snapshot before), but when I try to delete the snapshot, virtualbox report crashes, so I can't delete the snapshot. Any ideas? My guest win7 still see 25G. thanks.
-
ollydbg23 over 6 yearsOK, I finally delete the snapshot, and now start win7, I see it has some 97G extra unallocated spaces, thanks.
-
CGFoX over 6 years
VBoxManage
is in your installation folder of VirtualBox -
parasrish about 6 yearsyou can validate the increased size by the command :
VBoxManage.exe showhdinfo <image_with_path.vdi>
There you see the before and after size in the "Capacity:" section. -
AlwaysLearning about 6 yearsWorked great. Shouldn't this be the accepted answer, at least for the recent versions of VirtualBox?
-
Royi about 5 yearsDo you need to do
Release
before that? As currently the slider is grayed. Or did you chose dynamic partition? -
Royi about 5 yearsYou should add this will work only on Dynamic Size Partitions. See askubuntu.com/questions/539924.
-
lenooh about 5 yearsRoyi: when you make the virtual disk, make sure it has a dynamic size.
-
nick-s almost 5 yearsOn Mac,
VBoxManage
is incd /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/
-
Manuel Jordan over 4 years@TomBrossman consider to indicate that
modifyhd
is old and is replaced bymodifymedium
. The former is still valid for compatibility purposes virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi -
Manuel Jordan over 4 yearsGood to know the GUI approach. Of course the command way works too.
-
Lasith Niroshan over 4 yearsAlso, this solution worked for macOS. thanks for sharing...
-
Jamie Hutber over 4 yearsThis should be the accepted answer. All the others you lose your install and have to format the drive!!!
-
R2-D2 almost 4 yearsI was using this sucessfully before, but this time it bricked my Ubuntu 20 VM.
-
Robin over 3 yearsSeems to be a more complicated story for ubuntu though. I am trying export OCI and then create a new VM to try to get round the deletion of partitions etc.
-
Tim over 3 yearsHow do you update size when the VM is ubuntu?
-
lenooh over 3 yearsTim: use the same procedure for Virtualbox, and then in Ubuntu use gparted for example.
-
Pikamander2 about 3 years@Tim - See Raghav's answer below.
-
run_the_race almost 3 yearsVery helpful, Ubuntu did not detect the increase in file size.
-
robert almost 3 yearsI had to use gparted-live iso and do the resize from there as I got an error from Ubuntu 21.04
-
Sagar M over 2 yearsRead this link itsfoss.com/increase-disk-size-virtualbox this worked for me
-
Chris G over 2 yearsThanks, this is the only correct answer!
-
baptx over 2 yearsThe "Extend Volume" option was greyed out so I could not select it. I read it can be because there is another partition between (recovery partition in my case) and to extend the volume, the unallocated space should be next to the volume we want to extend: diskpart.com/windows-10/… I used a GParted live CD to move the partition and then I was able to extend the volume in Windows.
-
lenooh over 2 yearsbaptx: recovery partition in a Virtual Box virtual disk? Are you sure you were resizing a virtual disk? 😃
-
parliament about 2 yearsDon't use this answer it bricked my VM and had to start over. Use the 2nd answer by lenooh
-
Admin about 2 yearsIndeed, very helpful, I was missing that step in which I am supposed to increase the disk space on the Ubuntu virtual machine.