How to resize a VirtualBox drive vdi

I was setting up some software on my VirtualBox OS that said it needed 20 GB of free room. The problem was that I only had 6GB of free room; I should have just made a large dynamic sizing drive to start with, but I didn’t…

Without further ado here’s how to resize a VirtualBox drive vdi

Resize the vdi

You will need to run the VBoxManage modifyhd command on your targeted vdi.

The easiest way to do this will be to:

  1. You can open up a command prompt (Windows + R then cmd) and run the following if your drive and install are default:
    1. cd “C:\Program Files\Oracle\VirtualBox\”
    2. You can then skip to step 4 otherwise follow 2 & 3 if you got a “The system cannot ifnd the path specified.”
  2. Navigate to the VirtualBox directory –
    1. If you have VirtualBox open right click on the system tray icon for it if it’s running.
    2. You may have to right click again on the program’s name in the context menu that opens up.
    3. Go to properties
    4. Then “Open File Location”
    5. It should end up being something like: “C:\Program Files\Oracle\VirtualBox\”
  3. Once in the directory hold shift and right click somewhere in the folder that doesn’t select a file
    1. The context menu should now contain an item that says “Open command window here”
  4. Now that you are in the VirtualBox directory you can run the following:
    1. VBoxManage modifyhd “C:\Users\UserName\VirtualBox VMs\Windows 7\Windows 7.vdi” –resize 81920
      • You will need to change the path to the vdi you would like to resize as well as the size in mebibytes that you would like the vdi to change to.
      • The default path to your machines and their vdi storage will be: %userprofile%\VirtualBox VMs\ (you can throw this into your windows explorer address bar)
      • Use google to find the Mebibytes via the following query; where xx is the targeted GB you would like:
        • xx gib to mib

Resize the OS Drive Using GParted

Unfortunately, it will not be enough to just resize the vdi. We created the space but the partition on the drive will not be able to utilize the space until we resize the partition.  The other gotcha is that you will not be able to use Window’s Disk Management to resize the drive if the partition you’re targeting is the same as the OS boot.

  1. For these reasons the best route is to run over and grab an ISO of GParted:
  2. After the download completes, create a new virtual machine on VirtualBox (I called mine GParted)
    • Type: Linux
    • Version: 2.6 / 3.x / 4.x (64-bit) or 32-bit if that’s what your system only has (I hope now days you have 64-bit)
    • Do not add a virtual hard disk
  3. Go into the settings for your new virtual machine
    1. I had to go into System and enable EFI because mine was having issues booting, but this may differ for others.
    2. In storage mount your GParted ISO via IDE controller
      • Check the “Live CD/DVD” option (may not be required)
    3. Also while in storage mount the vdi drive you want to resize via SATA controller
  4. Now start the GParted virtual machine up
    1. Run with Default Settings; be patient for a minute or two but if it takes longer you may have to reach out to the interwebs to troubleshoot your problem. Hit enter 3 times once prompted about settings questions.
      1. Hit enter: Don’t Touch keymap
      2. Hit enter: default language 33 is fine (US English)
      3. Hit enter: contineu to start X to use GParted automatically
      4. Enable a few seconds of patience ; D
    2. You should now see your partition in there with the newly unallocated space that you’ve added from resizing the VDI
    3. Right click on your current partition and select “Resize/Move”
    4. You should be able to drag the slider over so that free space preceding and following are both at zero
    5. Hit Resize/Move
    6. Hit Apply to save changes
  5. Once the process completes you can shut down the GParted virtual machine

Start the OS up with the resized partition

If you’re running Windows you’ll have to wait a little while on this next boot because it will have to check the file system on the drive. After that you’ll be back to your OS with all your new empty HDD space!

Sources (they have nice formatting and pictures!)

Why write up a seemingly redundant article?

How-To Geek got me really close to resizing the drive but I couldn’t get the system to boot with GParted. Looking back I may have been able to enable EFI and got it to work (although I think it wasn’t being recognized, maybe I needed to check the live disk option but I doubt that was it).

Thus I stumbled across Derek Molloy’s site which talked about creating a separate virtual machine explicitly for GParted; I really like this method as you can toss the targeted vdi you want to resize into this virtual machine and be ready to go without touching your original virtual machine’s settings. For whatever reason my GParted did not want to boot

For whatever reason my GParted did not want to boot once I did get it to show up, so I ran across a stack exchange question with the magical answer of enabling EFI, which gives another reason to create a separate Virtual Machine – it’s not going to use up any resources except the configuration and settings for it; the ISO is separate and you can mount whatever drive you want to change.

This entry was posted in Virtual Machines and tagged , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Cody Swartz David Gillooly
    Posted March 9, 2017 at 9:18 am | Permalink

    When I start Gpart (downloaded today and installed as above), I get message “Libparted Error” “Can’t have a partition outside the disk”

    Ubuntu on windows 10 VM

Leave your thoughts...

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*
*