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.
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:
replacing
YOUR_HARD_DISK
andSIZE_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:and it should resolve path issue. Do make sure
VBoxManage
is present at this path before setting it.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), selectStorage
->Disk Management
in the left menu (In Windows 10 you can find it ascreate and format hard disk partitions
directly from the start menu). Select your partition (probably C:), right-click on it, and selectExtend 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.
The following worked for me:
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.
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.
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:
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:
After resizing and not being able to view the resizing on my windows XP guest machine, I had to
I saw in other forums that snapshots can interfere for resizing and not being able to remove all snapshots for different errors I got, the only found solution for me was to clone it to remove the snapshots and then resize it, and everything worked. For resizing outside windows, a gparted boot cd that can be found here can help
I had the same problem where I had moved a disk, and replaced the original with a symlink. This works OK afterwards, but you run into problems with the 'modifyhd' command, as that apparently canonicalizes the path to the vdi-file when working with it. This makes it looks like you're trying to add a new disk with the same UUID but on a different path - or something like that.
There was two problems:
The disk had to be removed from the VM that used it, but then also "from the VirtualBox list of hdds". This was fixed with 'closemedium' command, which removes it from that list.
The disk to be resized was a "fixed disk" instead of "dynamic", and only dynamic disks can be resized. That was fixed with a 'clone' command (the clone is dynamic), and then resize the resulting disk.
This is my log for how it was done. Do notice that I am not at any point running as root, except when I afterwards do the resize of the partition and filesystem.
REMOVE THE ASSOCIATION TO THE DISK FROM VM.
PROBLEM STILL PERSISTS:
Ah, the disk is still "in the system":
Remove/delete the disk from the VirtualBox disk list ("closemedium"):
Try the resize again:
DAMN, "fixed-size" DOESN'T WORK! 'clonehd' to the rescue, as that leaves a 'dynamically allocated' cloned disk:
NOW DO THE RESIZE (instantanious):
THEN ATTACH TO SOME VM, FOR RESIZING. This is done as root. Assumes that you only have one partition and possibly swap.
This worked for me with Virtualbox 5.2.6 installed on Ubuntu 16.04 Host Machine and Windows 10 Guest: open Virtualbox Manager, click on Global Tools (upper right corner) and choose Virtual Media Manager. Click on the Hard Disk Tab and select your Guest OS. At the bottom of the box click on the Attributes Tab. At the bottom you can see the size of the Virtual Disk, and with the slider you can increase the size to your liking. (You can only increase, not decrease the size with this method). Click on Apply. Start your Windows Guest OS, open Computer Management, right click on the C: Drive, and select Extend Volume to extend the file system with the unallocated part.
That’s all I had to do, works perfectly for me.
Here's a way to resize your VirtualBox disk, regardless of whether it is a fixed format or dynamic format disk. Specifically, it prevents this error:
On your host:
Open a terminal window.
Go to the directory with the virtual disk you want to resize. For example:
Create a new VirtualBox disk with your desired filename, size (in megabytes) and format (either
Standard
(dynamic) orFixed
). For example, to create a 50 GB fixed-format disk calledMyNewDisk.vdi
:Copy the original disk to the new disk.
The resize is done! You can check the properties of the new disk if you want:
Change the virtual machine to use the new disk instead.
Next, on your guest OS you need to resize the partitions to use the newly available space.
A sure-proof way is to do it the same as moving to a larger hard drive that's not running in a VM. First use ccleaner or similiar program in XP to clean up all junk files that it can. Then create a secondary virtual HDD of the size you want. Boot with the clonezilla ISO in your virtual ODD drive and clone over along with the 'resize to new partition size' option selected. Then set the new Virtual HDD as primary, and don't delete the old one until you know it worked.