[B450] USB issue on AMD with Linux

Since I’ve now discovered that one or all of my rift device were causing the issue I’ve written a bash script to disable them. This is my first time programming in bash and it’s only a proof of concept so please try to excuse the horrible inefficiency:


# Set usb device locations
front_sensor=$(cat /sys/bus/usb/devices/2-3/product)
back_sensor1=$(cat /sys/bus/usb/devices/4-2/product)
back_sensor2=$(cat /sys/bus/usb/devices/1-2.1/product)
hub=$(cat /sys/bus/usb/devices/1-2/product)
back_rift1=$(cat /sys/bus/usb/devices/3-1/product)
back_rift2=$(cat /sys/bus/usb/devices/3-1.1/product)
back_rift3=$(cat /sys/bus/usb/devices/4-1/product)

# Set hardware names
sensor_str="Rift Sensor"
hub_str="USB 2.0 Hub"

# If device locations match hardware names (devices are plugged into usb ports)
# then disable them
if [ "$front_sensor" == "$sensor_str" ]; then
    echo '2-3' | tee /sys/bus/usb/drivers/usb/unbind

if [ "$back_sensor1" == "$sensor_str" ]; then
    echo '4-2' | tee /sys/bus/usb/drivers/usb/unbind

if [ "$back_sensor2" == "$sensor_str" ]; then
    echo '1-2.1' | tee /sys/bus/usb/drivers/usb/unbind

if [ "$hub" == "$hub_str" ]; then
    echo '1-2' | tee /sys/bus/usb/drivers/usb/unbind

if [ "$back_rift1" == "$rift_str" ]; then
    echo '3-1' | tee /sys/bus/usb/drivers/usb/unbind

if [ "$back_rift2" == "$rift_str" ]; then
    echo '3-1.1' | tee /sys/bus/usb/drivers/usb/unbind

if [ "$back_rift3" == "$rift_str" ]; then
    echo '4-1' | tee /sys/bus/usb/drivers/usb/unbind

My question is how can I make this script execute as root every time a usb event happens? I know how to make a systemd startup service but I’ve never done an event based script before.

Edit: I’ve also just turned off USB power management for my entire system with ACTION=="add", SUBSYSTEM="usb", TEST=="power/control", ATTR{power/control}="off" as I really have absolutely no need for it and I can just see it causing more problems in the future.

EDIT: Using the power of the internet I have now figured out how to run this script every time a USB device is plugged in I’m marking this as solved for now unless the issue reoccurs. Thanks to @Mastic_Warrior and @jdfthetech for helping me :smiley:


Awesome job. I hope that i don’t have these issues when i go to zen 3

1 Like

Thanks. You should be find as long as you don’t have oculus rift hardware plugged in.

thanks for posting the solution and cause, I learned something today

1 Like

I would not touch Occulus with a 10 foot pole because facebook.