PCs

DIY: Use VirtualBox to serve up virtual machines

Jack Wallen describes how to create virtual images and serve them over your network using free virtualization software called VirtualBox.

Commercial virtualization products such as VMware are effective but costly tools that enable a company to serve up different virtual machines. One alternative to these solutions is the free VirtualBox virtualization software, which is available for Linux, Windows, and Mac. With VirtualBox, it is possible to create as many virtual images as you like and then serve them up over the network. This is a tutorial on how to do that in VirtualBox.

Host and guest defined

You need to understand what host and guest mean, or else this tutorial will be quite confusing.

  • Host is the operating system that serves up the virtual machines.
  • Guest is the operating system running on top of the host that is served up in a virtual environment.

Setting up a virtual machine

You can have a VirtualBox setup with almost any configuration. You could use a Windows host with Linux or Windows guests, Linux hosts with Windows or Linux guests, or Mac hosts with Linux or Windows guests.

It is required to have VirtualBox and the VirtualBox Extension Packs installed on the virtual machine server. You don't need to have the application installed on the client. If necessary, the Guest will have to be set up so remote access is allowed; the way this is done will depend on what operating system is used as the Guest. The Guest on VirtualBox will have to be configured to have the VRD Server enabled and configured. To do this, follow these steps:

  1. Make sure the Guest operating system is Off (not suspended).
  2. Select the Guest operating system to be served up remotely.
  3. Click Configure.
  4. Click the Display tab.
  5. Click the Remote Display tab (Figure A).
  6. Check Enable Server.
  7. Set a server port that will not conflict with a port already in use.
  8. Select an Authentication method.
  9. Enable Allow Multiple Connections if you want more than one connection at a time for this virtual machine.
  10. Click OK.

Figure A

Click the image to enlarge.

Now that one virtual machine is ready to be served up.

Hosting the virtual machine

I'll explain how to connect to a Kubuntu virtual machine. (I'm assuming you have everything installed and up and running successfully.) The Guest should not be running on the server because it is going to be made available with the help of a command VboxManager; this command allows you to turn "on" a virtual machine so it is available remotely. The usage of the command is VBoxManage modifyvm VMNAME --vrde on (VMNAME is the name of the virtual machine to be turned on). This command will turn "off" the virtual machine: VboxManage modifyvm VMNAME --vrde off. (When using VirtualBox on Windows, you will want to change to the C:\Program Files\Oracle\VirtualBox directory before you run the commands.)

The commands are instructing VirtualBox to make available the virtual machines via the virtual rdp which, by default, is served up on port 3389. So let's assume the address of the VirtualBox server is 192.168.100.21, and let's turn on the Kubuntu virtual machine with the command VBoxManage modifyvm Kubuntu -vrdp on. The next step is to fire up the virtual machine and leave it running. Now clients can connect to that virtual Guest through the Host.

Now let's hop over to a remote machine and, using an rdp connection tool (such as Terminal Server Client), connect with the address 192.168.100.21:3389. Depending on your network speed, you should see the virtual machine begin booting up right away.

If you don't want to have the virtual machine running on the host, you would run the VboxHeadless command on the Host machine: VBoxHeadless -startvm "VMNAME" (VMNAME is the name of the virtual machine to be run). This method does not require the virtual machine or VirtualBox to be running at the time.

Conclusion

VirtualBox is not as robust or as flexible as the VMware vSphere system, but this setup will get DIY administrators on their way to virtualization and serving up virtual machines across their networks.

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

32 comments
BALTHOR
BALTHOR

VBox could install on an empty drive.The operating systems would then be selected from a page at boot up.One or more operating systems could be selected.Copy/paste between the operating systems and you're in.The power of the computer goes to the active OS.Instant select and instant on,a boot to a snapshot.Files in the RAM.One OS for audio another for video is an example.It all works out of the package,networking shared folders and so on.

BALTHOR
BALTHOR

VBox is a free download,for now.Somebody is sneaking contribute in there.I see virtual more as a novelty.I use it to look at ISO's and vhd's.It's much fun to install an OS and see it work.I will make a vhd and save it to a DVD.You don't need to make your virtual hard drive all that big either.There's some memory and CPU stuff to adjust and that's interesting.Boot to USB would be great.

wranilus
wranilus

At one on my clients, I installed VirtualBox on Windows SBS 2003 and loaded it up with windows xp virtual machines. Users with iPad have Mocha Remote Desktop (RDP) on their tablets and through the corporate WIFI they access the ERP win32 client, SysgestockERP with no effort as if they were on a PC. I use phpvirtualbox for web administration of the virtual machines. They love this solution.

eric.van.rheenen
eric.van.rheenen

I have a dual booted notebook with windows and openSuSE running. I use VMware, which is using my windows partition so that i can run windows applications when using the Linux OS. I don't have to be affraid to have synchronisation problems when i reboot and start using windows. I also don't lose diskspace on my Linux partiton for the virtual disk. Is there a way to do this with VirtualBox aswell. Thus running on the Linux host and using the windows partition as the guest OS ?? And naturally also the other way around.

Andrew Happ
Andrew Happ

I remember a few years ago with VM Server 2 that I had some problems with Usb. How would you rate the robustness of Usb passthrough on Virtual Box, in a general sense?

lastchip
lastchip

I've used VirtualBox, but only on a desktop machine (Debian), which of course has a "normal" desktop in the form of a GUI. Can VirtualBox be used on a server which is text based only and if so, how does the interface appear? Is it all done via the command line, or is it browser based, similar to Webmin or phpmyadmin? Any advice would be appreciated.

pfyearwood
pfyearwood

I prefer Virtual Box over VMWare and Moka5. It is simple to set up a guest OS. I use it mainly to test new Linux/GNU distros and to practice installing a different OS from my normal Ubuntu. The best part is you don't have set up partitions the traditional way. When you get rid of a guest OS and all its files, you do not have repartition. I thank Mr. Wallen for showing how to actually set up a server to allow usage of a virtual machine. While I always download a fresh install from Oracle, there is a virtual box open source edition. It however, is usually a few versions behind the original version. VBox also lets you know when a new version is released. The download page at www.virtualbox.org has a version for nearly every OS in use. The Linux selection covers every major distro so you should not have to rely on your repositories. I find Virtual Box helpful and just plain fun. And I am not a trained IT pro. Just a heavy duty tinkerer. Paul

tim.stephens
tim.stephens

In stopped using vmware when it got bloated and slow....Virtual box is much slimmer code and very fast, may miss a few enhancments but I haven't missed anything I needed.

gpachello
gpachello

I've a workstation (Windows 7 - x64) with Virtualbox as host, and Hyper-V - ESXi as guests for testing and learning purposes and works very fine for me. Regards. GDP.

carl.gerlach
carl.gerlach

Hi, I've been working with various versions and Guests configuration for over a year. I've never used the remote connection. (I wasn't sharing my VM's). My question is, with a DHP serving up the IP Address for my Ubuntu Guest (Bridged Adapter) How can I find out the IP Address of the Ubuntu Guest? THanks, Carl

jorglct
jorglct

I continue working with VMserver2.0, is a old system but like more of virtualbox. Have a lot of appliance and complement with GNS 3.0 to make laboratories of telecommunications.

Neon Samurai
Neon Samurai

When I looked last, the official Virtualbox website was directing people to the Virtualbox Community Edition website for free download. I think it may have included a "not for commercial use" clause also. One may want to look at that if your intending it for commercial use; especially for public facing systems.

Bjarni Runar
Bjarni Runar

Thanks for this article, Jack, it's great to see VirtualBox getting more attention! It's a really useful tool. :-) I find that combining VirtualBox with PageKite (which you wrote about a while back, http://pagekite.net/), works really, really well - you can set up your own virtual web host and then use PageKite to expose it to the wider Internet, without having to worry about the network configuration at all. You can also use PageKite to allow ssh logins from outside to the VirtualBox, in case you want to collaborate with someone or do remote administration. (disclaimer: I wrote PageKite - but couldn't resist commenting as this happens to be exactly the set-up I use for our internal development environment: a bunch of virtual machines which run tests and experimental versions of our site and are accessed using PageKite itself.)

Neon Samurai
Neon Samurai

(or, are you doing that with VMware Server?) Looking at Virtualbox Community Edition; .vmdk, .vdi, .vhd, .hdd (parallels) though on the *nix side, you might be able to tell it to open the device partition directly (/dev/sda1) since devices are represented as files. Hm.. ok, so Virtualbox calls it "Raw Hard Disk Access". The link has lots of warnings about using it and seems to read like it's Virtualbox on a Windows host OS but I can't see why the given steps wouldn't work under a *nix host OS: http://www.sysprobs.com/access-physical-disk-virtualbox-desktop-virtualization-software

Neon Samurai
Neon Samurai

I regularily use virtuaboxheadless to setup up VMs before I start up a graphic desktop but there is full command line support from what I can tell. Creating VMs, modifying config, booting, deleting.. it's all there.

Neon Samurai
Neon Samurai

If your Ubuntu guest has a bridged network adapter then whatever IP it shows is the VM's IP on the network. I'm not sure what GUI tools you have in place that would display the IP though I'd guess something under the network manager (GNOME top right, KDE taskbar) should provide network information. If it comes down to using command line, open the terminal and try: sudo ifconfig and see what IP your eth0 or applicable network device is showing. If you really want to get technical about it, look at what MAC address Virtualbox assigned to the NIC under advanced settings (in the VBox manager GUI) then check our router or otherwise scan the network to see what IP that MAC address is on. This shouldn't be anyone's first choice though.. I just include it for fun.

Neon Samurai
Neon Samurai

That was what killed it for me. VMware was my first and does indeed deserve to be the brand leader in the market but not being able to deliver a VMware Server 2 that installed and ran clean on Debian 5 killed it for me. Debian is just not obscure enough a distro to not deliver packages for; especially if they can deliver Ubuntu .deb packages. If they had focused on Debian use, Ubuntu could ahve inherited it. Virtualbox was also in the Debian repositories making install and updates a natural part of the package management process. When Virtualbox delivered easy bridged networking setup, VMware was outclassed for my needs. The only other feature I miss is "start on host system boot" but I can script my way around that almost as easily as selecting a config checkbox so no biggie. Still, for a production system, I'd be looking at a dedicated server like VMware ESXI Offhand; Anyone know legalities of ESXI Free 64bit on production servers? At 1400$ per CPU ESXI retail may be out of budget range for even a humble two CPU rack server.

Bjarni Runar
Bjarni Runar

The community edition is GPL licensed, which means you can use it for whatever you like, including commercial activity. The only restriction is that if you modify the VirtualBox code itself and distribute your changes, then you have to make sure you comply with the license (distribute your own changes under the GPL as well).

Neon Samurai
Neon Samurai

My first go at Virtualbox was before it provided bridged networking through the standard NIC pulldown config. Now, you just select bridged isntead of NAT or host only and your VM apears on the network indistinguishable from a physical machine and NIC. The decision may then be using pagekite and configuring that hosts's networking or simply using bridged networking on your VM keeping website and network config consolidated.

pgit
pgit

I don't see linux listed as a host OS anywhere for ESXI.

eric.van.rheenen
eric.van.rheenen

I use a somewhat older version of VMware server at the moment. I will give virtualbox a try. Thanks for the response.

lastchip
lastchip

I'll have to look into it further.

tbmay
tbmay

You just gotta do a bit more than RHEL. I'm running it on several Lenny servers just fine. I'll see if I can get you some procedures. On thing you want to get used to though....tunnel through ssh to use the web interface....on 8222....and copy your links for your console. Once you get used to those two things, you'll not miss a beat. But yes....I agree. ESX is the standard, and the one to use for serious virtualization.

jstevensfit
jstevensfit

There are no legalities of running ESXI on production servers; I ran 70% (about 24 ESXI servers ) of my enterprise off the free version. If you read the faqs page they basically encourage it -> http://www.vmware.com/products/vsphere-hypervisor/faq.html If you use the free version then you don't get the ability to use vmotion, high avail, etc.....but most organizations don't need this functionality(it would be nice but not a requirement to running a successful infrastructure using ESXI)

Bjarni Runar
Bjarni Runar

If you want it externally visible (to the outside world, not just your LAN) then PageKite may (or may not) be more convenient than reconfiguring your routers and firewalls. It just depends on what you are doing, really.

jstevensfit
jstevensfit

ESXI is not a hypervisor that sits on top of another OS. Think of ESXI as a standalone OS that you install just as you would a regular version of Linux or windows. As robo_dev mentioned it's essentially running a proprietary version of Linux. The beauty here is that you can run solaris, windows and Linux virtual machines, etc without the overhead of another OS because it is the OS. That plus the ease of use is worth it.

robo_dev
robo_dev

It is really a stripped-down Linux kernel under the covers, though. ESXi is awesome; I run it at home and am in the process of doing server consolidation. And it's free.

Neon Samurai
Neon Samurai

I just did a quick search and found lots of writeups. Personally, I'm mostly use vboxheadless: vboxheadless -s [machinename] but vboxmanage seems to be the primary command you want to read up on.

tbmay
tbmay

Is they're going to stop supporting VMWare Server, if they haven't already. I did run in to several small businesses where Server makes more sense. I've deployed, and I use esx. However, it doesn't support softraid, and getting the most out of it means thinking about external storage. This means more $ for the customer. It's also picky about hardware. This is not too much of an issue now as I wouldn't buy a server to run it unless it's sure to work; however, it does mean you can't NECESSARILY use just any hardware the customer might want to use.

Neon Samurai
Neon Samurai

The https web interface didn't work well. When able to connect by port 8333, it'd sort of work or crash out completely. Cleartext port 8222 was fine for local use but this meant living with the second issue: Restarting the VMware services meant a hang of ten minutes or more before it would fail out of trying to halt the management process. Restarting my computer for an hour of gaming or any other reason meant suffering that same hang and error out unless I took the system down hard with the power button (not advisable). If VMware is going to provide there own packaged bundle with installer script, they need to make it actually work and install the software clean. None of this installed-but-broken that I saw no end to after every Debian and Ubuntu related howto I could find including the third party installer patch methods. Now on Debian 6, something seems broken between SSH dynamic port forwarding and GUI apps under KDE. I can setup the dynamic port and drag pages in by curl proxied through it so the ssh connection is in place. I can't for the life of me get any GUI apps to properly use it though. Hard set firefox proxy or foxyproxy pointed at the established dynamic port simply gave me an invinate loop of "doing something".. pause.. "doing something".. Unfortunately, this issue actually affects much more than just providing an adhoc secure connection to VMware as I use dynamic port proxy for several work and personally related tasks. (I'd love to figure out why it's not working.. even if I can't fix it in the end). Overall, VMware is fantastic and deserves to be the market leader in terms of actually running the VMs. If one is only concerned with a host OS specifically supported then give it a go. Start after delay with host OS bootup; good. Delay host shutdown while shutting down guests gracefully; good. The method used in the screen display layer when showing windowed VM screens.. even that's nicer than competitive products. Not running one of the VMware blessed host OS, I'm just not going to hack it apart to force it to work on my system when there is a competitive alternative delivered within the native repositories (heck, even a Deb6 third party repository would be acceptable such as Webmin and Mondo Rescue.) ESX is another matter entirely though since it doesn't rely on a specific host OS. If it'll give my VM's direct access to the hardware (my Win7 sees an Nvidia GPU not a VMware GPU and similar) then it's even tempting to try and run Win7 and Deb6 concourently instead of in dual-boot. I suspect that would affect gaming on the Windows side still though.

Neon Samurai
Neon Samurai

I've gotten so used to forwarding 80/443 through my network that it's just assumed now. In a production environment, I'd expect the publicly accessible systems to already be setup in an applicable network space. Someone in a production environment running a webserver off there workstation or lacking IT support to get that VM visible from the outside probably shouldn't be doing so in the first place.