Connecting a USB flash memory device or printer to a virtual machine in VirtualBox shouldn't be too much trouble, but if you do find that the device cannot be recognized, here are a couple of useful tips that will come in handy.
VirtualBox and USB Devices
It’s always good to test an operating system before using it, and this is one of the many benefits of VirtualBox. This is a tool which makes it possible to run legacy applications, install applications that you wouldn’t normally be able to use and much more - all thanks to virtualization.
VirtualBox is a free, open source virtualization utility available for Windows, Mac and Linux, and is ideal for running virtual computers (with guest operating systems installed) with full access to your computer’s physical hardware. You can also specify some virtualized system hardware, such as a hard disk drive or an amount of RAM that should be made available to the guest OS.
Sometimes it can be difficult adding new USB device to your physical PC and persuading it to work with the virtual computer that you’re running. For instance, you might have a problem trying to pass through a USB device to VirtualBox running Ubuntu.
This type of problem can generally be overcome, however…
Virtual Ports in VirtualBox
Because VirtualBox allows you to create a virtual computer, its connector ports for external devices (such as USB) don’t actually exist, any more than the hard disk drive, RAM and optical drives exist. The virtual “guest" operating system runs on a virtual motherboard, accepts connections from virtual hardware, and in many cases uses virtual external devices (for instance you can create a virtual CD or DVD drive for reason ISO disc image files).
This makes VirtualBox ideal for creating a testing environment. As recently as five years ago a system administrator would have had to physically build and install an operating system for creating test systems and now that can all be done in minutes using virtualization software such as VirtualBox.
VirtualBox therefore can technically have any number of virtual ports created, although this is in reality is more likely to be limited by the number of physical ports you have on your PC.
Adding a USB Flash Memory Device to VirtualBox
What should happen when connecting a USB device – such as flash memory – to VirtualBox is that the host operating system (typically Windows, but it might be Mac OS X) will detect the device and install any necessary drivers if no connection has previously been established. VirtualBox will then install the necessary drivers that enable communication between the physical device and the virtual computer.
It should be as simple as that, but in certain situations this doesn’t necessarily work. For instance, you might be running a Windows 7 PC and within VirtualBox have Ubuntu installed. While the above description should occur when connecting a USB flash device, you might find that the device isn’t correctly detected, or else is initially detected but after some time has passed (perhaps you have ALT+TABbed away to use a different application) no longer responds.
This problem can be resolved by correctly removing and replacing the device in host operating system; alternatively you can disable and re-enable the USB host controller via Start > right-click Computer > Properties > Device Manager. Identify the appropriate USB controller, right-click and choose Properties and on the Driver tab use the Disable button. Click OK back to Device Manager and then repeat the action, this time clicking Enable.
Connecting a USB Printer
Acquiring USB pass through with a USB printer should be equally simple, but again this requires you to have first installed the device on the host operating system.
After installation, launch your virtual machine and switch on the printer; the VirtualBox software will detect the device, install the necessary drivers and then provide the printer as an available device in the guest operating system. You will then be able to easily print to this device when necessary.
As you can see, this is a pretty similar process as seen with the addition of a USB flash device. In fact, you will find that this is a pattern repeated across the various USB devices that you connect to your PC, from keyboards and other human input devices to external hard disk drives, mobile devices and capture devices.
Other USB Connectivity Issues with VirtualBox and Ubuntu
With these steps completed you should see how easy it is to overcome any problems with USB devices and Ubuntu running on VirtualBox. However, you should also bear in mind that any restrictions or problems you face will be reflected in the physical, host computer hardware.
For instance, if you’re connecting a device to a USB hub and this doesn’t display as being connected in the virtual machine, then your problem is likely to be related to the hub. Additionally, you might have driver issues. As an example, if you’re running operating system A on a physical host and you setup operating system B as a guest, if the USB device usually requires drivers for the guest OS it will also require drivers for the host in order for the USB pass through to work correctly in VirtualBox.
Author's own experience.
Screenshots provided by author.