I have many USB external drives (hdd, flash drive, etc) and I want that they appears always with the same name under /dev folder (also mount external hdd with static mount point).
This can be achieved writing custom udev rules.
I have wrote my own rules which I saved them into a /etc/udev/rules.d/10-local.rules file:
SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Western Digital ",ATTRS{product}=="External HDD ", ATTRS{serial}=="575845593037563230383239", KERNEL=="sd?5", NAME="wdbak_var", SYMLINK+="usbdevices/wdbak_var" SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Western Digital ",ATTRS{product}=="External HDD ", ATTRS{serial}=="575845593037563230383239", KERNEL=="sd?6", NAME="wdbak_tmp", SYMLINK+="usbdevices/wdbak_tmp" SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Western Digital ",ATTRS{product}=="External HDD ", ATTRS{serial}=="575845593037563230383239", KERNEL=="sd?7", NAME="wdbak_prtag", SYMLINK+="usbdevices/wdbak_prtag" SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Western Digital ",ATTRS{product}=="External HDD ", ATTRS{serial}=="575843593037363930313237", KERNEL=="sd?1", NAME="wddana", SYMLINK+="usbdevices/wd250j", ACTION=="add", RUN+="/bin/mount /mnt/auto/john" SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Western Digital ",ATTRS{product}=="External HDD ", ATTRS{serial}=="575845593037553933303036", KERNEL=="sd?1", NAME="wdeugen", SYMLINK+="usbdevices/cv250p", ACTION=="add", RUN+="/bin/mount /mnt/auto/smith"
All information about a device handled by udev can be found using the udevadm management tool:
udevadm info -a -p $(udevadm info -q path -n /dev/sdb)
Daniel Dracke have a detailed guide about this and that can be found here.
Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.
The following two tabs change content below.
Eugen Mihailescu
Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Latest posts by Eugen Mihailescu (see all)
- Dual monitor setup in Xfce - January 9, 2019
- Gentoo AMD Ryzen stabilizator - April 29, 2018
- Symfony Compile Error Failed opening required Proxies - January 22, 2018