I had a head exploding moment this morning. While trying to install SQL 2012 onto a VM I recently created and installed all of the upgrades to, I realized that I had not allocated enough memory to it. Thinking that I would have to clone my vhd and set it up again, taking hours out of my night tonight, I was loading the bullet into the proverbial chamber. I created a separate vhd that I was just going to attach to the machine to give me more room, but while researching how to get the VM to recognize the new drive, I stumbled across a way to expand my existing drive.
“Well sure, but then you have to download some third party application and spend an hour or two at least to expand it and repartition, right?” Nope. Apparantly, in the 4.0 version of Oracle’s VirtualBox, they included a way to do it in-house, so to speak. Note: This is not supported for fixed hard drives, only dynamically allocated vhds. Also, you MUST not be running on a snapshot.
First: Make sure that your VMs are shut down.
Second: Open your command prompt and change the directory to C:\Program Files\Oracle\VirtualBox>.
Third: Type VBOXMANAGE.EXE modifyhd "[full vhd location]" --resize [space in megabites], and hit enter.
You should see a screen that resembles the one below.
That’s it! When you look at your storage in the VirtualBox console now, it will show the new size. No fuss, no muss. Just don't forget to repartition when you're done!