Sometimes we would like to access devices with a more friendly naming or unify naming with disks or devices. Normally USB disks naming depends the order you connect the disk, so if you want to set always the same name for a specific device to access it as /dev/ipod follow next rules to symlink to a new name.
To link devices in /dev find the block device, for example with sdi USB disk.
# udevinfo -q all -n /dev/sdi P: /block/sdi N: sdj
and check which parameters we can use, here is the output /block device:
# udevinfo -a -p /block/sdi
udevinfo starts with the device the node belongs to and then walks up the device chain, to print for every device found, all possibly useful attributes in the udev key format. Only attributes within one device section may be used together in one rule, to match the device for which the node will be created. device '/sys/block/sdi' has major:minor 8:128 looking at class device '/sys/block/sdi': SUBSYSTEM="block" SYSFS{dev}="8:128" SYSFS{range}="16" SYSFS{removable}="1" SYSFS{size}="7999487" SYSFS{stat}=" 3209 214 340102 423892 281 1 282 3808 0 225696 427700" follow the class device's "device" looking at the device chain at '/sys/devices/pci0000:01/0000:01:0e.2/usb3/3-4/3-4.1/3-.1:1.0/host9/target9:0:0/9:0:0:0': BUS="scsi" ID="9:0:0:0" DRIVER="sd" SYSFS{device_blocked}="0" SYSFS{iocounterbits}="32" SYSFS{iodone_cnt}="0xdb1" SYSFS{ioerr_cnt}="0x0" SYSFS{iorequest_cnt}="0xdb1" SYSFS{max_sectors}="240" SYSFS{model}="iPod " SYSFS{queue_depth}="1" SYSFS{queue_type}="none" SYSFS{rev}="1.62" SYSFS{scsi_level}="3" SYSFS{state}="running" SYSFS{timeout}="30" SYSFS{type}="0" SYSFS{vendor}="Apple "
Select the best information to identify the device you want to identify, like SYSFS{model}
Now use this information in /etc/udev/personnal.rules like
BUS=”scsi”, KERNEL=”sd*2″, SYSFS{model}=”iPod “, NAME=”%k”,SYMLINK=”ipod”
Here are more examples of USB disk devices.
[/]#> cat personnal.rules # These rules create the /dev/{cdrom,dvd,...} symlinks. Also see the # /etc/udev/cdsymlinks.conf config file. # # If you would like to statically configure the aliases instead, you can # use rules like: ## BUS="ide", ID="1.0", SYMLINK="cdrom" #BUS="scsi", KERNEL="sd[a-z]*", \ # There are a number of modifiers that are allowed to be used in some # of the different fields. They provide the following subsitutions: # # %n the "kernel number" of the device. # For example, 'sda3' has a "kernel number" of '3' # %e the smallest number for that name which does not matches an existing node # %k the kernel name for the device. # %M the kernel major number for the device # %m the kernel minor number for the device # %b the bus id for the device # %c the string returned by the PROGRAM # %s{filename} the content of a sysfs attribute. # %% the '%' char itself. NAME="%k",SYMLINK="ipod_%n" SEPARA BUS="scsi", KERNEL="sd*1", SYSFS{model}="ST950212A ",NAME="%k",SYMLINK="lacie" BUS="scsi", KERNEL="sd*1", SYSFS{model}="Twist ",NAME="%k",SYMLINK="minimem" BUS="scsi", KERNEL="sd*2", SYSFS{model}="iPod ",NAME="%k",SYMLINK="ipod" BUS="scsi", KERNEL="sd*", SYSFS{model}="ST318437LC ", MODE="0600", OWNER="iguana"
Other options like MODE and OWNER helps you set the owner of the device to a specific username on the system or default file permissions to allow write to others than root only on devices with model like “ST318437LC “.
Note*: You should copy full output of SYSFS{model}, white space before last characters included.
Add a symbolic link in /etc/udev/rules.d/ to your personnal.rules like
[/etc/udev]#> ln -s /etc/udev/personnal.rules /etc/udev/rules.d00-personnal.rules [/etc/udev]#> ls -l /etc/udev/rules.d/00-personnal.rules lrwxrwxrwx 1 root root 18 2007-04-24 21:39 /etc/udev/rules.d/00-personnal.rules -> ../personnal.rules
Other examples useful to allow access to some devices like audio devices to a specific user, but now let’s use KERNEL== field, instead of vendor
# audio devices KERNEL=="dsp*", MODE="0660", OWNER="iguana" KERNEL=="audio*", MODE="0660", OWNER="iguana" KERNEL=="midi*", MODE="0660", OWNER="iguana" KERNEL=="mixer*", MODE="0660", OWNER="iguana" KERNEL=="sequencer*", MODE="0660", OWNER="iguana"