Programming, Windows

Virtual Hard Drive resizing

VirtualBox is one of the most useful virtualization software available for free.

Creating virtual machine is easy, just a few clicks and we are able to explore new operating system. What we need to sacrifice is some processor time, RAM memory and a few GBof hard drive. These resources can be dynamically allocated, even the hard drive.


Recently, I had set up a developement environment on a virtual machine running Windows 7. Hard disk has been dynamically allocated at 30 GB. I was running GlassFish server with MySQL database and Eclipse IDE. I also had installed ruby with rails framework along and Aptana Studio. As you can imagine VHD become insufficient. As I couldn’t afford to install everything from scratch again, I decided to extend virtual disk.

Well, extending a VDI disk is impossible, but every problem has also a solution. Following steps bellow, I was able to “extend” my virtual image:

  1. First you have to prepare an USB drive with at least as free space as your virtual disk image size is.
    You can also create a virtual disk from partition on physical disk following this instructions:
  2. Add USB disk or mapped partition to virtual machine.
  3. Find disk cloning software.
    I used Clonezilla.
  4. Run virtual machine from bootable ISO image.
    Clonezilla comes as live CD. What you need is actually an ISO image. Make sure that your USB drive or mapped partition is accessible at start.
  5. Follow Clonezilla wizard to clone virtual disk to local USB or mapped partition.
  6. Create a new virtual disk with desired size (about 100 GB dynamically allocated).
  7. Add disk to virtual machine and remove old virtual disk.
  8. On newly created disk write partitions table.
    Using GParted.
  9. Run virtual machine with Clonezilla CD again.
    Make sure you have also included USB drive or mapped partition.
  10. Follow Clonezilla wizard to restore image to virtual disk from local USB or mapped partition.
  11. At last you have to resize partition inside OS.
    In my case Windows.

For any further questions or step explanation don’t hesitate to comment.

English: Clonezilla


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s