Thursday, April 22, 2010

Managing Virtual Operating Systems Using Virtual Box

0 comments
Sun's VirtualBox is a powerful virtualization software that allows you to run a number of operating systems from within your main, host operating system.  You can install them, and pretty much abuse the 'guest OS', break it, tear it up from the inside out, and never hurt your main operating system.  This is a great tool for people who want to learn about Operating Systems like Linux and BSD.  Linux user's can even install it to run Windows inside their Linux environment if needed. VirtualBox is cross platform (Windows, Mac, and Linux).

I was tinkering with my Linux Mint 8 install (running as a guest on my Windows XP box), and I got an error about the partition running low on space.  So I immediately thought of a project.  Could I take the installed operating system, copy it and move it to a larger virtual drive?  I found several sites with instructions on how to do it, and I was unable to get the Linux Mint booting again after the move.  It was hang at a black screen with a cursor in the upper right corner.  So I did things my way.  And I was successful.

Some background info: my Linux Mint install was fresh.  I only allocated a small virtual drive of about 4 GB's for Linux Mint when setting it up in Virtual Box.  Since I primarily tinker with it, I don't need a huge amount of space.  Just enough I can use for installing some apps and playing Compiz.  But keeping my original goal of trying to relocate the system on a bigger 'virtual hard drive' without having to fully reinstall Linux Mint.

First, I downloaded two ISO files: GParted and CloneZilla.  Using Sun's Virtual Box I setup another 'virtual disk drive' of around 8 GB's and set it as 'IDE Secondary Slave' and leaving my original virtual Linux Mint hard drive as 'IDE Primary Master'.  See pictures below:
Above: Steps 1 and 2

Secondly, set the 'Host Drive D:' to boot the CloneZilla ISO file.  This will allow us to clone the installed Linux Mint Operating System to a new virtual hard drive.  When booting CloneZilla I took all of the defaults to boot and took the option to do a 'Device to Device Transfer' in the 'Beginner' menu.  This simply cloned the small 4GB partition to the new 8GB partition.  After about 10 minutes CloneZilla was finished and I tried booting the new partition to see what happened.  And it did boot.  (To do this simply shutdown CloneZilla and click on the use the Storage Manager we used a few moments ago (in the pictures above).  Click the original virtual drive (4GB) and then click the 'Remove Attachment Device' Button below the 'Storage Tree' window.  See picture:

After removing the original virtual drive, we need to set the new virtual drive to be the Primary Drive and remove the CloneZilla ISO from our virtual CD-ROM drive.  You're Storage Tree Window should look like this:

After doing this, I attempted booting my new virtual hard drive.  And behold, it booted!  But I was once again greeted with the warning about running out of space.  Then it hit me, I forgot to resize the partition after it was cloned to the new virtual drive.  So yes, I am using an 8GB virtual drive, but the operating system can only see the original 4GB's of allocated space.  So, I shut down Linux Mint, and loaded the GParted ISO file in my virtual CD-ROM drive (just like we loaded the CloneZilla ISO in the second step.

Once again taking all defaults and booting GParted, I simply deleted the Linux Swap Partition and moved it to end of the unallocated space (remaining 4GB's that was not formatted).  Then I chose 'Resize/Move' to resize the partition from 4GB's to almost 8GB's (I saved some room for the Linux Swap Partition).  Set the remaining unallocated space as Linux Swap and apply all changes.  The I crossed my fingers.  The resulting setup under GParted looked like:

 Next, shutdown GParted, make sure to remove the GParted ISO from our virtual CD-ROM in the Storage Tree in VirtualBox and boot the new virtual drive again.  Once Linux Mint booted again, I wasn't greeted with the error message so I wanted to checkout the partition in a drive/storage manager from within the virtual OS.  So I ran the 'Disk Usage Analyzer' under Linux Mint, and surprise!  The OS now see's the full partition.
Here's a screenshot of the Disk Usage Analyzer:



Now, please note: the install of Linux Mint I'm using takes up the entire partition.  I did not create a seperate Home partition when performing the install.  Mostly because I will not be creating anything worthy of keeping with this install.  Mostly just tinkering, and doing crap like this.

Have I tried this with a real life, living, breathing install on a physical hard drive...No, I have not.  However, I am in the process of piecing together a small computer setup with some older hardware that I would love to try it on.  Maybe the next rainy day, I'll be bored and give it a shot.  Overall, this whole process took up about 30 minutes to 45 minutes.  So far the OS works as normal, and I haven't received any other crazy errors as a result.  But remember, as always: TRY AT YOUR OWN RISK.

Have fun!

0 comments: