Setting up an (integrated) webcam to use in Ubuntu inside VirtualBox can be a tough nut to crack. However, with this guide, it should only take you a couple of minutes.
If you’re running Microsft Windows as your host operating system (OS), open an elevated command prompt (right click on cmd and run as administrator). Furthermore, please make sure that you can access VBoxManage. This is the tool that comes with Oracle VirtualBox that allows you to control your VirtualBox image from the command line of your host OS. If you cannot access it and you get the following error, please follow this short guide.
‘VBoxManage’ is not recognized as an internal or external command, operable program or batch file.
If the VBoxManage command is properly working, type the following command to list all the webcam devices. If you don’t see any errors, please scroll down to the area below the horizontal line.
VBoxManage list webcams
However, if you thought this would work properly but instead got the following error, please download the VM VirtualBox Extension Pack and install it on your computer. Make sure to turn off your VM.
VBoxManage.exe: error: No extension pack by the name 'Oracle VM VirtualBox Extension Pack' was found.
If you run into the following error, please follow the steps below the image.
- Browse to the folder where you installed VirtualBox. The default folder is ‘C:\Program Files\Oracle\VirtualBox’.
- Next, right click on the folder named ‘ExtensionPacks’ and go to the tab Security.
- Click Edit
- In the list, select Users (LAPTOPNAME/Users)
- Give it Full Control
- Rerun the installer
- In your elevated command prompt, run the following command again:
VBoxManage list webcams
You should see an output like this. The thing I hid from you is the directory to where my integrated webcam is installed (it’s very long).
Finally, start up your VM and run the following command, where you replace the image name and the path to the webcam with your specific values. Tips:
- If the directory name is long, you can copy from your cmd using control+C.
- If your directory contains spaces or weird characters, wrap them in double quotes.
VBoxManage controlvm <image_name> webcam attach <path_to_webcam>
Congratulations, you can now use your webcam in your virtual machine!