Expand virtual disk

If the virtual disk of guest operating system is getting full, then you should know, that you can easily expand it. Let say that you want to expand your Windows guest’s disk and have just one disk, which is larger than previously.

If you are using VirtualBox 4.0 (or more recent), you can achieve this in a two phase process. First you have to use VirtualBox tool to expand the disk size, and then use GParted to expand Windows partition within it. I assume that you understand the difference between disk and disk partition. Just expanding the disk will not miraculously expand Windows partition within it.

First we use VBoxManage to expand virtual disk. This works only with disks that have dynamical size, and to expand only.


VBoxManage modifyhd YourVirtualDisk.vdi --resize NewMaxSize

Now the maximum size of disk is NewMaxSize in Megabytes. Now take what ever Linux LiveCD (e.g. System Rescue CD) you may have and boot your virtual machine with it. It can be ISO image or real CD. Attach it in virtual machine and start it up. Then use GParted to expand the Windows partition in it, so that it takes all unused space on the disk. Apply the changes you made on the disk, exit GParted, and reboot virtual machine. Now you have one disk, which is bigger than before.

Of course, if you prefer, you could just format the unused space as a separate partition within disk. In that case you can skip the GParted phase.

If you are using previous versions of VirtualBox (pre 4.0), then you have to create a new empty disk with new size, and attach it into the virtual machine. After booting virtual machine with System Rescue CD, you have to clone the contents of old disk on the new disk.


dd if=/dev/sda of=/dev/sdb

Then use GParted to expand /dev/sdb1 to cover all available space in /dev/sdb. Then shutdown the virtual machine and detach the old disk from virtual machine. Now you should have only the new disk attached to machine. Start up the machine, and you should have more disk space.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

  • Enter your email address to follow this blog and receive notifications of new posts by email.

    Join 98 other followers

Follow

Get every new post delivered to your Inbox.

Join 98 other followers

%d bloggers like this: