Steps to use a USB stick on a Virtualbox virtual machine
Virtual machines are very convenient for testing the functionality of new operating systems without physically installing them on the disk but they can also be excellent allies for testing USB peripherals, to be added as new separate devices to the virtual machine.
In the following guide we will show you how to show a USB device connected to PC on VirtualBox, which is the most famous virtual machine manager in the world. The steps described below can be applied to any type of virtual machine.
READ ALSO -> VirtualBox guide to create, start and manage virtual machines on PC
1) Why USB devices are not available?
When we start a virtual machine on VirtualBox all the main components (RAM, processor, motherboard, video card and disk) are virtualized by the program itself: this explains why the virtual machine is immediately ready for use after completing the initial configuration.
The USB peripherals they are not automatically virtualized because their virtualization would disconnect them from the main machine: to be able to use them virtually it is therefore necessary that the peripheral is no longer visible on the PC we use as a “base”, so that it can be displayed correctly on the virtual machine.
This virtualization does not involve the mouse and keyboard, which are virtualized anyway; the separation of USB devices can concern instead USB webcams, external USB disks, USB sticks and any other additional USB peripherals present on the device.
2) Prerequisites for VirtualBox
To correctly add USB devices to VirtualBox we will first have to download the VM VirtualBox Extension Packnecessary to be able to unlock all the functions related to the USB components.
After downloading simply double click on the downloaded file and follow the prompts to add it to your VirtualBox installation. To check if the extension is installed on VirtualBox, open the app from the Start menu, press the top menu Filewe press on the menu Preferences and finally let’s go to the menu Extensions; on VirtualBox 7 we press at the top of the menu Fileclick on Tools and finally press on Extension Pack Manager.
3) How to add USB devices to VirtualBox
After checking the correct installation of the extension we can follow two different ways to add devices to the VirtualBox virtual machines: adding while running and adding when the machine is off.
If we have already started a virtual machine we press up on pressing up on the menu Devicespressing on the USB item and selecting (from the list that will appear) the device we want to be visible on the virtual machine.
Alternatively, we can add a USB peripheral to VirtualBox on the fly by taking us to the path Devices -> USB- USB Settingsclicking on the side of the USB socket icon and with a + and indicating which device we want to add to the system.
If we want the USB device to be accessible before the system starts, all we have to do is open the ap Oracle VPM VirtualBoxselect the virtual machine to add the USB devices to, right-click on it, select the menu Settingstake us to the USB screen and immediately select the most suitable virtual controller for the peripheral (usually USB 2.0 controllers is the most compatible, so let’s activate this item if we haven’t already).
In the screen we will be able to add the USB peripherals as seen a little while ago, i.e. by clicking on the side on theicon in the shape of a USB plug and a + and choosing the device to add.
Whichever path you choose, the result will be identical: the peripheral will disappear from the main machine and will only be accessible from the virtual machine as long as it is connected to the socket. To avoid data loss and errors we always advise you to remove the USB device with the removal procedure (as we will see in the following chapter) and only then
4) How to remove USB devices on VirtualBox
If we have added a USB peripheral to a virtual machine and want to remove it, we must pay the utmost attention: we do not simply unplug the peripheral from its port, since it is virtualized at that moment and data loss could occur!
For safely remove USB devices added to VirtualBox we try to use the procedure closest to the one we used to add it. If we have added the peripheral with the active virtual machine, press again at the top of the menu Deviceslet’s go to the USB menu and remove the check mark from the USB device we have added.
If, on the other hand, we had added the peripheral to the virtual machine off, open the VirtualBox app, select the virtual machine to modify, right-click on it, click on the item Settingswe open the menu USBselect the peripheral to be removed and finally press on the item Remove selected USB filter.
After removing the USB stick from the virtual machine we can remove it from the physical system, as seen in our guide on how to unplug the USB stick from the PC.
L’adding external USB devices to VirtualBox virtual machines it will allow us to carry out numerous functional tests on the machines themselves, as well as being able to access the files stored on a USB key or disk and use other peripherals such as webcams, wired controllers and graphic tablets.
The only recommendation is by follow a very precise procedure for removing the added devicesin order to avoid any type of error or data loss when switching from virtualization to the real machine.
To learn more, we can read our guides to solutions to errors on USB ports and flash drives that are not recognized or impossible to use and at alternatives to Virtualbox to install virtual machines.