UDEV rules, "NAME" variable not working
You can't rename a device node by assigning to the NAME
key in udev rules. At least not in systemd udev. Only a network device name can be changed. From the udev manual:
NAME The name to use for a network interface. See systemd.link(5) for a higher-level mechanism for setting the interface name. The name of a device node cannot be changed by udev, only additional symlinks can be created.
Any udev symlink for a device is not special in it self. It is just a file system symbolic link to the device node. However, an example of useful usage of udev symlink rules is that because device names depends on the order in which the kernel discover devices, the device name that a specific file system resides on is unpredictable. At one time a thumb drive may get the device name /dev/sdf
, and at another /dev/sdg
. Udev rules are usually installed which adds predictable symlink names, like it is done on my Ubuntu laptop in
/dev/disk/by-uuid/
where the uuid of the file systems on the disk are symbolic links pointing to the kernel device name.
As for your last question, you can not have a udev symlink point to anything but a device node, so you can not have it point to a mount point:
SYMLINK The name of a symlink targeting the node. Every matching rule adds this value to the list of symlinks to be created.
To achieve what you want to do, you may give the file system a label, and have the program you use to mount your file systems (udisks2?) use the label in the name of the mount point.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I've written a simple udev rule to help me understand the concept
#SUBSYSTEM=="block", ATTR{size}=="3913727", SYMLINK="AlphaUSB" SUBSYSTEM=="block", ATTR{size}=="3913727", NAME="HelloUSB"
The symlink part of the UDEV rule works (it's been commented out) but the Name part of the UDEV rule doesn't work. I'm not sure what i've done wrong?
My second part of the question is, what is the symlink supposed to do when i have created it? I understand that it points to the device file but that's kind of useless. I would like it to point to the mount point so i can use that as a shortcut to get into the USB, any ideas on how i can do that?