Basic virtual machine setup

Audio

In the machine settings, go to the audio tab and select the correct driver according to your sound system (ALSA, OSS or PulseAudio).

RAM and video memory

You can change the default values by going to Settings → General.

CD-ROM

You can change the default values by going to Settings → CD/DVD-ROM.

Check mount CD/DVD drive and select one of the following options.

Extension pack

VirtualBox requires an extension pack in order to provide support for RDP, as well as USB 2.0 and PXE booting for Intel network cards, etc., available at this webpage: VirtualBox Downloads. This PUEL licensed extension pack is free for personal use.

To install the Extension pack you download and save it to your hard drive and then open the VirtualBox main program. Click on preferences and on the left side click Extensions. On the right side, click the add package icon and then open the folder that has the extension and click to install it.

Additionally you can install the Extension Pack from the command line using VBoxManage.

Networking

VirtualBox guests may be networked through various methods; among them, there is #NAT and #Bridged networking. Using the #NAT method is the simplest and the default for new virtual machines.

In order to use host-only and internal network settings you have to load the Template:Codeline kernel module. The VirtualBox manual covers the available options for these two network types. They have been omitted here due to them being, for the most part, OS agnostic.

NAT

From VirtualBox:

access the VM's Settings menu;

click on Network from the list to the left; finally,

in the Attached to drop-down list, select NAT.

VirtualBox's bundled DHCP server enables the guest system to be configured with DHCP. The NAT IP address on the first card is 10.0.2.0, 10.0.3.0 on the second and so on.

Bridged

Bridged networking may be setup through various methods; among them, there is the native way, which requires minimal setup at the expense of having less control. For other methods, see Advanced VirtualBox Networking. Since newer versions, VirtualBox can bridge between a guest and a wireless host interface without the help of third party utilities.

Before continuing, load the required module:

# modprobe vboxnetflt

From VirtualBox:

access the VM's Settings menu;

click on Network from the list to the left;

in the Attached to drop-down list, select Bridged Adapter; finally,

in the Name drop-down list, select the name of the host interface that is connected to the network that the guest OS should be part of.

Start the virtual machine and configure its network as usual; e.g., DHCP or static.

Guest additions

The Guest Additions make the shared folders feature available, improve video card acceleration support, and enable bi-directional clipboard between the guest and host. Mouse integration is another feature, taking away the need of releasing the mouse after using it in the guest.

Windows guests

This will mount the iso image and windows should then automatically launch the guest additions installer. Follow the instructions to the end.
If you have Guest Additions installed for one virtual machine, and you want to install it for another one, there is no need to re-download the .iso. Select Devices → CD/DVD Devices → Choose virtual CD/DVD drive and navigate to ~/.VirtualBox where the image is located. This is the case if you have multiple VMs.

Sharing keyboard and mouse

To capture the keyboard and mouse, click the mouse inside the virtual machine display.

In a Linux host, create one or more folders for sharing files, then set the shared folders via the virtualbox menu (guest window).

In a Windows guest, starting with VirtualBox 1.5.0, shared folders are browseable and are therefore visible in Windows Explorer. Open Windows Explorer and look for it under My Networking Places → Entire Network → VirtualBox Shared Folders.

Launch the Windows Explorer (run explorer command) to browse the network places -> expand with the (+) sign : entire network → VirtualBox shared folders → \\Vboxsvr → then you can now expand all your configured shared folders here, and set up shortcuts for Linux folders in the guest filesystem. You can alternatively use the "Add network place wizard", and browse to "VBoxsvr".

Alternatively, on the Windows command line, you can also use the following:

net use x: \\VBOXSVR\sharename

While Template:Codeline is a fixed name, replace Template:Codeline with the drive letter that you want to use for the share, and sharename with the share name specified with VBoxManage.

# mount -t vboxsf [-o OPTIONS] sharename mountpoint
(Notes: sharename is optional or same as selected in the VirtualBox-Dialog , mountpoint of the shared directory in the hosts filesystem)

Automatically mounting a shared folder is possible through the linux-guest Template:Filename file. You may also specify the uid=#,gid=# (where # is replaced by the actual numerical uid and gid) to mount the share with normal user permissions instead of root permissions. (this can be helpful to mount parts of your host Template:Filename for use in your Linux-guest. To do this add an entry in the following format to the linux-guest Template:Filename:

sharename mountpoint vboxsf uid=#,gid=# 0 0

Replace Template:Codeline with the share name specified with VBoxManage, and mountpoint with the path where you want the share to be mounted (e.g. /mnt/share). The usual mount rules apply, that is, create this directory first if it does not exist yet. Note that if you have told VirtualBox to "automatically mount" the shared folder, this step may not be necessary and your folder will be found somewhere under Template:Filename.

Beyond the standard options supplied by the mount command, the following are available:

iocharset=CHARSET

to set the character set used for I/O operations (utf8 by default) and

convertcp=CHARSET

to specify the character set used for the shared folder name (utf8 by default).

D3D acceleration in Windows guests

Recent versions of Virtualbox have support for accelerating OpenGL inside guests. This can be enabled with a simple checkbox in the machine's settings, right below where video ram is set, and installing the Virtualbox guest additions. However, most Windows games use Direct3D (part of DirectX), not OpenGL, and are thus not helped by this method. However, it is possible to gain accelerated Direct3D in your Windows guests by borrowing the d3d libraries from Wine, which translate d3d calls into OpenGL, which is then accelerated.

After enabling OpenGL acceleration as described above, go to http://www.nongnu.org/wined3d/ in your Windows guest and grab the "Latest version (Installer):". Reboot the guest into safe mode (press F8 before the Windows screen appears but after the Virtualbox screen disappears), and install wined3d, accepting the defaults during the install. (You may check the box for DirectX 10 support if you like, dont touch anything else.) Reboot back to normal mode and you should have accelerated Direct3D.

Note: This hack may or may not work for some games depending on what hardware checks they make and what parts of D3D they use.

Note: This has only been tried on Windows XP and Windows 7 RC guests AFAIK, and does not work on the Windows 7 guest. If you have experience with this on a different windows version, please add that data here.

Virtual hard disks

Compacting Linux disks

When the fillfile hits the limit of the virtual hdd, the vast majority of user-space (non-reserved blocks) will be filled. Alternatively, run the command as root to get all of them. Example message: "8192 blocks (8192Mb) written.dcfldd:: No space left on device."

Once this occurs, simply remove the fill file and powerdown the VM:

$ rm -f fillfile && sudo shutdown -hF now

Note: The -F switch will force a disk check upon a reboot which is advised following the compact operation.

Using fully qualified path to su and VBoxHeadless is recommend. Add additional lines like above to start additional VMs. Commands following these in Template:Filename will be executed. Based on some rooting around in the VirtualBox documentation, I get the impression this will be a little more robust than 'VBoxManage ... --type headless' in future VBox releases.

Virtual machine control daemon

Below is a daemon for controlling virtual machines. Guests will be initialized on start, and state-saved on stop, or you will just get a "./vbox_service: line 31: out[${m[1]}]: bad array subscript" message when you run it.

Where 8888 is the port the host should listen on and 80 is the port the VM will send Apache's signal on.
To use a port lower than 1024 on the host machine changes need to be made to the firewall on the host machine. This can also be set up to work with SSH, etc.. by changing "Apache" to whatever service and using different ports.

Note: "pcnet" refers to the network card of the VM. If you use an Intel card in your VM settings change "pcnet" to "e1000"

Daemon Tools

While VirtualBox can mount ISO images without a problem, there are some image formats which cannot reliably be converted to ISO. For instance, ccd2iso ignores .ccd and .sub files, which can give disk images with broken files. cdemu, fuseiso, and MagicISO will do the same. In this case there is no choice but to use Daemon Tools inside VirtualBox.

VirtualBox on a USB key

When using VirtualBox on a USB key, for example to start an installed machine with an ISO image, you will manually have to create VDMKs from the existing drives. However, once the new VMDKs are saved and you move on to another machine, you may experience problems launching an appropriate machine again. To get rid of this issue, you can use the following script to launch VirtualBox. This script will clean up and unregister old VMDK files and it will create new, proper VMDKs for you:

Note that your user has to be added to the "disk" group to create VMDKs out of existing drives.

phpVirtualBox

An open source, AJAX implementation of the VirtualBox user interface written in PHP. As a modern web interface, it allows you to access and control remote VirtualBox instances. Much of its verbage and some of its code is based on the (inactive) vboxweb project. It allows the administrator to remotely and graphically administer their virtual machines without having to log in to their headless VirtualBox servers.

This requires the PUEL edition for VirtualBox (may be wrong).

See PhpVirtualBox for more information about the Arch Linux-specific installation process.

Troubleshooting OpenBSD

Some people with older computers can have trouble running an OpenBSD VM, manifesting as bunch of segmentation faults and total unusability. Starting VirtualBox with the -norawr0 argument may solve the problem. You can do it like this: