Virutalbox: Resizing a static disk



Yesterday I launched one of my virtual machines to find out that I am low on space. I wanted to expand the static (fixed size) disk but apparently this couldn’t be done on a static disk. Some posts indicated that one could clone the disk as a dynamic one and then resize that.

I wanted to resizing the vdi disk from 7GB to 12GB. To do this I

  1. converted the static disk into a dynamic disk using
    vboxmanage clonehd disk-name.vdi new-disk-name.vdi
  2. resized the disk using
    VBoxManage modifyhd new-disk-name.vdi --resize 12000  #12000 is 12000MB
  3. replaced the disks in the settings of the machine (ie; removed the old disk and added the new disk)

But this did not solve the problem. Albeit the disk is now dynamic and 12GB in size, still the additional space was detected as unallocated space in the virtual Ubuntu 12.04. Given that the unallocated space was added to the end of the partition table, there was no way of resizing the root partition.

Twenty minutes earlier I thought of it some more and I had another idea that seemed promising but a little risky. It goes as follows.

Since the filesystem is composed of a root partition and followed by a Linux swap I had to get rid of the swap partition first. Here’s what I did:

  1. Launched the machine and booted a (live) Ubuntu Saucy iso
  2. Launched Gparted
  3. Unswaped the linux swap partition (any ideas why it was locked?)
  4. Deleted the swap and the extended partition it was under
  5. Resized the root partition
  6. Recreated the extended and swap partitions
  7. Restarted the machine and booted into the virtual Ubuntu 12.04 and checked the disk in Disk Utility.

There you have it. It works and all it took was 10 minutes.

I am not sure if someone has written about this solution; I personally haven’t found it during my quick search but inspiration to solve the problem came from reading several thread posts mainly two on askubuntu [1] and stackoverflow [2].


[1] AskUbuntu
[2] StackOverflow


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 )

Facebook photo

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

Connecting to %s