Gentoo Archives: gentoo-user

From: Alex Schuster <wonko@×××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Udev rules for identical hard drives
Date: Thu, 02 Aug 2012 17:46:16
Message-Id: 20120802194350.6a721f35@weird.wonkology.org
In Reply to: Re: [gentoo-user] Udev rules for identical hard drives by Walter Dnes
1 Walter Dnes writes:
2
3 > You can get the ATTRS{serial} (i.e. serial number). See the printer
4 > example at http://www.reactivated.net/writing_udev_rules.html and adapt
5 > to your hard drive. Serial numbers should be unique, even amongst
6 > otherwise identical drives...
7 >
8 > ======================================================================
9 > I power on my printer, and it is assigned device node /dev/lp0. Not
10 > satisfied with such a bland name, I decide to use udevinfo to aid me in
11 > writing a rule which will provide an alternative name:
12 >
13 > # udevinfo -a -p $(udevinfo -q path -n /dev/lp0)
14 > looking at device '/class/usb/lp0':
15 > KERNEL=="lp0"
16 > SUBSYSTEM=="usb"
17 > DRIVER==""
18 > ATTR{dev}=="180:0"
19 >
20 > looking at parent device
21 > '/devices/pci0000:00/0000:00:1d.0/usb1/1-1':
22 > SUBSYSTEMS=="usb"
23 > ATTRS{manufacturer}=="EPSON"
24 > ATTRS{product}=="USB Printer"
25 > ATTRS{serial}=="L72010011070626380"
26 >
27 > My rule becomes:
28 >
29 > SUBSYSTEM=="usb", ATTRS{serial}=="L72010011070626380",
30 > SYMLINK+="epson_680"
31
32 That's exactly what I would like to have! I have a working solution, but
33 using UDEV would seem more adequate.
34
35 But: I cannot find a serial number for my hard drives in the output. And
36 shouldn't there be a file named 'serial' in /sys? I have some, but not
37 for my block devices, only for USB and in /sys/{bus,pci}/drivers/.
38
39 BTW, sys-fs/udev-187 does not have the 'udevinfo' command, it seems to be
40 'udevadm info' now.
41
42 Wonko

Replies

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