If you already have a .rules
file for the USB device then append the following to the pre-existing file in the /etc/udev/rules.d/
directory. Otherwise, create a file in the /etc/udev/rules.d/
directory with the following content:
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", ACTION=="add", RUN+="/sbin/rmmod ftdi_sio"
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", ACTION=="remove", RUN+=""
This means that when the device with vendorID 0403
and product ID 6010
is plugged in it runs /sbin/rmmod ftdi_sio
which removes the ftdi_sio
module. The second rule means nothing will be run when unplugged. See [writing udev rules] for more info on how to name the .rules
file (e.g. 99-mydevice.rules
)
You'll have to replace 0403
and 6010
with your device's vendor ID and prodcut ID. The vendor ID and product ID can be found by running lsusb
on the command line after plugging in the USB device. It will have the format:
Bus xxx Device xxx: ID idVendor:idProduct ManufacturerName
After creating or editing the .rules
file in /etc/udev/rules.d/
directory be sure to reload the .rules
file with the following command:
sudo udevadm control --reload
Some further references on udev rules:
debian wiki
arch wiki
writing udev rules