Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

enter image description here

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:

enter image description here

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:

enter image description here

I was able to resize the partition easily using a bit of freeware called EASEUS Partition Master 9.1.0 Home Edition.

share|improve this question
2  
Your 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. –  stolsvik Apr 9 '13 at 15:35
    
i 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. –  kmonsoor Oct 8 at 16:25

9 Answers 9

up vote 128 down vote accepted

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. This answer and a fuller explanation are here, on webupd8. Credit to Andrew there for posting this answer.

share|improve this answer
    
unfortunately it does not work.. see my edit –  wim Dec 19 '11 at 8:13
    
Sorry 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. –  Tom Brossman Dec 19 '11 at 9:36
9  
+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. –  Jonik Dec 22 '11 at 10:05
2  
+1, This is certainly the cleanest way to do it. –  Starx May 3 '12 at 15:08
7  
@asd Changing the disk size isn't enough, you also need to resize the partition. –  Bruno Nov 7 '12 at 18:44

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.

share|improve this answer

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.

Computer management screen

share|improve this answer
7  
sudo is not necessary. It may corrupt permissions in your home directory, requiring you to use sudo for virtualbox which is a bad idea. –  Lekensteyn Apr 15 '12 at 12:01
1  
@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 Apr 15 '12 at 12:05
    
@Lekensteyn: chown will fix ownership mistakes. I mention chmod and chown, because I have had to fix the problem you are referencing many times :-) –  Richard Povinelli Apr 15 '12 at 12:19
    
This 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 –  Jon Mar 29 at 21:35

After resizing and not being able to view the resizing on my windows XP guest machine, I had to

  1. clone it
  2. resize it with "VBoxManage modifyhd winxppro\ Clone.vdi --resize 30720" and everything worked

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

share|improve this answer

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:

  1. 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.

  2. 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: virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage modifyhd TestInception\ 64\ bit.vdi --resize 8192 VBoxManage: error: Cannot register the hard disk '/datadisk/VirtualBox VMs/TestInception 64 bit/TestInception 64 bit.vdi' {6cd99209-e4db-4178-a6c2-53f9581b1fad} because a hard disk '/home/virt_box/VirtualBox VMs/TestInception 64 bit/TestInception 64 bit.vdi' with UUID {6cd99209-e4db-4178-a6c2-53f9581b1fad} already exists VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp ### Ah, the disk is still "in the system": virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage list hdds UUID: ba58276a-bbe1-4354-8ae5-246bdac390c8 Parent UUID: base Format: VDI Location: /home/virt_box/VirtualBox VMs/TestInception 32 bit/TestInception.vdi State: locked write Type: normal Usage: TestInception 32 bit (UUID: a693ac62-7caa-4f11-9d00-51d3a149f5f7) UUID: 6cd99209-e4db-4178-a6c2-53f9581b1fad Parent UUID: base Format: VDI Location: /home/virt_box/VirtualBox VMs/TestInception 64 bit/TestInception 64 bit.vdi State: created Type: normal ### Remove/delete the disk from the VirtualBox disk list ("closemedium"): virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage closemedium disk 6cd99209-e4db-4178-a6c2-53f9581b1fad virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage list hdds UUID: ba58276a-bbe1-4354-8ae5-246bdac390c8 Parent UUID: base Format: VDI Location: /home/virt_box/VirtualBox VMs/TestInception 32 bit/TestInception.vdi State: locked write Type: normal Usage: TestInception 32 bit (UUID: a693ac62-7caa-4f11-9d00-51d3a149f5f7) ### Try the resize again: virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage modifyhd TestInception\ 64\ bit.vdi --resize 8192 0%... Progress state: VBOX_E_NOT_SUPPORTED VBoxManage: error: Resize hard disk operation for this format is not implemented yet! ### DAMN, "fixed-size" DOESN'T WORK! 'clonehd' to the rescue, as that leaves a 'dynamically allocated' cloned disk: virt_box@TestBox:/datadisk/VirtualBox VMs/TestInception 64 bit$ VBoxManage clonehd TestInception\ 64\ bit.vdi TestInception\ 64\ bit-cloned.vdi 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Clone hard disk created in format 'VDI'. UUID: 8e237500-173b-401a-9e63-9e64da110da9 ### NOW DO THE RESIZE (instantanious): virt_box@TestBox:/datadisk/VirtualBox VMs/TestInception 64 bit$ VBoxManage modifyhd --resize 8192 TestInception\ 64\ bit-cloned.vdi 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% ### THEN ATTACH TO SOME VM, FOR RESIZING. This is done as root. Assumes that you only have one partition and possibly swap. # fdisk /dev/sdb # <- The extra disk, just attached to be resized // The procedure looks like this: // m - print help // p - print table // d ... - delete partition (delete both if you have root and swap) // n - new partition (create root/first partition starting on exact same sector as before, typically 2048, but ends on last, or last minus swap) // ... n.. (.. then add the swap partition. Calculate how many sectors using original table) // t - change type of partition (swap partition, if any, to 82 - not 83 which is "normal Linux"). // w - write partition table (write out, with the resized partition) # e2fsck -f /dev/sdb1 e2fsck 1.42.5 (29-Jul-2012) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdb1: 99918/122160 files (0.3% non-contiguous), 471032/487936 blocks # resize2fs /dev/sdb1 resize2fs 1.42.5 (29-Jul-2012) Resizing the filesystem on /dev/sdb1 to 1965824 (4k) blocks. The filesystem on /dev/sdb1 is now 1965824 blocks long.
share|improve this answer

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.

share|improve this answer

I received the same error until I used sudo to run the command, then worked perfect, still need to have partition grown from within the guest to use additional space.

share|improve this answer

Make sure you are logged in as user with write permissions to the disk image file. Then run

VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB  

Worked for me at first time of asking

share|improve this answer

As a matter of fact, it seems that modifyhd alone doesn't do you any good in some cases. I actually expanded my WinXP vdi by cloning the image after expansion.

Here's the complete step-by-step guide that worked for me a couple of weeks ago: http://libtronics.com/2011/07/resize-virtualbox-disk-for-winxp-guest/

share|improve this answer
    
Can 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. –  Tom Brossman Sep 29 '12 at 17:10
    
Well, you need to understand what modifyhd does, which isn't much more than expanding the underlying virtual disk, that's all. You still need to expand the filesystem that's on it. –  Marcin Kaminski Nov 21 '12 at 0:41

protected by Community Apr 10 '12 at 10:27

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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