162

Oracle VirtualBox is unable to list/filter the USB devices attached to my system. As a result, the guest OS is not able to see any USB device either.

This is my configuration:

  • Host: VirtualBox 5.0.0 r101573 on Ubuntu 14.04, with Oracle VM VirtualBox Extension Pack installed
  • Guest: Windows 7, with VirtualBox Guest Additions installed

I've been trying with a USB flash drive and a Garmin sports watch: when connected to the host, they are both recognised by the system, i.e. they are in the list outputted by the lsusb command.

However, when running VirtualBox, no USB device is actually detected (Enable USB Controller is obviously checked). If I select the VM, then Settings -> USB and I try to add a filter, a tooltip is displayed:

<no devices available>

I've tried different options as USB controller, even tried to attach the devices to different USB ports (2.0 instead of 3.0), but that didn't change anything. Since no USB devices are listed there I assume the problem is with the host, not with the guest.

The USB mouse I have is working in both the host and the guest, but that's probably a device that is treated differently.

The VBox.log does not report anything suspicious regarding the USB, and VirtualBox does not throw any error either.

The same problem occurred when I had VirtualBox 4.3.30 installed.

Is there a way to resolve the issue?

mguassa
  • 1,834
  • 2
  • 11
  • 13
  • 1
    most likely you don't have access rights to `/dev/bus/usb/XXX/YYY` . try running `virtualbox` as a root as a temporary measure to confirm. – akhmed May 01 '17 at 04:16

7 Answers7

258

Please add your user name to the vboxusers group with this command:

sudo adduser $USER vboxusers

After that you must logout and login. (For Ubuntu 20.04, a reboot is required)

Please check this for more details:

https://help.ubuntu.com/community/VirtualBox/USB

csorig
  • 2,604
  • 1
  • 11
  • 2
  • 6
    I have the same issue in opensuse adding myself to vboxusers group did not solve the problem – Calin Jan 13 '16 at 07:47
  • 3
    @Calin Adding your account to group `vboxusers` works only, if `/dev/bus/usb/XXX/YYY` belongs to group `vboxusers` too. – Olaf Dietsche Aug 14 '16 at 14:45
  • 7
    You can also check if this is working with following command: `VBoxManage list usbhost` – sequielo Jan 08 '17 at 19:34
  • 1
    this is an incredibly common usecase, just curious how we were supposed to figure this out – user391339 Mar 01 '18 at 04:11
  • 1
    Pro-tip: Use `su yourself -c 'virtualbox'` to avoid having to log out ([source](https://unix.stackexchange.com/questions/18796/how-to-apply-changes-of-newly-added-user-groups-without-needing-to-reboot)) – vpetersson Mar 21 '18 at 12:20
  • 2
    @olaf-dietsche All that `/dev/bus/usb/…` belongs to user root, group root... any advice, what to do then? – Frank N Mar 23 '18 at 12:20
  • @FrankNocke As always, it depends. You can add your own udev rule, e.g. SUBSYSTEMS=="usb", GROUP="vboxusers" or some other convenient group. – Olaf Dietsche Mar 23 '18 at 14:18
  • 4
    @FrankNocke I ran into this just today. Adding the GID to the udev rules file installed by vbox does the trick. See https://github.com/dnschneid/crouton/wiki/VirtualBox-udev-integration. It does feel kludgy though. – Raghu Jun 12 '18 at 14:43
  • Just remember that after you add a user to the vboxusers group, that user needs to log off and log back in for the changes to take effect. – Hopping Bunny May 29 '20 at 06:01
  • 1
    In Ubuntu 20.04 I had to restart the machine. Relogin did not help – Margus Pala Jul 20 '20 at 05:44
  • Re-login should work also on 20.04. After logging in again, `groups` shows that I am in the `vboxusers` group. – Supernormal Nov 02 '21 at 11:49
  • Re-login didn't show `vboxusers` on `groups` command. I had to restart the system. – Adrian Bienias Dec 15 '21 at 19:00
  • JFYI: I didn't have to restart on my Ubuntu 20.04.2 box. Log-off -> Log-in did it for me. – Rober May 16 '22 at 14:53
  • No answer worked for me. Only solution was to uninstall with `apt remove --purge virtualbox*` reboot, reinstall it, reboot, and now it's Ok. – Meloman Sep 19 '22 at 09:47
  • for ppl still hunting down the `/dev/bus/usb/...` permission issue, please note, at least vbox6.1 links all usbs to `/dev/vboxusb/...` correct permission is set for nodes in /dev/vboxusb/, not for /dev/bus/usb , time to look elsewhere. – Ben Apr 08 '23 at 04:35
34

If you don't have the adduser command, you can do this instead:

sudo usermod -aG vboxusers $USER

Logout and login again in order to reload user's group info and usb device will now show up in the list.

superl2
  • 3
  • 1
Babken Vardanyan
  • 1,543
  • 2
  • 15
  • 15
13

There's a lot of things that can go wrong when sharing USB to guests. In any case, the checklist I did was:

  • install the Extension Pack on the host and Guest Additions on the guest.
  • add current user to vboxusers group.
  • manually add the corresponding USB filter in VirtualBox settings and only connect the device after finish booting the guest OS.
  • under VirtualBox, first try USB 3.0 (xHCI) Controler and if doesn't work then go for USB 2.0 Controller.

I've successfully managed to share a USB stick to a Windows XP guest on a Linux Mint 19 host after some initial failed attempts. Good luck !

Henrique de Sousa
  • 983
  • 11
  • 17
10

First of all, @csorig's answer is right. You need to be in the vboxusers group. That's the basic.

But if it still doesn't work for any reason... it's not documented anywhere, but I found that USB host device sharing does not work if the system has run out of inotify resources.

You can try running tail -f /var/log/syslog or something like that. If it shows up a message like:

tail: inotify cannot be used, reverting to polling: Too many open files

then you need to increase your inotify watch limit or disable software that is consuming them. In my case it was a continuous backup software running in background.

The basic method to increase this limit is:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
kFYatek
  • 461
  • 1
  • 6
  • 8
  • Thanks @kFYatek! Found the problem much faster because of your comment! Just wanted to note that in my case the error happened even though `tail -f /var/log/syslog` worked just fine (no warning)… – ntninja Dec 19 '17 at 21:19
  • I'm still getting the `inotify cannot be used` after increasing the limit. – James Hirschorn May 13 '20 at 21:03
  • 1
    I fixed the `inotify` issue with `fs.inotify.max_user_instances`. However, this did not help with the missing USB devices. – James Hirschorn May 13 '20 at 21:21
  • 1
    The only thing that worked for me is to increase both `max_user_watches` and `max_user_instances` and restart the virtualbox service – dargaud Feb 20 '23 at 15:50
  • @dargaud, @kFYatek, @James_Hirschorn, Thanks for the tips, raising both limits, restarting `vboxdrv.service`, fixed everything. VSCode used to cause a lot of inotify watcher runnout error, too bad, I just never linked them together. – Ben Apr 08 '23 at 04:49
9

After numerous searching I've concluded with the help of this wiki to the below script that fixed the problem:

#!/bin/bash

#
# Heavily inspired by https://github.com/dnschneid/crouton/wiki/VirtualBox-udev-integration
#

vbox_usbnode_path=$(find / -name VBoxCreateUSBNode.sh 2> /dev/null | head -n 1)
if [[ -z $vbox_usbnode_path ]]; then
    echo Warning: VBoxCreateUSBNode.sh file has not been found.
    exit 1
fi

chmod 755 $vbox_usbnode_path
chown root:root $vbox_usbnode_path

vboxusers_gid=$(getent group vboxusers | awk -F: '{printf "%d\n", $3}')

vbox_rules="SUBSYSTEM==\"usb_device\", ACTION==\"add\", RUN+=\"$vbox_usbnode_path \$major \$minor \$attr{bDeviceClass} $vboxusers_gid\"
SUBSYSTEM==\"usb\", ACTION==\"add\", ENV{DEVTYPE}==\"usb_device\", RUN+=\"$vbox_usbnode_path \$major \$minor \$attr{bDeviceClass} $vboxusers_gid\"
SUBSYSTEM==\"usb_device\", ACTION==\"remove\", RUN+=\"$vbox_usbnode_path --remove \$major \$minor\"
SUBSYSTEM==\"usb\", ACTION==\"remove\", ENV{DEVTYPE}==\"usb_device\", RUN+=\"$vbox_usbnode_path --remove \$major \$minor\""

echo "$vbox_rules" > /etc/udev/rules.d/virtualbox.rules
rm -f /etc/udev/rules.d/*-virtualbox.rules
udevadm control --reload
adduser `logname` vboxusers

echo All actions succeeded.
echo Log out and log in to see if the issue go fixed.

Be sure to have VM VirtualBox Extension Pack installed and at least USB 2.0 (EHCI) Controller enabled at VM's USB settings.

After these requirements are met, run the above script with sudo.

You may need to reboot the Linux box.

gon1332
  • 191
  • 1
  • 3
0

I used another USB port and... it worked.

We have to be aware that there are different types of USB ports and devices.

If you please, try using another USB port before attempting other ways.

Ganton
  • 109
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 18 '22 at 12:06
  • This comment is added because of the "leave a comment below their post". I understand this is an answer to the question (the proposed way was useful, it avoided me trying a lot of futile methods for my case). – Ganton Feb 22 '22 at 11:05
0

None of the solutions or ideas presented here worked for me. And my issue was intermittent, would come and go between updates and reboots and reinstalls of VirtualBox on Ubuntu.

Solution: using a slightly older kernel, i.e. rebooting and choosing a few versions back, does the trick: it works again.

dargaud
  • 210
  • 3
  • 12