The guest system will run in its virtual machine (VM) as if it were installed on a real computer, according to the parameters of the virtual system you have created for it.
All software running on the guest system does so as it would on a real machine.
You have considerable latitude in deciding what virtual hardware will be provided to the guest. The virtual hardware can be used for communicating with the host system or with other guests. For instance, if you provide VirtualBox with the image of a CD-ROM in an ISO file, VirtualBox can present this image to a guest system as if it were a physical CD-ROM. Similarly, you can give a guest system access to the real network via its virtual network card, and, if you choose, give the host system, other guests, or computers on the internet access to the guest system.
Starting the graphical user interface
After installing VirtualBox you can find the graphical user interface in the “Programs” menu (under the
“VirtualBox” group); on Linux, you can type VirtualBox on the command line.
Then, a window like the following should come up:
On the left, you can see a pane that lists all the virtual machines you have created so far (three in the example above). A row of buttons above it allows you to create new VMs and work on existing VMs. The pane on the right displays the properties of the virtual machine currently selected, if any.
When you start VirtualBox for the first time, as there is no virtual machine yet, everything will be empty.
Creating a virtual machine
Clicking on the “New” button in the user interface will guide you through setting up a
new virtual machine (VM). A wizard will show up:
that is needed to create a VM, in particular:
1. A name for your VM, and the type of operating system (OS) you want to install.
The name is what you will later see in the VirtualBox main window, and what your settings will be stored under. It is purely informational, but once you have created a few VMs, you will appreciate if you have given your VMs informative names. “My VM” probably is therefore not as useful as “Windows XP SP2”.
For “Operating System Type”, select the operating system that you want to install later. While this setting presently has no lasting effect, VirtualBox will use this setting to display an operating system accordingly and also make certain recom-
mendations later based on your selection (such as the amount of memory and hard disk space to allocate), and future VirtualBox versions may offer certain system-specific virtualization features. It is therefore recommended to always
set it to the correct value.
2. The amount of memory (RAM) that the virtual machine should have for itself.
Every time a virtual machine is started, VirtualBox will allocate this much memory from your host machine and present it to the guest operating system, which will report this size as the (virtual) computer’s installed RAM.
Note: Choose this setting carefully! The memory you give to the VM will not be available to your host OS while the VM is running, so do not specify more than you can spare. For example, if your host machine has 1 GB of RAM and you enter 512 MB as the amount of RAM for a particular virtual machine, while that VM is running, you will only have 512 MB left for all the other software on your host. If you run two VMs at the same time, even more memory will be allocated for the second VM (which may not even be able to start if that memory is not available). On the other hand, you should specify as much as your guest OS (and your applications) will require to run properly.
A Windows XP guest will require at least a few hundred MB RAM to run properly, and Windows Vista will even refuse to install with less than 512 MB. Of course, if you want to run graphics-intensive applications in your VM, you may require even more RAM.
So, as a rule of thumb, if you have 1 GB of RAM or more in your host computer, it is usually safe to allocate 512 MB to each VM. But, in any case, make sure you always have at least 256-512 MB of RAM left on your host operating system.
Otherwise you may cause your host OS to excessively swap out memory to your hard disk, effectively bringing your host system to a standstill.
As with the other settings, you can change this setting later, after you have created the VM.
3. Next, you must specify a virtual hard disk for your VM. There are several ways in which VirtualBox can provide hard disk space to a VM, but the most common way is to use a large image file on your “real” hard disk, whose contents VirtualBox
presents to your VM as if it were a complete hard disk.
The wizard presents to you the following window:
The wizard allows you to create an image file or use an existing one. Note also that the disk images can be separated from a particular VM, so even if you delete a VM, you can keep the image, or copy it to another host and create a new VM
for it there.
In the wizard, you have the following options:
• If you have previously created any virtual hard disks which have not been attached to other virtual machines, you can select those from the dropdown list in the wizard window.
• Otherwise, to create a new virtual hard disk, press the “New” button.
• Finally, for more complicated operations with virtual disks, the “Existing...“ button will bring up the Virtual Disk Manager, Most probably, if you are using VirtualBox for the first time, you will want to create a new disk image. Hence, press the “New” button.
This brings up another window, the “Create New Virtual Disk Wizard”.
VirtualBox supports two types of image files:
• A dynamically expanding file will only grow in size when the guest actually stores data on its virtual hard disk. It will therefore initially be small on the host hard drive and only later grow to the size specified as it is filled with data.
• A fixed-size file will immediately occupy the file specified, even if only a fraction of the virtual hard disk space is actually in use. While occupying much more space, a fixed-size file incurs less overhead and is therefore slightly faster than a dynamically expanding file.
To prevent your physical hard disk from running full, VirtualBox limits the size of the image file. Still, it needs to be large enough to hold the contents of your operating system and the applications you want to install – for a modern Windows or Linux guest, you will probably need several gigabytes for any serious use:
After having selected or created your image file, again press “Next” to go to the next page.
4. After clicking on “Finish”, your new virtual machine will be created. You will then see it in the list on the left side of the main window, with the name you have entered.
Basics of virtual machine configuration
When you select a virtual machine from the list in the main VirtualBox window, you will see a summary of that machine’s settings on the right of the window, under the “Details” tab.
Clicking on the “Settings” button in the toolbar at the top of VirtualBox main window brings up a detailed window where you can configure many of the properties of the VM that is currently selected. But be careful: even though it is possible to change all VM settings after installing a guest operating system, certain changes might prevent a guest operating system from functioning correctly if done after installation.
Note: The “Settings” button is disabled while a VM is either in the “running” or “saved” state. This is simply because the settings dialog allows you to change fundamental characteristics of the virtual computer that is created for your guest operating system, and this operating system may not take it well when, for example, half of its memory is taken away from under its feet. As a result, if the “Settings” button is disabled, shut down the current VM first.
VirtualBox provides a plethora of parameters that can be changed for a virtual machine.
For now, if you have just created an empty VM, you will probably be most interested in the settings presented by the “CD/DVD -ROM” section if want to make a CD-ROM or a DVD-ROM available the first time you start it, in order to install your guest operating system.
For this, you have two options:
• If you have actual CD or DVD media from which you want to install your guest operating system (e.g. in the case of a Windows installation CD or DVD), put the media into your host’s CD or DVD drive.
Then, in the settings dialog, go to the “CD/DVD -ROM” section and select “Host drive” with the correct drive letter (or, in the case of a Linux host, device file).
This will allow your VM to access the media in your host drive, and you can proceed to install from there.
• If you have downloaded installation media from the Internet in the form of an ISO image file (most probably in the case of a Linux distribution), you would normally burn this file to an empty CD or DVD and proceed as just described.
With VirtualBox however, you can skip this step and mount the ISO file directly.
VirtualBox will then present this file as a CD or DVD-ROM drive to the virtual machine, much like it does with virtual hard disk images.
In this case, in the settings dialog, go to the “CD/DVD -ROM” section and select “ISO image file”. This brings up the Virtual Disk Image Manager, where you perform the following steps:
1. Press the “Add” button to add your ISO file to the list of registered images.
This will present an ordinary file dialog that allows you to find your ISO file on your host machine.
2. Back to the manager window, select the ISO file that you just added and press the “Select” button. This selects the ISO file for your VM.
Running a virtual machine
The “Start” button in the main window starts the virtual machine that is currently selected.
This opens up a new window, and the virtual machine which you selected will boot up. Everything which would normally be seen on the virtual system’s monitor is shown
In general, you can use the virtual machine much like you would use a real computer. There are couple of points worth mentioning however.
Keyboard and mouse support in virtual machines
Capturing and releasing keyboard and mouse
Since the operating system in the virtual machine does not “know” that it is not running on a real computer, it expects to have exclusive control over your keyboard and mouse. This is, however, not the case since, unless you are running the VM in fullscreen mode, your VM needs to share keyboard and mouse with other applications and possibly other VMs on your host.
As a result, initially after installing a host operating system and before you install the guest additions (we will explain this in a minute), only one of the two – your VM or the rest of your computer – can “own” the keyboard and the mouse. You will see asecond mouse pointer which will always be confined to the limits of the VM window.
Basically, you activate the VM by clicking inside it.
To return ownership of keyboard and mouse to your host operating system, VirtualBox reserves a special key on your keyboard for itself: the “host key”. By default, this is the right Control key on your keyboard, but you can change this default in the VirtualBox Global Settings. In any case, the current setting for the host key is always displayed at the bottom right of your VM window, should you have forgotten about it:
In detail, all this translates into the following:
• Your keyboard is owned by the VM if the VM window on your host desktop has the keyboard focus (and then, if you have many windows open in your guest operating system as well, the window that has the focus in your VM). This means that if you want to type within your VM, click on the title bar of your VM window first.
To release keyboard ownership, press the Host key (as explained above, typically the right Control key).
Note that while the VM owns the keyboard, some key sequences (like Alt-Tab for example) will no longer be seen by the host, but will go to the guest instead.
After you press the host key to reenable the host keyboard, all key presses will go through the host again, so that sequences like Alt-Tab will no longer reach the guest.
• Your mouse is owned by the VM only after you have clicked in the VM window.
The host mouse pointer will disappear, and your mouse will drive the guest’s pointer instead of your normal mouse pointer.
Note that mouse ownership is independent of that of the keyboard: even after you have clicked on a titlebar to be able to type into the VM window, your mouse is not necessarily owned by the VM yet.
To release ownership of your mouse by the VM, also press the Host key.
As this behavior can be inconvenient, VirtualBox provides a set of tools and device drivers for guest systems called the “VirtualBox Guest Additions” which make VM keyboard and mouse operation a lot more seamless. Most importantly, the Additions will get rid of the second “guest” mouse pointer and make your host mouse pointer work directly in the guest.
Typing special characters
Operating systems expect certain key combinations to initiate certain procedures.
Some of these key combinations may be difficult to enter into a virtual machine, as there are three candidates as to who receives keyboard input: the host operating system, VirtualBox, or the guest operating system. Who of these three receives keypresses depends on a number of factors, including the key itself.
• Host operating systems reserve certain key combinations for themselves. For example, it is impossible to enter the Ctrl+Alt+Delete combination if you want to reboot the guest operating system in your virtual machine, because this key combination is usually hard-wired into the host OS (both Windows and Linux intercept this), and pressing this key combination will therefore reboot your host.
Also, with Linux, the key combination Ctrl+Alt+Backspace normally resets the X server (to restart the entire graphical user interface in case it got stuck). As the X server intercepts this combination, pressing it will usually restart your host graphical userface (and kill all running programs, including VirtualBox, in the process).
Third, also with Linux, the key combination Ctrl+Alt+Fx (where Fx is one of the function keys from F1 to F12) normally allows to switch between virtual terminals. As with Ctrl+Alt+Delete, these combinations are intercepted by the host operating system and therefore always switch terminals on the host.
If, instead, you want to send these key combinations to the guest operating system in the virtual machine, you will need to use one of the following methods:
– Use the items in the “VM” menu of the virtual machine window. There you will find “Insert Ctrl+Alt+Delete” and “Ctrl+Alt+Backspace”; the latter will only have an effect with Linux guests, however.
– Press special key combinations with the Host key (normally the right Control key), which VirtualBox will then translate for the virtual machine:
* Host key + Del to send Ctrl+Alt+Del (to reboot the guest);
* Host key + Backspace to send Ctrl+Alt+Backspace (to restart the graphical user interface of a Linux guest);
* Host key + F1 (or other function keys) to simulate Ctrl+Alt+F1 (or other function keys, i.e. to switch between virtual terminals in a Linux guest).
• For some other keyboard combinations such as Alt-Tab (to switch between open windows), VirtualBox allows you to configure whether these combinations will affect the host or the guest, if a virtual machine currently has the focus. This is a
global setting for all virtual machines and can be found under “File” -> “Global settings” -> “Input” -> “Auto-capture keyboard”.
Changing removable media
While a virtual machine is running, you can change removable media from the “Devces” menu of the VM’s window. Here you can select in detail what VirtualBox presents to your VM as a CD, DVD, or oppy.
The settings are the same as would be available for the VM in the “Settings” dialog of the VirtualBox main window, but since that dialog is disabled while the VM is in “running” or “saved” state, this extra menu saves you from having to shut down and
restart the VM every time you want to change media.
Hence, in the “Devices” menu, VirtualBox allows you to attach the host drive to the guest or select a oppy or DVD image using the Disk Image Manager
Saving the state of the machine
When you click on the “Close” button of your virtual machine window (at the top right of the window, just like you would close any other window on your system) (or press the Host key together with “Q”), VirtualBox asks you whether you want to “save” or “power off” the VM.The difference between these two options is crucial. They mean:
• Save the machine state: With this option, VirtualBox “freezes” the virtual machine by completely saving its state to your local disk. When you later resume the VM (by again clicking the “Start” button in the VirtualBox main window), you will find that the VM continues exactly where it was left off. All your programs will still be open, and your computer resumes operation.
Saving the state of a virtual machine is thus similar to suspending a laptop computer (e.g. by closing its lid).
• Power off the machine: With this option, VirtualBox also stops running the virtual machine, but without saving its state.
This is equivalent of pulling the power plug on a real computer without shutting it down properly. If you start the machine again after powering it off, your operating system will have to reboot completely and may begin a lengthy check
With VirtualBox’s snapshots, you can save a particular state of a virtual machine for later use. At any later time, you can revert to that state, even though you may have changed the VM considerably since then.
This is particularly useful for making sure that a guest installation is not damaged by accidental changes, misbehaving software, or viruses.
Once you have set up the machine the way you want it, simply take a snapshot, and should anything happen to the installation, you can simply revert to its snapshot state.
To take a snapshot of your VM, perform the following steps:
1. If your VM is currently in either the “saved” or the “powered off” state (as displayed next to the VM in the VirtualBox main window), click on the “Snapshots” tab on the top right of the main window, and then on the small camera icon (for
If your VM is currently running, select “Take snapshot” from the “VM” pull-down menu of the VM window.
2. A window will pop up and ask you to name the snapshot. This name is purely for reference purposes to help you remember the state of the snapshot. For example, a useful name would be “Fresh installation from scratch, no external drivers”.
3. Your new snapshot will then appear in the list of snapshots under the “Snapshots” tab. Underneath, you will see an item called “Current state”, signifying that the current state of your VM is a variation based on the snapshot you took earlier.
(If you later take another snapshot, you will see that they will be displayed in sequence, and each subsequent snapshot is a derivation of the earlier one.)
To revert to an earlier snapshot, you click on the “Current state” item and select “Discard current state”. This will bring the VM back to the state of the nearest (most recent) snapshot. In the same way, you can merge several earlier snapshots into one.
Note: The snapshot reverted to will affect the virtual hard drives that are connected to your VM, as the entire state of the virtual hard drive will be reverted as well. This means also that all files that have been created since the snapshot and all other file changes will be lost.In order to prevent such data loss while still making use of the snapshot feature, it is possible to add a second hard drive in “write-through” mode using the VBoxManage interface and use it to store your data. As write-through hard drives are not included in snapshots, they remain unaltered when a machine is reverted.
The Virtual Disk Manager
VirtualBox keeps an internal registry of all available hard disk, CD/DVD -ROM and oppy disk images. This registry can be viewed and changed in the Virtual Disk Manager, which you can access from the “File” menu in the VirtualBox main window:
The Disk Image Manager shows you all images that are currently registered with VirtualBox, conveniently grouped in three tabs for the three possible formats. These formats are:
• Hard disk images, either in VirtualBox’s own Virtual Disk Image (VDI) format or in the widely supported VMDK format;
• CD/DVD images in standard ISO format;
• oppy images in standard RAW format.
Starting with version 1.4, VirtualBox also supports the widely supported VMDK format. This means that if you have created virtual hard disks with another virtualization product that uses the VMDK format, you will not have to recreate these images with VirtualBox, but can continue to use them
As you can see in the screenshot above, for each image, the Virtual Disk Manager shows you the full path of the image file and other information, such as the virtual machine the image is currently attached to, if any. Also, as can be seen in the screenshot, if you have created snapshots for a virtual machine, additional “differencing”
hard disk images may automatically be created.
The Virtual Disk Manager allows you to
• create new hard disk images using the “New” button; this will bring up the “Create Disk Image” wizard
• import existing VDI or VMDK files from your hard drive into VirtualBox using the “Add” button;
• remove an image from the registry (and optionally delete the image file when doing so);
• “release” an image, that is, detach it from a virtual machine if it is currently attached to one as a virtual hard disk.
We recommend that you maintain two special folders on your system for keeping images: one for hard disk image files (which can, in the case of dynamically expand ing images, grow to considerable sizes), and one for ISO files (which were probably downloaded from the Internet).
Hard disk image files can be copied onto other host systems and imported into virtual machines there, although certain guest systems (notably Windows 2000 and XP) will require that the new virtual machine be set up in a similar way to the old one.
You can also duplicate hard disk image files on the same host to quickly produce a second virtual machine with the same operating system setup. However, you should only make copies of virtual disk images using the utility supplied with VirtualBox.
This is because VirtualBox assigns a unique identity number (UUID) to each disk image, which is also stored inside the image, and will refuse to work with two images that use the same number. If you do accidentally try to reimport a disk image which you copied normally, you can make a second copy using VirtualBox’s utility and import that instead.
Deleting virtual machines
The “Delete” button in the main VirtualBox window lets you remove a virtual machine which you no longer need. All settings for that machine will be lost. However, any hard disk images attached to the machine will be kept; you can delete those separately using the Disk Image Manager (described just above).
You cannot delete a machine which has snapshots or is in a saved state, so you must discard these first.
Virtual machine settings
Most of the settings described below are available in the settings window after selecting a virtual machine in the VirtualBox main window and clicking on the “Settings” button. To keep the user interface simple, those of the following settings which are not as commonly used are not shown in that settings window.
In the Settings window, under “General”, you can configure the most fundamental aspects of the virtual machine such as memory and essential hardware. There are
three tabs, “Basic”, “Advanced”, and “Description”.
Under the “Basic” tab of the “General” settings category, you can find these settings:
Name The name under which the VM is shown in the list of VMs in the main window.
Under this name, VirtualBox also saves the VM’s configuration files. By changing the name, VirtualBox renames these files as well. As a result, you can only use characters which are allowed in your host operating system’s file names.
Note that internally, VirtualBox uses unique identifiers (UUIDs) to identify virtual machines. You can display these with VBoxManage.
OS Type The type of the guest operating system that is (or will be) installed in the VM..
Memory size (RAM) The amount of RAM that is allocated and given to the VM when it is running. The specified amount of memory will be allocated from the host operating system (from resident memory so it must be available or made available as free memory on the host when attempting to start the VM and will not be available to the host while the VM is running).
Generally, it is possible to change the memory size after installing the guest operating system (provided you do not reduce the memory to an amount where the operating system would no longer boot).
Note: As Microsoft Windows’ activation mechanism is sensitive to some hardware changes, if you are changing settings for a Windows guest, some of these changes may trigger a request for another activation with Microsoft.
Video memory siz e Size of the memory provided by the virtual graphics card available to the guest, in MB. As with the main memory, the specified amount will be allocated from the host’s resident memory. Based on the amount of video memory, higher resolutions and color depths may be available, but for most setups, the default video memory size of 8MB should be sufficient.
“Advanced” tab Boot order This setting determines the order in which the guest operating system will attempt to boot from the various virtual boot devices. Analogous to a real PC’s BIOS setting, VirtualBox can tell a guest OS to start from the virtual oppy, the virtual CD/DVD drive, the virtual hard drive (each of these as defined by the other VM settings), or none of these.
With VBoxManage modifyvm -boot>, you can also configure a VM to boot from the network.
Enable ACPI VirtualBox can present the Advanced Configuration and Power Interface (ACPI) to the guest operating system for configuring the virtual hardware. In addition, via ACPI, VirtualBox can present the host’s power status information to the guest.
ACPI is the current industry standard to allow operating systems to recognize hardware, configure motherboards and other devices and manage power. As all modern PCs contain this feature and Windows and Linux have been supporting
it for years, it is also enabled by default in VirtualBox.
Note that all Windows operating systems starting with Windows 2000 install different kernels depending on whether ACPI is available, so ACPI must not be turned off after installation. Turning it on after installation will have no effect however.
Enable I/O APIC Advanced Programmable Interrupt Controllers (APICs) are a newer x86 hardware feature that have replaced old-style Programmable Interrupt Controllers (PICs) in recent years. With an I/O APIC, operating systems can use more than 16 interrupt requests (IRQs) and therefore avoid IRQ sharing for improved reliability.
However, software support for I/O APICs has been unreliable with some operating systems other than Windows. Also, the use of an I/O APIC slightly increases the overhead of virtualization and therefore slows down the guest OS a little.
Note that all Windows operating systems starting with Windows 2000 install different kernels depending on whether an I/O APIC is available. As with ACPI, the I/O APIC therefore must not be turned off after installation of a Windows
guest OS. Turning it on after installation will have no effect however.
Shared clipboard If the virtual machine has Guest Additions installed, you can select here whether the clipboard of the guest operating system should be shared with that of your host. If you select “Bidirectional”, then VirtualBox will always make sure that both clipboards contain the same data. If you select “Host to guest”
or “Guest to host”, then VirtualBox will only ever copy clipboard data in one direction.With this setting, you can specify any other folder for each VM.
BIOS logo customization By default, when the virtual machine starts up, VirtualBox displays the “innotek” company logo. With VBoxManage, you can change this logo to one of your choice.
In the VM Settings window, the “Hard Disks” section allows you to connect up to three virtual hard disk images to your virtual machine.
As with a real PC, VirtualBox’s IDE support offers you two IDE controllers, each with a “master” and a “slave” connection. With one of these four connectors being reserved to the CD -ROM/DVD drive (see below), that leaves you with three possible hard disks, each represented by one disk image file.
The settings of the first disk (“Primary Master”) are initially set by the “Create VM” wizard. Normally, you will stick with this setting for the rest of a VM’s lifetime. You may, however, freely remove, add and exchange virtual hard drives after the machine has been set up. For example, if you wish to copy some files from another virtual disk that you created, you can connect that disk as a second hard disk.
To connect an additional disk, select the corresponding checkbox and click on the folder icon on the right to bring up the Virtual Disk Image Manager. To remove a virtual disk, simply uncheck the appropriate checkbox. To replace a hard drive with a different one, click on the folder icon for that drive and select or create a new one using the Virtual Disk Manager.
CD/DVD-ROM and oppy settings
In the VM Settings window, the settings in these two categories determine what VirtualBox provides as a oppy disk and as a CD/DVD -ROM drive to your VM’s guest operating system. For both the oppy and CD/DVD-ROM categories, the following
options are available:
• Not mounted: The virtual device is presented as empty, that is, no oppy (or no CD/DVD -ROM) is present.
• Host drive: The physical device of the host computer is connected to the VM, so that the guest operating system can read from and write to your physical device.
This is, for instance, useful if you want to install Windows from a real installation CD. In this case, select from the drop-down list the drive letter (or, on the Linux host, the device) of your host drive.
• Image file: Quite similar to virtual hard disks, this presents a file on your host as a device to the guest operating system. The image file format varies depending on the type of device:
– For oppies, the file must be in raw format.
– For CD- and DVD -ROMs, the file must be in ISO format. Most commonly, you will select this option when installing an operating system from an ISO file that you have obtained from the Internet. For example, most Linux distributions are available in this way.
All these settings can be changed while the guest is running. Since the “Settings” dialog is not available at that time, you can also access these settings from the “Devices” menu of your virtual machine window.
Note: The identification string of the drive provided to the guest (which is displayed by some configuration tools such as the Windows Device Manager) is always “VBOX CD-ROM”, irrespective of the current configuration of the virtual drive. This is to prevent hardware detection from being triggered in the guest operating system every time the configuration is changed.
Using the host drive normally provides a read-only drive to the guest. As an experimental feature (which currently works for data only, audio is not supported), it is possible to give the guest access to the CD/DVD writing features of the host drive (if available):
The “Audio” section in a virtual machine’s Settings window determines whether the VM will see a sound card connected, and whether the audio output should be heard on the host system.
If audio is enabled for a guest, VirtualBox simulates an Intel AC’97 controller for the virtual machine. In that case, you can select what audio driver VirtualBox will use on the host. On Linux hosts, you can select between the OSS or the ALSA subsystem.
The “Network” section in a virtual machine’s Settings window allows you to configure how VirtualBox presents virtual network cards to your VM, and how they operate.
VirtualBox can simulate up to four virtual network cards for a virtual machine. These cards are presented as AMD PCNet cards, which most current operating systems (as well as GNU GRUB) support out of the box, without needing extra drivers.
When you first create a virtual machine, VirtualBox by default enables one of these four cards and selects “Network Address Translation” (NAT) for it. This way the the guest can connect to the outside world using the host’s networking and the outside world can connect to services on the guest which you choose to make visible outside of the virtual machine.
The “USB” section in a virtual machine’s Settings window allows you to configure VirtualBox’s sophisticated USB support.
VirtualBox can allow virtual machines to access the USB devices on your host directly. To achieve this, VirtualBox presents to the guest operating system a virtual USB controller. As soon as the guest system starts using a USB device, it will appear as unavailable on the host.
Note: Be careful with USB devices that are currently in use on the host! For example, if you allow your guest to connect to your USB hard disk that is currently mounted on the host, when the guest is activated, it will be disconnected from the host without a proper shutdown. This may cause data loss.
In addition to allowing a guest access to your local USB devices, VirtualBox even allows your guests to connect to remote USB devices by use of the VRDP protocol.
In the Settings dialog, you can first configure whether USB is available in the guest at all. If so, you can determine in detail which devices are available. For this, you must create so-called “filters” by specifying certain properties of the USB device.
Clicking on the “+“ button to the right of the “USB Device Filters” window creates a new filter. You can give the filter a name (for referencing it later) and specify the filter criteria. The more criteria you specify, the more precisely devices will be selected. For instance, if you specify only a vendor ID of 046d, all devices produced by Logitech will be available to the guest. If you fill in all fields, on the other hand, the filter will only apply to a particular device model from a particular vendor, and not even to other devices of the same type with a different revision and serial number.
In detail, the following criteria are available:
1. Vendor and product ID. With USB, each vendor of USB products carries an identification number that is unique world-wide, the “vendor ID”. Similarly, each line of products is assigned a “product ID” number. Both numbers are commonly
written in hexadecimal (that is, they are composed of the numbers 0-9 and the letters A-F), and a colon separates the vendor from the product ID. For example, 046d:c016 stands for Logitech as a vendor, and the “M-UV69a Optical Wheel
Alternatively, you can also specify “Manufacturer” and “Product” by name.
To list all the USB devices that are connected to your host machine with their respective vendor and product IDs, you can use the following command.
1.VBoxManage list usbhost
On Windows, you can also see all USB devices that are attached to your system in the Device Manager. On Linux, you can use the lsusb command.
2. Serial number. While vendor and product ID are already quite specific to identify USB devices, if you have two identical devices of the same brand and product line, you will also need their serial numbers to filter them out correctly.
3. Remote. This setting specifies whether the device will be local only, or remote only (over VRDP), or either.
On a Windows host, you will need to unplug and reconnect a USB device to use it after creating a filter for it.
As an example, you could create a new USB filter and specify a vendor ID of 046d (Logitech, Inc), a manufacturer index of 1, and “not remote”. Then any USB devices on the host system produced by Logitech, Inc with a manufacturer index of 1 will be visible to the guest system.
Several filters can select a single device – for example, a filter which selects all Logitech devices, and one which selects a particular webcam.
You can deactivate filters without deleting them by clicking in the checkbox next to the filter name.
On Windows hosts, two kernel mode device drivers provide USB proxy support. A USB filter driver allows VirtualBox to capture devices when they are plugged in. Installing, uninstalling and updating this filter requires a system restart. A second USB device driver then claims USB devices and makes them available to a virtual machine.
After defining a USB device filter for a VM, the device needs to be replugged once for VirtualBox to claim it. Also, you might have to confirm a driver signing warning when starting a VM with assigned USB devices.
On Linux hosts, VirtualBox accesses USB devices on Linux through the usbfs file system. Therefore, the user executing VirtualBox needs read and write permission to the USB file system. Most distributions provide a group (e.g. usbusers) which the VirtualBox user needs to be added to. Also, VirtualBox can only proxy to virtual machines USB devices which are not claimed by a Linux host USB driver. Please refer to the driver= entry in /proc/bus/usb/devices to see which devices are claimed.
If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog: