Will's blog

purpose: Will Kahn-Greene's blog of Miro, PyBlosxom, Python, GNU/Linux, random content, PyBlosxom, Miro, and other projects mixed in there ad hoc, half-baked, and with a twist of lemon

[ home | blog home | recent activity ]

Fri, 02 Jan 2009

How to resize a virtual disk

I use VirtualBox OSE for virtualizing test environments for Miro development. I built a Windows XP vm a year ago and when I did it, I put it on a virtual disk that was 8 GB which turned out to be waaaay too small for my needs. It's non-trivial to build a Windows build environment for Miro so I really wanted to clone the partition to a new virtual disk that was a lot bigger, then resize the partition rather than create a new virtual disk and reinstall and set everything back up.

I pretty much did that this morning in a couple of hours.

First thing I did was download the LiveCD of Clonezilla (version 1.2.1-23) and the LiveCD of GParted (version 0.4.1-2).

Second thing I did was create a 25 GB virtual disk in VirtualBox.

Then I attached the new virtual disk to the winxp vm that I had. Thus it should show up as hdb.

I booted into the Clonezilla LiveCD, cloned the old virtual disk to the new one keeping the partition sizes the same and making sure to copy over the MBR, too.

I switched around the virtual disks attached to my winxp vm and booted into the new virtual disk--worked great!

I booted into the GParted LiveCD, launched qtparted and grew the NTFS partition so that it used the whole virtual disk.

Then I booted into the new virtual disk. It did an NTFS disk check on startup which I thought might indicate the process didn't work right. Disk check passed, Windows XP booted and everything worked as well as I expected it to.

Comments:

Posted by Dan V on Fri Jan 2 12:16:20 2009
I just did the same thing today.. except one step easier. I downloaded the gparted livecd with the old drive and new drive in Virtual Box. Then, I right clicked on the old (small) disk, selected Copy. Then I right clicked the unallocated space on the new (big) disk, and selected Paste. A partition resizer appeared, and I dragged the partition to take all available space. I clicked Apply, and my 4GB disk was copied and grown to 20GB (took about 10 minutes). I marked the new disk as 'boot', and started Virtual Box with the new disk. It did a check disk, then worked perfectly.


Posted by JohnMc on Fri Jan 2 15:20:14 2009
Thanks for the tip! Especially Dan V. I just tried his technique and it worked perfectly.

I pass along a trick I used in VBox. I from time to time need to test multiple client access against server development. Rather than consuming a lot of disk space setting up VDI's for the client I load client distros like DSL or Slitaz that run in memory loading them from ISO's. 256mb allocation is enough to run either distro. Once running I save the instance state. So long as I remember to make sure the instance state is saved it works perfectly.


Posted by Paul Swartz on Wed Jan 7 11:28:26 2009
Thanks for the instructions, Will!

I tried just using gparted, but something weird happened with the resize (I tried it twice) and Windows refused to start.  Using the two step process worked like a charm.


Posted by Carlos Bastos on Wed May 27 11:00:17 2009
Me too Paul!

I'll try now the two steps to see.


Post a new comment:

Three things:

  1. New comments get placed in a "draft" status and will NOT show up on the site until I explicitly approve it. Sometimes that happens within 24 hours.
  2. I reserve the right to reject/remove inappropriate comments.
  3. Sometimes I'll reply to a comment directly in email--so make sure your email address is correct.

If you can't for some reason post a comment, send me an email: willg at bluesock dot org.

Your name:


Your e-mail address (this doesn't get displayed to anyone--sometimes I'll reply directly to you):


URL of your website (optional):


Comment:


Yes, I am a human!


pyblosxom::1.5-dev git-master

Copyright 1996 to 2012, Will Guaraldi Kahn-Greene, under the Creative Commons BY-SA 3.0 license

Creative Commons License
Will's Blog by William Kahn-Greene is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.