Increase or expand the size of an existing Vmware or Virtualbox drive / machine
Author // Jim Categories // Tech Tips
So back when I was trying conserve the limited disk space on my laptop I made several small fixed disk virtual machines. This worked ok until system updates and functional software I needed for various projects filled it up so much that performance was miserable and I was stuck.
Now that I moved to a larger laptop with more disk space, I have the capacity to increase so what are my options? Rather than create a brand-new virtual machine, I just wanted to expand out the existing one. And since I use various virtualization software, I wanted a method that would work for all of them. I realize there are command line tools and various software options but I wanted to keep it free and simple.(well at least free) Here's how I solved it.
First I needed a partitioning tool so I used Gparted off of the System Rescue live CD linux distro which I found here http://www.sysresccd.org.
My examples used both the free Vmware Server and Virtualbox
My example VMs aren't in critical shape yet but the method is the same. So here's our first VMware Serverl VM running Windows 2000 with a 5GB drive:

I created a second dynamic drive that I set to a size of 8 GB and added it to the virtual machine.(don't worry we'll eventually get rid of the original)


So now your VM should show the two drives

Now put the System Rescue CD into your computer and tell your VM to boot off of it.

Once it boots into the System Rescue Live CD, type 'wizard' to get to a graphical interface

I usually just take the default of Xorg-run and it works fine (hopefully for you too)

Now when the graphical interface comes up click on the Gparted shortcut at the bottom

Now you will see both the original drive(/dev/sda) and the new one(/dev/sdb)

Select the original drive (/dev/sda1) and hit 'Copy' at the top

Select the new one drive from the drop-down at the right (/dev/sdb)

And create a partition table on /dev/sdb. You can just take the defaults but you need to do this before you can paste.

Now paste the /dev/sda1 into your /dev/sdb and tell it to use the entire /dev/sdb by either dragging it out graphically or just putting in the maximum size

The pending operations will appear in the bottom frame of Gparted. Hit 'Apply' to copy over the partition.

It's copying....

It's done!

With the newly copied partition(/dev/sdb1) selected go to Partition - Manage Flags

Remember to set the 'boot' flag

Then Quit out of Gparted and Exit from the System Rescue Live CD graphical session.

Then exit from the System Rescue CD as shown below

Now go back into the Vmware settings and remove the old, smaller drive

With Windows virtual machines it will sometimes force a chkdsk on first boot. I let this go and then it seems to correct any issues with the Master Boot Record(MBR) and everything is fine on subsequent boots. With Linux VMs sometimes it boots without issue and other times I need to setup grub (the boot loader). If your Linux VM does not boot then put back in the System Rescue Live CD and boot from it. When you get to the prompt don't worry about going into the graphical UI. Issue the following commands:
# grub grub> find /boot/grub/stage1
This will return something like (hd0,1) Whatever is returned use it as the basis for the following commands
grub> root (hd0,1)
Note the space between root and the parenthesis
grub> setup (hd0)
Note the space between setup and the parenthesis
grub> quit
Quit out of grub and then issue the 'shutdown -h now' command to leave the System Rescue Live CD. Reboot your machine again and see if you are good. If instead of booting to your OS it throws you into a "grub>" interface then redo the commands above and issue a 'reboot' command instead of "quit". That should fix it.
Enjoy the new found space.

For a similar example this time with Virtual Box running a Fedora 10 virtual machine. Do the same thing as before and add an additional hard drive. This time I added a 12 GB drive.



Now we can see our virtual machine with both drives available

Put in the System Rescue CD and tell the virtual machine to boot from it. Repeat the steps above using System Rescue Live CD to copy the partition over and set the proper flags on your new drive. Once you are done with System Rescue then reset your virtual machine to solely use the new drive. Make sure to set the new drive to the 'Primary' here.

Boot from the new drive. If you have issues booting the new drive see above in the article for troubleshooting advice.

Comments (0)