Gentoo Archives: gentoo-user

From: Walter Dnes <waltdnes@××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Udev rules for identical hard drives
Date: Thu, 02 Aug 2012 17:01:39
Message-Id: 20120802165919.GA25423@waltdnes.org
In Reply to: [gentoo-user] Udev rules for identical hard drives by Alex Schuster
1 On Thu, Aug 02, 2012 at 01:34:04AM +0200, Alex Schuster wrote
2
3 > So I made some udev rules like this, and my drives are called /dev/hd1,
4 > hd2 and hd3:
5 >
6 > SUBSYSTEMS=="scsi", KERNEL=="sd?", ATTRS{model}=="SAMSUNG HD154UI",
7 > SYMLINK="hd1"
8 >
9 > This works fine, and this way I can address them in scripts, smartd and
10 > hdparm config files and such. But now I have two identical drives. I had
11 > this before with the drive above, but while being identical models, the
12 > two drives differed a little in size, so I just had to add ATTR{size}.
13 > This does not help with my current drives, and I find nothing
14 > in /sys/block/sd?/device/ that differs. Could there be another way to
15 > distinguish the drives, like looking at the partition scheme or something?
16
17 You can get the ATTRS{serial} (i.e. serial number). See the printer
18 example at http://www.reactivated.net/writing_udev_rules.html and adapt
19 to your hard drive. Serial numbers should be unique, even amongst
20 otherwise identical drives...
21
22 ======================================================================
23 I power on my printer, and it is assigned device node /dev/lp0. Not
24 satisfied with such a bland name, I decide to use udevinfo to aid me in
25 writing a rule which will provide an alternative name:
26
27 # udevinfo -a -p $(udevinfo -q path -n /dev/lp0)
28 looking at device '/class/usb/lp0':
29 KERNEL=="lp0"
30 SUBSYSTEM=="usb"
31 DRIVER==""
32 ATTR{dev}=="180:0"
33
34 looking at parent device
35 '/devices/pci0000:00/0000:00:1d.0/usb1/1-1':
36 SUBSYSTEMS=="usb"
37 ATTRS{manufacturer}=="EPSON"
38 ATTRS{product}=="USB Printer"
39 ATTRS{serial}=="L72010011070626380"
40
41 My rule becomes:
42
43 SUBSYSTEM=="usb", ATTRS{serial}=="L72010011070626380", SYMLINK+="epson_680"
44 ======================================================================
45
46 --
47 Walter Dnes <waltdnes@××××××××.org>

Replies

Subject Author
Re: [gentoo-user] Udev rules for identical hard drives Alex Schuster <wonko@×××××××××.org>
Re: [gentoo-user] Udev rules for identical hard drives Neil Bothwick <neil@××××××××××.uk>