0

I have a Ubuntu 16.04 based VM which runs inside VirtualBox on Windows 10. On my Host, I've connected a ZWave USB antenna, which I've then mapped/attached to the VM. When I first boot my VM, I can see that the USB device is properly detected as /dev/ttyACM0:

eric@XMEANT ~ $ dmesg | grep acm
[   18.593264] cdc_acm 2-2:1.0: ttyACM0: USB ACM device

eric@XMEANT ~ $ ls /dev/ttyA*
/dev/ttyACM0

However, after I wake my Host wakes from sleep mode, I no longer see the device listed in my /dev.

eric@XMEANT ~ $ ls /dev/ttyA*
ls: cannot access '/dev/ttyA*': No such file or directory

Following hints I found on another Superuser question, I tried the following:

eric@XMEANT ~ $ cat /proc/tty/drivers
/dev/tty             /dev/tty        5       0 system:/dev/tty
/dev/console         /dev/console    5       1 system:console
/dev/ptmx            /dev/ptmx       5       2 system
/dev/vc/0            /dev/vc/0       4       0 system:vtmaster
acm                  /dev/ttyACM   166 0-255 serial
ttyprintk            /dev/ttyprintk   5       3 console
max310x              /dev/ttyMAX   204 209-224 serial
serial               /dev/ttyS       4 64-111 serial
pty_slave            /dev/pts      136 0-1048575 pty:slave
pty_master           /dev/ptm      128 0-1048575 pty:master
unknown              /dev/tty        4 1-63 console

eric@XMEANT ~ $ lsmod | grep acm
cdc_acm                36864  0

eric@XMEANT ~ $ sudo modprobe -r cdc_acm
eric@XMEANT ~ $ sudo modprobe  cdc_acm

However, still no device found:

eric@XMEANT ~ $ ls /dev/ttyA*
ls: cannot access '/dev/ttyA*': No such file or directory

I've tried to unmap it from VirtualBox and remap it, but it made no difference. The only way I've been able to figure out is to restart the VM. But that is not really an effective solution as it can take several minutes to restart my VM and all services/etc.

Is there any other way I can force the VM to rescan/redetect the missing device or restart the subservice required to find it?

Eric B.
  • 1,061

1 Answers1

0

You should try to reload USB core modules.

Not sure you are facing exactly the same issue than I used to have (a VirtualBox VM running Debian 9 which sometimes loose all its USB devices, not related to any suspends), but this small script works well for my case:

#!/bin/sh

USB_DRIVERS="ehci_pci ehci_hcd ohci_pci ohci_hcd"

echo "Unloading USB modules..."
for usb_driver in ${USB_DRIVERS}
do
    sudo modprobe -r ${usb_driver}
done

echo "Reloading USB modules..."
for usb_driver in ${USB_DRIVERS}
do
    sudo modprobe ${usb_driver}
done

sleep 2
lsusb

It unloads USB modules, reloads them and finally list USB devices.

A. Loiseau
  • 1,268