Resizing a VirtualBox hard drive image under Windows

This quick how-to shows how to expand a VirtualBox VDI disk on Windows using `vboxmanage modifyhd` and then extend the guest partition in Disk Management. It provides a straightforward sequence for adding space without attaching a second virtual drive.

Coveros Staff

December 5, 2012

I use a lot of virtual machines for the work I do. Invariably, I start with small virtual hard drives that continuously grow until I run out of space. I used to go through wild gyrations to add an additional hard drive to the machine. It’s actually much simpler to just expand the hard drive.

In my case, I’m using a Windows 7 guest OS inside a Windows 7 host OS. I do the following:

  1. Shutdown the guest machine
  2. Locate your virtual disk file which is probably stored in your Virtual Machine directory. In my case, it was in C:\VirtualMachines\Win7CppDev and it was called Win7CppDev.vdi. Adjust your appropriately.
  3. Determine what size you want for the drive. Mine started at 20GB, so I want to expand it to about 30 GB.
  4. Start a command prompt and type the following:
    C:\Program Files\Oracle\VirtualBox”\vboxmanage modifyhd Win7CppDev.vdi –resize 30720
  5. You should be able to confirm that the drive is larger in File > Media Manager.
  6. Boot the guest VM
  7. Start Computer Management > Storage > Disk Management
  8. Use “Extend Volume…” on C: partition to use the newly unallocated partition space.
  9. Restart guest OS for good measure, even though I don’t think it is needed.

Congratulations, you now have more space.

Coveros Staff

Coveros Staff

This post represents the collective insights of the Coveros team. Our staff consists of software experts who bring deep experience in secure agile development, DevOps, testing, and software quality. Over the past 20 years, Coveros has trained more than 30,000 professionals and worked with half of the Fortune 100 companies on mission-critical software development challenges. We draw on this extensive experience to share practical insights, proven strategies, and real-world solutions that help organizations build better software faster and more securely.