11Jan
2009

Tags: ,

Virtualbox Logo

Lately I’ve been interested in learning about a variety of the Operating Systems that are available today. I’m a big advocate of using the right tool for the job so experimenting with the latest OSes is a must in order to figure out the strengths and weaknesses of each. While experimentation is a great way to learn it can be a bit of a pain to find an old machine, format the hard drive, and install an OS. Dual booting is an alternative option, but there is the inherent risk of messing up the current state of your machine.

Overcoming these issues was always a bit of a challenge for me until about six months ago when I stumbled upon VirtualBox. VirtualBox is Sun’s “family of powerful x86 virtualization products.” VirtualBox allows you to install and run “guest” operating systems in their own virtual environment on top of a “host” operating system. I know that virtualization has been around for a while, but until finding VirtualBox, I’ve never had much success running virtualization software. VirtualBox is different. It’s intuitive and easy to use. Here are the top 5 reasons why I love VirtualBox:

  1. Cheap Machines for Easy Experimentation
  2. No More Dual Booting
  3. Networking Works
  4. Virtual Machine Cloning
  5. Guest Additions Make for Seamless Work

1. Cheap Machines for Easy Experimentation

If you’ve ever wanted to try out a particular OS, but didn’t feel like dealing with the hassles mentioned above then VirtualBox may be exactly what you are looking for. VirtualBox allows you to install guest operating systems in their own virtual environment which means there are no side effects on the current state of your machine (other than taking up some hard drive space of course). If you mess something up simply discard your virtual machine (VM) and start over.

The net effect is that you save a lot of time. No need for additional machines, formatting, or partitioning. Simply create a new VM, mount the CD drive (or an .iso image of the OS you want to install), and fire up the virtual machine.

VirtualBox settings window
VirtualBox allows you to install a wide range of OSes including, but not limited to Linux (Ubuntu, etc.), BSD, Solaris, Windows (including 3.1). For a full list of guest operating systems click here.

2. No More Dual Booting

When I first started dual booting years ago I appreciated the fact that it was possible to run two (or more) operating systems on the same machine. This proved to be very useful when I wanted to play video games, write, or work with multimedia and graphics tools using Windows, but wanted to develop software using the tools available under various flavors of Linux. There was a problem however. Sometimes I would want to do work that required tools available in one of the OSes but not the other. Other times I would simply prefer to work in a way that favored a particular operating system. In either case I would often have to reboot my machine, select a particular OS, do my work in that OS, and then reboot back to my main operating system. As you can imagine this was quite painful.

With VirtualBox you can have the best of all worlds. You can work with as many OSes as you want at the same time. I do this a lot particularly when developing websites. I can run a full LAMP stack on an Ubuntu Linux guest operating system while I use photo editing software on my Windows host machine. As a bonus you can place the guest OS into “Full Screen” mode and be totally ignorant of the fact that you are running a virtualized operating system. Best of all: No reboots required.

VirtualBox running inside of Windows
VirtualBox running inside of Windows.

VirtualBox running in full screen mode
VirtualBox running in full screen mode.

3. Networking Works

One of the most exciting aspects about VirtualBox for me is that networking works between guest and host operating systems, guest and other guest operating systems, and guest operating systems and external networks (i.e. the Internet). This has a lot of interesting implications. One thing that I’ve been able to do is set up an old Dell computer in my closet running two VirtualBox VMs. I have Ubuntu Linux installed on both VM instances. I use one VM to serve as a centralized Git source code repository (you are using Git, right?). The other VM hosts a LAMP stack for serving a simple Wiki. On my network these two VMs act as individual machines. I can restart, shutdown, or in any other way modify one VM without disrupting the other.

With previous versions of VirtualBox networking could be slightly cumbersome to set up, but version 2.1 makes setup a breeze. If you do try VirtualBox and get caught up along the way there is plenty of documentation and a strong development community to help you out along the way.

VirtualBox networking
VirtualBox networking allows for communication between guests, hosts, and outside networks.

4. Virtual Machine Cloning

I once spent a lot of time setting up one of my virtual machine guest environments to the exact specifications that I needed. I downloaded tons of software, added bash aliases, and tweaked various configurations to suit my needs. Then an interesting thing happened. I ended up needing another VM with the exact same specifications. Taking the time to manually configure another VM wasn’t really an option. Fortunately VirtualBox has built in VM cloning* support. All I had to do was run the following command:**

VBoxManage clonehd </path/source.vdi> </path/target.vdi> -format VDI

This saves a lot of time by reducing the effort needed to reproduce the guest virtual machines that you have previously set up using VirtualBox. This also allows you to share your environment with other people by simply giving them access to your .vdi file (VirtualBox VM instance) and configuration settings. In addition, once you set up a pristine environment you can clone it and always have it stored as a backup incase you mess something up with the VM you are currently working with.

*There is a bit of a bug in VirtualBox 2.1. The clonehd command seems to be generating corrupt .vdi files. In the meantime as a work around you can simply copy the .vdi file, paste it into a target directory, and then run VBoxManage internalcommands sethduuid <target.vdi> command (thanks to The Bonobo Journal for the tip).

**Note: On Windows don’t forget to make sure you add the VBoxManage application to your path so that you can run it from the command line.

5. Guest Additions Make for Seamless Work

If you decide to install VirtualBox you will definitely want to install the “Guest Additions” package that is available for most guest operating systems. Guest Additions allow for better interoperability between your installed guest VMs and your host system. A few of the best features included with Guest Additions are:

Shared Clipboard – gives you the ability to bi-directionally copy and paste text between guest and host operating systems.

Independent Mouse Control – permits you to move your mouse between guest and host systems. Without Guest Additions installed your mouse is “captured” by the guest virtual machine until the “Host Key” is pressed (usually the right ctrl key).

Better Video Support – allows you to resize your VM window while also dynamically resizing the screen resolution of your guest operating system.

Resized VirtualBox Window
With Guest Additions installed VirtualBox screens can dynamically be resized to any screen resolution.

Conclusion

Besides simply saving time, space, and energy there are a lot of real world applications for VirtualBox. I really like to setup multiple VMs on my host machine to serve as development and staging environments for the various web applications that I work on. Also I like to test my web applications using a combination of different operating systems and browsers (especially various Windows/Internet Explorer combinations). With VirtualBox this is all very straight forward. In the future I would like to use VirtualBox to experiment with running multiple VMs over a network to learn more about setting up clustered, load balanced environments.

There are other virtualization and emulation tools on the market (VMWare, Xen, Wine), but I find that VirtualBox has the right mix of performance and ease of use to suit all of my development needs.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • DZone
  • FSDaily
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter
  1. 31 Responses to “5 Reasons VirtualBox Rocks My Socks”

  2. Justin, you are right on the dot with all these 5 points. I have tried VMware, Qemu and Virtualbox and Virtualbox really tops them all.

    Also, thanks for leaving a comment on my blog.

    By Damien on Jan 11, 2009

  3. Is it free?

    By Ross on Jan 11, 2009

  4. @Ross

    VirtualBox is free and open source!

    By Justin Spradlin on Jan 11, 2009

  5. you should really try kvm it’s the fastest ever!

    By Romek on Jan 12, 2009

  6. There’s an annoying bug right now where Net/Free/OpenBSD will core dump randomly when running under VirtualBox. The team is aware and working on it.

    By Kint on Jan 12, 2009

  7. @Romek

    Thanks for the suggestion. I’ll have to check kvm out.

    @Kint
    Thanks for the update. I’ve noticed a few random issues as well, but overall the software is pretty incredible. Thanks for commenting.

    By Justin Spradlin on Jan 12, 2009

  8. Hi,

    Nice article on virtualbox. I’m a beginner PHP developer who has normally used windows XP as a desktop.

    I just installed ubuntu in virtualbox, and would love to learn how to properly setup the LAMP environment and other dev tools to make my life easier.

    Would you be free on IM to chat to help me through some of it?

    Oddly enough, I’m also located in DC!

    Ls1dreams (at) yahoo (dot) com if you’d like to help.

    By Neil on Jan 12, 2009

  9. @Neil

    Setting up LAMP is pretty staight forward in Ubuntu. Here are some great article that I think will really help you out (they helped me out a ton):

    Installing/Configuring Apache and PHP:
    Slicehost Apache/PHP5 Instructions

    Installing/Configuring MySQL:
    Slicehost MySQL Instructions

    Setting Up Apache Virtual Hosts:
    Slicehost Apache VirtualHost Instructions – 1
    Slicehost Apache VirtualHost Instructions – 2

    Making the Gedit Text Editor Much More User Friendly:
    Make Gedit Act like Textmate

    By Justin Spradlin on Jan 12, 2009

  10. VirtualBox is good, really good! But it has some limitations: (i) it is not possible to make virtual machine with more than one CPU, (ii) VirtualBox has only experimental for support PAE (Physical Address Extension). For the second reason e.g. ubuntu-server will not easly install on VB.

    By W on Jan 13, 2009

  11. Good post Justin and also good helpful comments from the readers and yourself might I add. I had considered trying out VirtualBox before but this post/comments just solidified my decision to give this virtualization technology a shot.

    By Topnotch on Jan 13, 2009

  12. Thanks for the comment Topnotch!

    By Justin Spradlin on Jan 13, 2009

  13. I’ve had problems using USB devices and COM ports on VirtualBox. I never really made them to work OK. I’m using VmWare because of this.

    By Kovi on Jan 13, 2009

  14. I found your article at the time when I just installed VirtualBox couple of days back to run Ubuntu on my Windows Desktop.

    I deliberated using VirtualBox or VirtualPC, but after reading several articles favoring VirtualBox over VirtualPC.I installed VirtualBox. Boy-o-Boy! I love it.

    You have put up some good points in this article i’m surely going to try the networking option.

    By Anu on Jan 13, 2009

  15. It’s an interesting article, but it doesn’t tell me why I would choose VirtualBox over any other virtualization product. I have been using VMWare’s VMPlayer on Ubuntu and for me it does everything you described in your article. In fact, one thing you described about VirtualBox is “cloning” a VM. With a VMWare virtual machine, I can just copy the directory that contains the VM and I’m done, no bugs to worry about such as in the VirtualBox cloning method.

    I would be interested in trying out VirtualBox if there was a compelling reason to do so. Why exactly did you find it easier to use than VMPlayer? In answering my own question the only thing I can think of is that it is harder to create your own VM in VMPlayer without using VMWorkstation which is not free. Is that the reason or are there others?

    Thanks!
    -Rob

    By Rob on Jan 13, 2009

  16. @Kovi
    I haven’t had much success with USB either. I typically use a shared folder to transfer files between guest and host systems.

    @Anu
    Thanks for the comment. Enjoy VirtualBox!

    @Rob
    This blog entry wasn’t specifically meant to be a comparison to other virtualization tools. To be perfectly honest I just randomly came across VirtualBox a few months ago, tried it out, and really enjoyed the experience so I’ve stuck with it. It meets all of my needs development needs and performs well so I thought I’d write about it.

    I haven’t bothered to try anything else yet, but would certainly like to try out some alternative tools (especially VMWare) when I get some free time. Thanks for your comment.

    By Justin Spradlin on Jan 13, 2009

  17. How does it compare to Microsoft’s Virtual PC 2007, which is also free?

    By Frank Rizzo on Jan 15, 2009

  18. @Frank
    I haven’t tried out MS Virtual PC but one big difference that I have noticed (according to MS’s website) is that VirtualPC only runs on Windows based hosts where as VirtualBox can run on Windows, Linux, Mac, and Open Solaris

    By Justin Spradlin on Jan 15, 2009

  19. I can’t seem to get a VirtualBox internal network working. Basically, I want to try simulating a network of 3 computer.

    Computer 1 = gateway/router which has 2 virtual nic’s
    Computer 2 = standard user computer with 1 nic
    Computer 3 = same as computer 2

    I have tried giving computer 2 and 3 access to the internet via computer 1, but I can’t seem to get it to work.

    Help.

    By mashcaster on Jan 23, 2009

  20. @mashcaster

    1. There are a couple of things you can try. To begin with make sure you are using VirtualBox version 2.1. Setting up networking in previous versions is pretty tedious.

    2. I’m not sure how well VirtualBox works with wireless connections so if possible make sure you are using a hard line connection.

    3. Make sure firewalls are turned off on your host operating system.

    4. Make sure that in the network settings for your virtual machine that you use “Host Interface” for the “Attached To” field. Also try playing around with the “Adapter Type”.

    By Justin Spradlin on Jan 23, 2009

  21. hi,

    i just found your blog with googling, anyway, could you please tell me how you configured the network? are the servers on your virtual network reachable also from outside?

    greets

    By Casper on Jan 24, 2009

  22. @Casper

    You can definitely access your virtual servers from outside computers on your network. For example. I have a desktop machine that runs to virtual servers and I can access them using my laptop which is on my home network.

    Configuring the network with VirtualBox version 2.1 was relatively painless for me.

    Check out the comment above addressed to mashcaster.

    By Justin Spradlin on Jan 24, 2009

  23. Great article! I’ve just stepped into the world of VirtualBox myself after a few months of pain with Xen (me being the problem, not Xen!)

    I was looking for a solution to problems cloning guests and you not only had the solution I needed, there was also a nice write up around it… thanks

    By streetdaddy on Jan 28, 2009

  24. @streetdaddy
    Thanks for the kind words. Enjoy your VirtualBox experience.

    By Justin Spradlin on Jan 28, 2009

  25. How do I put a guest os in full screen mode? I must be missing something. Thanks!

    By twtech on Feb 16, 2009

  26. twtech,
    You will first need to install “Guest Additions” onto your guest virtual machine. Here is an example of how to do that using an Ubuntu Virtual Machine. http://ubuntu-tutorials.com/2007/10/13/installing-guest-additions-for-ubuntu-guests-in-virtualbox/

    Once you have Guest Additions installed you simply need to hit right ctrl + f and your VM should go into full screen mode.

    By Justin Spradlin on Feb 16, 2009

  27. Do you have any tips for setting up apache virtual hosts in the guest os (Ubuntu) so I can access them by name on the host OS (Vista64) So if I have a project called, say project1 on guest v1, I could access it from the host as p1.v1? The best I can do is map any host to one apache vhost.

    By jake on Mar 13, 2009

  28. @jake

    I’m sure that it can be done. I played around with my virtual hosts files for about an hour tonight and had the same success as you (i.e. could could map one host to one apache vhost).

    It may have something to do with DNS entires/record, but that is far from my forte. A bit of a guess if you haven’t tried walking down that avenue. Perhaps you could create a guest DNS server and point it to projects on your various guest machines.

    By Justin Spradlin on Mar 16, 2009

  29. Re: Vbox vs VMWare Workstation, I’ve used both. VMWare was a bit slower and a little rough around the edges. I’ve got Vbox running on Ubuntu9.04 and it’s lightning fast. My winXP guest boots faster in VBox than XP did as a standalone OS on the same hardware – not including the ubuntu boot time, of course.

    The seamless window integration in Vbox is also better than what you’ll find in VMWare. It’s really a kick to have a Quicken window set against the Ubuntu desktop without any of the windows OS junk cluttering the desktop

    By Pete on Jun 2, 2009

  30. I’d the system with Windows Vista Home Basic edition. I tried intsalling MS Virtual PC, but it is not supporting on this version. Hope Vbox works.

    By Shivayogi on Jun 23, 2009

  31. hi,
    That’s great article about virtual PC

    By sudath on Oct 11, 2010

  1. 1 Trackback(s)

  2. Jan 14, 2009: [Web] 連結分享 « 網站製作學習誌

Post a Comment