Hello! I’m new bie in TrueNas Scale (and Linux too) and I have a problem with one USB device. I’m passing throu to Windows VM external pcie controller. There are 3 devices connected to this controller:
*mouse
*keyboard
*wireless remote controller
Wireless remote controller has a Power button on it. In normal scenario Power button powers off computer. But in my case it powers off VM when VM is running(it’ Ok) and powers off TrueNas when VM is not running and USB controller is not passed throu to VM(it is not Ok).
How to list all devices connected to my computer and how to disable some of them in TrueNas (not in VM)?
I’m using TrueNAS-SCALE-24.04.0
Welcome to the TrueNAS forums (and to TrueNAS SCALE :P)
SCALE does not have a GUI method to disable USBs, and unfortunately does not have the lsusb
command, may we pray it is added in future.
You can script this to disable the USB like this:
- I connect my USB keyboard to my machine
- Output of
dmesg | grep -i usb
shows me this:
[ 1.476558] usb 1-10: new low-speed USB device number 2 using xhci_hcd
[ 1.630327] usb 1-10: New USB device found, idVendor=145f, idProduct=01e5, bcdDevice= 1.10
[ 1.630610] usb 1-10: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1.631064] usb 1-10: Product: USB Keyboard
[ 1.631536] usb 1-10: Manufacturer: SEMICO
Okay, cool, so we know my keyboard is listed as a “USB Keyboard” with Manufacturer “SEMICO”, and we also know the ID for this is ‘1-10’.
Here’s a quick and dirty script that will unbind the USB device, you could run this on demand or run it as a post-init startup script to disable the USB device on startup. I’ve added some checks just to make sure it doesn’t hit the wrong devices:
MAN="SEMICO"
PROD="USB Keyboard"
# Thank you ChatGPT for your contribution to these awk matches!
MAN_ID=$(dmesg | awk -v m="$MAN" '$0 ~ m {match($0, /usb [0-9]+-[0-9]+/); print substr($0, RSTART+4, RLENGTH-4)}')
PROD_ID=$(dmesg | awk -v p="$PROD" '$0 ~ p {match($0, /usb [0-9]+-[0-9]+/); print substr($0, RSTART+4, RLENGTH-4)}')
if [ -z "$MAN_ID" ]; then
echo "Manufacturer USB device not found!"
exit 1
fi
if [ -z "$PROD_ID" ]; then
echo "Product USB device not found!"
exit 1
fi
if [ "$MAN_ID" != "$PROD_ID" ]; then
echo "Manufacturer and Product USB IDs do not match!"
exit 1
fi
echo "$MAN_ID" | tee /sys/bus/usb/drivers/usb/unbind
echo "USB $MAN_ID ($MAN - $PROD) unbound!"

To bind the USB again, all you have to do is edit /sys/bus/usb/drivers/usb/unbind
to /sys/bus/usb/drivers/usb/bind
(you could have this as a second script run on demand).