Translate

How to resize a VirtualBox fixed size virtual drive (.vdi) on Mac

So you created a disk for your Windows or Linux VirtualBox VM and you made the mistake of not creating the drive as a dynamically expanding storage drive, you chose fixed size.

Now you’re running out of space and all your Google searches point you to stupid posts on the virtualbox.org forums that lead to nowhere, specially if you are a MacOSX user, look no further, you’ve found the solution to your problem on this post.

VirtualBox for Mac comes with a tool called VBoxManage, this tool is all you need to resize your virtual disk.

When you’re using the VBoxManage tool make sure your VM is not running, stop it completely to be safe.

Step 0. Backup your current drive (optional)

I recommend that before you do anything you clone your existing drive, just in case…

You can clone your drive using guess what? yes, the VBoxManage tool. No need to download any external tools.

$ VboxManage clonehd <path to your original drive> <path of the copy>

in my computer it looked exactly like this:

$ VBoxManage clonehd /Users/gubatron/VirtualBox\ VMs/windows7-64bit/windows7-64bit.vdi /Users/gubatron/windows7-64bit.cloned.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

If you don’t know where your .vdi file is, it’s very simple, right Click your VM > Settings > Storage, and mouse over the .vdi to see it’s physical location on your Mac hardrive.


Mouse over your virtual drive if you don’t know its location

Step 1. Resize!

The command to resize is:

$ VBoxManage modifyhd <path to your vdi> --resize <new size in megabytes>

In my case I had a 20GB drive that I wanted to double in size (40GB), a quick Google search for “40GB to megabytes” yields the number 40960, so that’s what I put on my –resize parameter.

This is how it looked for me:

$ VBoxManage modifyhd /Users/gubatron/VirtualBox\ VMs/windows7-64bit/windows7-64bit.vdi --resize 40960
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

The ‘resizing’ is almost immediate.

Step 2. (Re)Start VirtualBox

After you’ve physically resized your drive, both VirtualBox and your OS should know about the changes.

At this point, clicking on your VM in the VirtualBox window will show that it still has the old size:

Before: (Note the size of the drive at the bottom of the image)

After doing the resize, shutdown completely your VirtualBox, and launch it again. When you see the information about the storage drives attached to your VM you should see the new disk size.

After: (Note the size of the drive at the bottom of the image)

Step 3. Let your OS know the new logical size of the drive


Your OS is still not aware of the changes, you need to let it know about them

When you start your VM, it won’t know right away what the new size of the disk is, you’ll have let the operating system know that there is additional space it can use.

If your VM is running Windows 7, the way to let the operating system know that it can use the additional space on your drive is very straight forward.

Click on the Windows (Start) Icon on the Bar > Right Click on “Computer” > Manage (You’ll need to be an Administrator)

The “Computer Management” window will open, in it go to:

Storage > Disk Management > Right Click on the partition you want to extend.

Select the option that says “Extend”, a Wizard will open, just hit Next until it ends if you want to use the whole space.

After you’re done, if you refresh your “Computer” on the File explorer the resized drive should show right away

That’s it, enjoy and let me know how it went.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

11 Responses to “How to resize a VirtualBox fixed size virtual drive (.vdi) on Mac”

  1. How do I format my mac portable hard drive to pc? Says:

    [...] IN. TURN ON. TUNE OUT.USB External Hard DriveAnalysis of hidden data in the NTFS file systemHow to resize a VirtualBox fixed size virtual drive (.vdi) on Mac – Gubatron.com [...]

  2. Chuckvdl Says:

    Nice, except for one small detail. The screenshot you show is for a dynamically allocated disk. You can tell because the actual and virtual size is not the same as t would be on a fixed size drive. Secondly the text obscured by the tooltip is not “Fixed size storage” but rather something with ellipses at the end which does not fit in the space allocated.

    Trying this process with VirtualBox 4.1.4 results in the message:

    Progress state: VBOX_E_NOT_SUPPORTED
    VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

  3. Chuckvdl Says:

    AH but now the solution is made obvious once I noticed something When you clone the original drive to make a backup, the tool creates a dynamically allocated disk, even if the original was fixed size. So at that point you can treat your ‘original’ disk as the backup, and expand the newly created clone.

  4. How-To: Start VBox VM Using Scripts / Command Lines « Kindle VS Mac Says:

    [...] How to resize a VirtualBox fixed size virtual drive (.vdi) on Mac (gubatron.com) [...]

  5. TRASHER Says:

    I dont have .vdi but i’ve .vhd (VirtualBox 4.1.4) My problem is that I don’t know where do i have to write the command – in the terminal or somewhere else outside the Virtualbox program? ‘Coz when I wrote the command into the terminal, it said: “command not found”. What could I do? (I’m new to mac, sorry)

  6. eSbek Says:

    Using Virtual Media Manager copy your VHD file to a new VDI one. Then type the command from the Virtualbox installation folder.

  7. marcus Says:

    Hi

    I am the same problem.
    I need to resize a vdi (4.1.6) installed on Mac OSX.
    Executing

    VBoxManage modifyhd mystorage.vdi –resize 9000

    returns :

    VBOX_E_NOT_SUPPORTED

    What’s wrong ?

    Regards

    Marcus

  8. gubatron Says:

    hopefully that vdi is not too old… did you google that VBOX_E_NOT_SUPPORTED error?

  9. Jake Says:

    Hey – the guide is really nice. I’m only having trouble with the disk management part at the end. I upgraded my 20 GB to a 100GB using methods 1-2 above, however, when I got to part 3, the 20 GB “Disk 0″ was still there even when under my SATA port 0, it says ((italicized) Normal, 100.00GB)… Any idea how I can get it to say 80 GB unallocated in my Windows 7 Disk Management Part?

  10. Chris Says:

    Thanks for the tip! It helped!

  11. Siva Says:

    How do I merge the disk on Windows XP guest?

Leave a Reply