Monday, January 12, 2009

Resize a VirtualBox VDI


Recently we wanted to create a series of vdi images. Each image would be built with a minimum disk size and increase. The issue we discovered however is increasing the size of the vdi files as we migrate to each successive image.

Here is a simple solution from the Crooked Spoke blog.

Since the blog is now offline swiped the original post from the Wayback machine.

There are quite a few advantages to using VirtualBox, an open source virtualization software, over the industry-standard VMWare, not the least of which is that the former doesn’t nag you for serials.




Unfortunately, VirtualBox is lacking in some functionalities I’d like - one of them is to resize a VDI (virtual disk image) after you’ve created it. I ran into a problem when I once created a 6GB disk image for a virtual install of Fedora 8 on a Windows XP host. I got to the point where it needed more space. Unfortunately, this is not a built-in functionality in VirtualBox.



Fortunately, there is a way around it. What you’ll need:



•A Gparted LiveCD, or some similar rescue CD or LiveCD

◦VirtualBox (and to be fair some other virtualization software) allows you to treat raw ISOs stored on your hard drive as virtual optical disks for the guests. This is very flexible and convenient - the Guest VM will “see” a regular CD or DVD. Further, this is probably faster than running through an optical drive.

◦Specifically, any LiveCD with the Linux utility dd will suffice for the first part (copying the existing data from one VDI to another), but you’ll need some sort of partition resizing software for the second part (setting your virtual machine’s OS to use all of the new, bigger virtual disk). For that reason, I suggest Gparted or any other rescue disk with both dd and partition resizing software.

•Two virtual disk images

◦The old one (the one that you’ve found is too small) with an operating system

◦The new one (made with a larger size); it should be “raw” (unpartitioned)

The general steps are fairly simple if you’re already familiar with Linux and VirtualBox. Sorry - if you’re looking for lots of screenshots and hand-holding, look elsewhere.



1. If you want, burn the Gparted LiveCD to a CD - it’s a nice tool to have around in general, but not strictly needed if you plan to mount the raw ISO as a virtual optical disk.



2. Back up the old VDI and Machine (in case Murphy’s Law kicks in), unless your VM is expendable.



3. Using VirtualBox, create a new VDI with a larger size that you want to expand the virtual machine to



4. In VirtualBox set the “virtual bios” for the machine to boot from CD before the virtual hard disk



5. Leave your existing VDI as the primary IDE master. Set the new VDI to be the Primary IDE slave for the machine.



6. Put in the LiveCD and let VirtualBox know that it is to “present” your physical optical drive to the virtual machine, or point VBox to the raw .iso of Gparted on your hard disk. (The idea is to boot into the virtual machine with the LiveCD.)



7. run fdisk -l (that’s fdisk-space-dash-lowercase-l) to view your partitions. You should get /dev/hda and /dev/hdb. /dev/hdb shouldn’t be partitioned at this point. /dev/hda should be your primary master (the original VDI that is too small for your needs), and /dev/hdb should be the new image (virtual primary IDE slave).



8. Do not mount those. You don’t need to for this procedure. Instead, use dd to copy the old image to the new one:



dd if=/dev/hda of=/dev/hdb



This will make a copy of the original image (the one that’s too small) on the new one that’s bigger. This step may take awhile.



9. For good measure, you may wish to run fsck on the newly created partition.



10. Launch gparted, and resize the partition on /dev/hdb (the new image) to take up the entire disk. This may take awhile.



11. Poweroff with the GParted LiveCD once this has completed.



12. Finally, set the new image (resized) as the primary master for the virtual machine. Uncheck the primary slave. Boot into the machine to verify that it worked.



This worked for me in expanding a ~5GB virtual disk image to ~15GB (Fedora 8 Guest, Windows XP Host - the steps should be pretty much the same for a Linux host). Your mileage may vary. If all went well, you should now have your working install from the smaller VDI on a larger VDI. I did have problems when I first booted up the virtual machine using the new VDI as the primary master, but it was fixed by running fsck on the file system that the Fedora 8 VM complained about (hence step #9). If it does complain, boot up using the LiveCD/.iso image again and use that to run fsck on the dirty file system.



I’m not sure if this is doable with a virtual disk image with multiple partitions.



Once you’re done and have confirmed your guest OS sees the new disk image at its proper size, take your old VDI and do whatever you want with it - keep it for a backup, delete it, shred it, or whatever.



UPDATE: I have tried the above procedure - modified slightly - with VMWare virtual machines (specifically Server 1.0.6) and can confirm that I’ve managed to use a similar process with success with vmware.



To those of you who have expressed problems with the above procedure, I have been unable to duplicate the issues. Keep in mind that, as always, this guide comes with no warranty and that, as always, YMMV.


Tuesday, December 30, 2008

Firefox 3 Cookies Issue

Recently my computer did what all computers did and started to demonstrate they are emotional entities. It just got mad at me and quit saving any login information on sites I visit and have tabs open to most of the day.

This is one of those situations where I don't know what the cause was but the cure was easy enough. It had to do with deleting the cookies.sqlite as described here.

Tuesday, December 2, 2008

Favorite Windows Vista Sidebar Gadgets

There are some helpful gadgets on this list.

Wednesday, July 16, 2008

Email not working

When working with a client today on email problems I realized I had never provided a simple tutorial for helping with email problems. As a user of Thunderbird, Outlook and/or Outlook Express you might have run into a situation where you can't send and/or receive emails for a new email account that has been set up. Sometimes it can be traced to a configuration problem when setting the account up in your email client and other times it can be a problem with your Internet Service Provider (ISP) or the email server you're attempting to use.

To remove your email client from the equation you can test your incoming mail server (the server you check when picking up email) and your outgoing mail server (the server that is used for delivering emails that you author).

Here is a simple tutorial for testing a POP3 incoming mail server and a SMTP outgoing mail server..

Monday, July 14, 2008

Remote Desktop Connection on Windows Vista Home Premium

In case you've only found blogs that say it can't be done then buckle up boys and girls, Tony Chan has come to the rescue and the ride isn't even a harrowing one.

Steps to Add Remote Desktop to Vista Home Premium:

1. Download termsvr.zip here
2. Extract Termsvr.zip to a temp directory
3. Start "Command Prompt" in Administrator mode (Run As Administrator)
4. Run the corresponding batch file for your Vista edition
5. Allow TCP Port 3389 on Windows Firewall or any other firewall product.
6. Done
source: Remote Desktop on your Windows Vista Home Premium

In the event that the link to Tony's blog entry goes bad let me know and I can email you the termsvr.zip file.

Wednesday, July 9, 2008

Windows Server 2003 Administration Tools Pack

Recently I upgraded my main laptop to Windows Vista Business and as usual it begins the search for the newer versions of some of the tools that you've become so accustomed to using. This blog post has to do with the Windows Server 2003 Administrator Tools Pack. If you haven't used it before I'd recommend you check it out.

Windows Server 2003 Service Pack 2 Administration Tools Pack for x86 editions

Thursday, July 3, 2008

Dell Bluetooth Travel Mouse


We recently ordered 4 new Latitude D830s for a client with the Bluetooth mice and upon received had an interesting experience. Granted my experience with Bluetooth is limited (okay non-existent except for my phone headset) it was still interesting. The paperwork that came with the mouse shows that when setting up Bluetooth you just select the "Don't use a passkey" item. Well the problem is either those were written for Vista (and we're using XP Pro) or the aren't using the Bluetooth utility that comes with the new Dell. After a few minutes of seaching it appears the mouse does indeed have a PIN.

Putting 0000 in the PIN window connected the mouse successfully and we had the pretty Dell BT Travel Mouse in the Bluetooth Settings utility.



Thank the Lord above for simple solutions.