Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼


Virtualization for Developers with VirtualBox

VirtualBox Guest Additions

Once you have a guest installed and running, you should install the VirtualBox Guest Additions for the guest OS, which provide the following features:

  • Mouse integration: no longer will the mouse and keyboard be "captured" solely by the guest. Simply moving the mouse over the guest OS window will seamlessly direct mouse movement and clicks to the guest. Moving the mouse pointer outside of the guest OS window will automatically "free" the mouse, and mouse activity will be directed to the host OS. The operation is smooth and seamless.
  • Enhanced video support: in addition to providing enhanced video acceleration and performance, with guest additions, when you resize the window that contains the guest OS, it automatically adjusts its resolution to fit the size of the window. As a result, when you make the containing window bigger or smaller, the guest OS will resize its desktop to fit.
  • Seamless mode: when enabled, windows and applications from the guest OS will float alongside applications and windows running on the host OS, seamlessly. This gives the illusion that the guest's applications are running right there on the host natively (more on this later).
  • Full screen mode: when enabled, you can set the guest OS to take over the full screen. It will appear that the guest is the only OS running unless you move the mouse to one of the screen edges, or press a special key to exit this mode.
  • Time synchronization: allows the guest OS time to be periodically synchronized to the host OS.
  • Automated logins: passes user credentials from the host to Windows guests (only) for automated, yet secure, logins.
  • Shared folders and clipboard: the clipboard and folders that you specify can be used to transfer information between the host and guests OS's. For example, you can copy text from an application on the host, and paste it directly into and application running in a guest, and vice-versa. Also, you can specify directories on the host to be mapped directly to the guest so you can easily share and copy files between the two.

Guest Additions are available for Windows (NT 4, 2000, XP, Server 2003, Server 2008, Vista, and Win 7), Linux (Ubuntu, SUSE/openSUSE, RHEL, and Fedora), Solaris 10, OpenSolaris, and OS/2. This is an invaluable set of features that make using VirtualBox a pleasure. To get the most of your virtual environment, I recommend you install it right after creating a new guest OS.

Inside VirtualBox Seamless Mode

Figure 3 shows Windows running in VirtualBox seamless mode on my Mac OS X host. The desktops of the guest and host are combined such that it appears the guest applications are running natively on the host. Taskbars are integrated, to a degree, but seamless mode often works best with the taskbar in auto-hide mode. I like to place the Windows taskbar up with the Mac OS X menu bar, although you can place it on any edge of the desktop (such as the side, or with the OS X Dock).

[Click image to view at full size]
Figure 3: Running Windows in seamless mode allows Windows application windows to float alongside Mac application windows.

VirtualBox Command-Line: Fast Stops and Starts

Virtualbox includes a command-line interface that lets you write scripts to control and automate almost any aspect of VirtualBox, and the guests running within it. For instance, I often switch between guests, and don't like to wait for them to boot up and subsequently shut down. Instead, I launch custom scripts that use the VirtualBox command-line to save a running guest, and then restore it when I need it.

Each operation takes literally seconds to complete, and as a result, I can have Windows XP running on my Mac in a snap. As an added bonus, the guest starts in the state I last saved it, which again saves me time as I don't need to wait for, say, Visual Studio or Microsoft Word to launch.

To begin, start your guest OS (Linux, Windows, Solaris, and so on), and when you're ready to close it, execute the following from the command-line:

VBoxManage controlvm <GUESTNAME> savestate

You'll need to replace the text <GUESTNAME> with the name of the guest you're saving. This command will simultaneously save and close the guest. Subsequently, when you're ready to run the same guest again, execute the following from the command-line:

VBoxManage startvm <GUESTNAME>

To make it easier, I've created two scripts per guest on my Macbook; one to save and close a guest; and the other to restore and open it. I've also created desktop shortcuts with nice icons so I can easily launch or close a guest (see Figure 4).

[Click image to view at full size]
Figure 4: Desktop shortcuts to scripts to save and restore individual VirtualBox guests.

Other features of the VirtualBox command-line include the ability to:

  • Create your own VirtualBox management front-end
  • Create and install new virtual machines
  • Delete existing virtual machines
  • Gather information from a running guest
  • Change settings (such as video, audio, network, and so on) for existing guests
  • Snapshot an existing guest for restoration later
  • Import or export a guest image to use on other machines, or from other virtualization software
  • Manage DHCP and other network settings for a running guest
  • Control virtual devices, such as disks and USB-connected peripherals

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.