As my USB dvd drives were being detected into a seemingly random order, I wanted to be able to control what device each was being assigned.
Adding udev rules
- Find serials to add
- sudo udevadm info /dev/sr0 | grep ID_SERIAL_SHORT
- sudo udevadm info /dev/sr1 | grep ID_SERIAL_SHORT
- sudo udevadm info /dev/sr2 | grep ID_SERIAL_SHORT
- Create /etc/udev/rules.d/99-dvd.rules
ACTION="add", KERNEL="sr[0-9]", ENV{ID_SERIAL_SHORT}="first drive serial", SYMLINK+="dvd0"ACTION="add", KERNEL="sr[0-9]", ENV{ID_SERIAL_SHORT}="second drive serial", SYMLINK+="dvd1"
ACTION="add", KERNEL="sr[0-9]", ENV{ID_SERIAL_SHORT}="third drive serial", SYMLINK+="dvd2"
- Reboot or force rerunning the rules
- sudo udevadm control --reload
- sudo udevadm trigger
- However, this did not work
- Edit /etc/udev/rules.d/99-dvd.rules and remove the ACTION
KERNEL="sr[0-9]", ENV{ID_SERIAL_SHORT}="first drive serial", SYMLINK+="dvd0"KERNEL="sr[0-9]", ENV{ID_SERIAL_SHORT}="second drive serial", SYMLINK+="dvd1"
KERNEL="sr[0-9]", ENV{ID_SERIAL_SHORT}="third drive serial", SYMLINK+="dvd2"
- Reboot or force rerunning the rules
- sudo udevadm control --reload
- sudo udevadm trigger
Outcome
Success, it now creates the /dev/dvd* in a consistent order. Unfortunately, Handbrake still tries to use the /dev/sr* labels.
Appendix
Sources
- https://www.reddit.com/r/linuxquestions/comments/1ci1nsj/fixed_identity_location_for_multiple_optical/
- https://reactivated.net/writing_udev_rules.html#basic
- https://dev.to/enbis/how-udev-rules-can-help-us-to-recognize-a-usb-to-serial-device-over-dev-tty-interface-pbk