Increase space on fixed VirtualBox VDI disk containing Windows 7 on Mac
I use VirtualBox on my Mac to have other operating systems at my disposal. One of my appliances contains a copy of Windows 7 with a fixed, 25GB disk. I’ve run out space and was looking for an easy way to increase it.
I came across the modifyhd
command, which in theory let’s you increase the disk space, but it only works on dynamic disks. I opted for performance (fixed disk) when I set up the appliance, and this minor inconvenience is the price.
There are several tutorials out there, but many of them require third-party applications, either on the Mac or in Windows side. The thing is, even without those utilities, it’s fairly easy to increase your disk space.
What we’ll do is create a bigger disk, clone the contents from the small disk to the big disk, and then increase our Windows partition.
Create a new VirtualBox disk
First, we’re going to create a new disk with the desired size.
- Select your appliance in VirtualBox and click on Settings.
- Click on the Storage button.
- Select Controller: SATA Controller from the storage tree list.
- Underneath the storage tree list, click on the add attachment button (disk icon with plus sign).
- Select Add Hard Disk, followed by the Create new disk button.
- Select VDI (VirtualBox Disk Image) and press Continue.
- Select Fixed size and press Continue.
- Give it a name, set your desired disk size, and click Create.
Clone small disk to large disk
Second, we’ll copy all of the contents from your existing disk to the new disk.
- Open up Terminal.
- Run the following command:
/Applications/VirtualBox.app/Contents/MacOS/VBoxManage clonehd /Users/username/VirtualBox\ VMs/Windows\ 7\ Pro/Windows\ 7\ Pro.vdi /Users/username/VirtualBox\ VMs/Windows\ 7\ Pro/Windows\ 7\ Pro\ New.vdi --existing
- Breaking the above command down:
- Program:
/Applications/VirtualBox.app/Contents/MacOS/VBoxManage clonehd
- Existing disk:
/Users/username/VirtualBox\ VMs/Windows\ 7\ Pro/Windows\ 7\ Pro.vdi
. - New disk:
/Users/username/VirtualBox\ VMs/Windows\ 7\ Pro/Windows\ 7\ Pro\ New.vdi
. - Existing disk flag:
--existing
. - Be sure to change the items in red (and anything else you may have customized). The backslash before each space is necessary to escape the space.
- You should see a progress indicator that will let you know when it’s complete.
Increase your Windows partition
Lastly, now that the disk has increased in space, we need to expand our Windows partition to utilize the newly-added space.
- Start your Windows appliance and login.
- Find your Computer, right-click on it, and select Manage.
- Toward the left, click on Disk Management (under Storage).
- Find your C: drive to the right, right-click on it, and select Extend Volume.
- Click Next, then Next one more time, followed by Finish.
If you inspect your hard drive now using Explorer, you’ll find the added space.
Featured image by Geometric Photography.
Comments (12)
Previously posted in WordPress and transferred to Ghost.
Cory Lowe
September 13, 2014 at 2:54 pm
Hi Ryan,
I used your tutorial (http://ryansechrest.com/2014/03/increase-space-fixed-virtualbox-vdi-disk-containing-windows-7-mac/) in attempt to expand the disk space on a fixed size VM. However, when I run the command I get the error message below stating that the original drive already exists. I was wondering if you had any advice to offer?
Thank you for any help you have to offer,
Cory Lowe
My commands and error messages are below:
Claytons-iMac:~ CoryLowe$ /Applications/VirtualBox.app/Contents/MacOS/VBoxManage clonehd /users/corylowe/virtualbox\ VMs/Windows\ XP/Windows\ XP.vdi /users/corylowe/virtualbox\ VMs/Windows\ XP/100\ GB.vdi --existing
VBoxManage: error: Cannot register the hard disk '/users/corylowe/virtualbox VMs/Windows XP/Windows XP.vdi' {403ba968-4361-4d09-a58a-4f434ef115fd} because a hard disk '/Users/CoryLowe/VirtualBox VMs/Windows XP/Windows XP.vdi' with UUID {403ba968-4361-4d09-a58a-4f434ef115fd} 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
Ryan Sechrest
September 13, 2014 at 5:00 pm
Hi Cory,
Did you at some point rename yourWindows XP
or any of the other directories in that path?
I did a bit of research on that (since I’ve never run into this) and it could either be (a) that you were not using absolute paths (which it looks like you were) or (b) that you at some point renamed a directory in that path (e.g.Windows XP
) and VirtualBox still thinks that location exists.
If you runVBoxManage list hdds
, do all your disks live in the path indicated?
What you might try is to unregister that UUID within VirtualBox’s registry by running:VBoxManage closemedium disk 403ba968-4361-4d09-a58a-4f434ef115fd
And then try cloning it again:VBoxManage clonehd "/users/corylowe/virtualbox VMs/Windows XP/Windows XP.vdi" "/users/corylowe/virtualbox VMs/Windows XP/100 GB.vdi" --existing
Luc
September 26, 2014 at 8:17 am
Hi,
Nice explanation, it’s work well for me.
Maybe we should add this before “Point 3 Increase your Windows partition”
In “VirtualBox/Settings/Storage” Select your new drive and attribute to it “Port SATA 0” to be able to boot with the new drive.
Thank you very much !
Jon
January 19, 2015 at 5:59 pm
Worked great for me, thanks!
ines
March 5, 2015 at 4:33 am
Thank you very much!!! i struggled 2 days to expand storage in my virtual box using a mac, until i found your post! your explanation are great, thanks a lot
David
July 6, 2015 at 6:41 am
Worked like a charm for me, thanks!
One remark though, it might be worth mentioning that you have to remove the old vdi file from the storage settings first, because otherwise ‘extend volume’ will be greyed out, even though Windows can already see how much free space it can allocate.
sadhanandham
September 1, 2015 at 1:09 am
Came across this site for expanding my fixed Hard disk size and worked like a charm. Found n number of solutions but this one helped me to achieve the same with just one additional disk.
Thanks.
Fabien
October 21, 2015 at 12:00 am
Hello, I came accross your tutorial and i have to admit that it was a big relieve. I can’t believe that they were nothing regarding this extension issue. I have followed your steps until the last part where i have to select the C drive and extend the volume. However, it’s gray out and does not allow me to select it. can you please advise on what to do? I was trying to attach a shot of it with no success.
Thank you very much.
Mike
December 9, 2015 at 12:53 am
Two words: THANK YOU!
Britt
September 6, 2018 at 11:03 pm
Thank you so much! You are a life saver!! Your instructions were so helpful and thank you for breaking down each part of the code so I could be sure that I was able to follow with my own directories!! I have been pulling out my hair for a week to get ready for a mandatory training and I have been through almost ever suggestion until I finally found your page. Thank you, thank you, thank you.
Ryan Sechrest
September 6, 2018 at 11:09 pm
Hi Britt! Haha, I’m glad that this is still helpful to someone four years later!
Seif Eddine Slimene
November 6, 2020 at 1:13 am
Very Helpful Sir!