On Thu, Aug 02, 2012 at 01:34:04AM +0200, Alex Schuster wrote > So I made some udev rules like this, and my drives are called /dev/hd1, > hd2 and hd3: > > SUBSYSTEMS=="scsi", KERNEL=="sd?", ATTRS{model}=="SAMSUNG HD154UI", > SYMLINK="hd1" > > This works fine, and this way I can address them in scripts, smartd and > hdparm config files and such. But now I have two identical drives. I had > this before with the drive above, but while being identical models, the > two drives differed a little in size, so I just had to add ATTR{size}. > This does not help with my current drives, and I find nothing > in /sys/block/sd?/device/ that differs. Could there be another way to > distinguish the drives, like looking at the partition scheme or something?
You can get the ATTRS{serial} (i.e. serial number). See the printer example at http://www.reactivated.net/writing_udev_rules.html and adapt to your hard drive. Serial numbers should be unique, even amongst otherwise identical drives... ====================================================================== I power on my printer, and it is assigned device node /dev/lp0. Not satisfied with such a bland name, I decide to use udevinfo to aid me in writing a rule which will provide an alternative name: # udevinfo -a -p $(udevinfo -q path -n /dev/lp0) looking at device '/class/usb/lp0': KERNEL=="lp0" SUBSYSTEM=="usb" DRIVER=="" ATTR{dev}=="180:0" looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1': SUBSYSTEMS=="usb" ATTRS{manufacturer}=="EPSON" ATTRS{product}=="USB Printer" ATTRS{serial}=="L72010011070626380" My rule becomes: SUBSYSTEM=="usb", ATTRS{serial}=="L72010011070626380", SYMLINK+="epson_680" ====================================================================== -- Walter Dnes <waltd...@waltdnes.org>