LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   udev rules fail on identical sata hard disk drives (https://www.linuxquestions.org/questions/linux-hardware-18/udev-rules-fail-on-identical-sata-hard-disk-drives-584595/)

xushi 09-14-2007 03:06 AM

udev rules fail on identical sata hard disk drives
 
Hi all,

This is a bit of a challenge to me. I tried for 3 days so i hope you all can help me solve it. The topic is a bit long but I'm trying not to leave any detail out.

Summary

I need help setting up udev on my identical hard drives that apparently show no serial number.

Problem

What i'm trying to do is use udev to ease the adding/removing of hard drives and setting up RAID on my server. Currently the server has about 8 hard disks connected, and i have another 6 more to connect. They are ordered in a specific way so everytime I add one more, their order gets messed up (sdd becomes sdf, sde becomes sdd, etc..), so I spend a whole day reorganizing them so that they mount to the right places.

I was told that I could use udev to specifically name the devices so that they'll always be ordered. I tried, but noticed that because my hard drives are identical, it caused a big challenge to me. I buy in bulk, so I have for example 4 x 500Gb SATA2 WD disks, 2 x 320Gb WD disks, etc..


The Details

The way I got my information is using udevinfo and hdparm. Let's start with the controller cards and 2 of the disks of which are identical.


Controller Cards (PCI)
Code:

sempron xushi # lspci
02:07.0 RAID bus controller: Silicon Image, Inc. SiI 3114 [SATALink/SATARaid] Serial ATA Controller (rev 02)
02:09.0 RAID bus controller: Silicon Image, Inc. SiI 3114 [SATALink/SATARaid] Serial ATA Controller (rev 02)


Hard disk 3

Code:

sempron xushi # hdparm -I /dev/sdd

/dev/sdd:

ATA device, with non-removable media
        Model Number:      WDC WD3200KS-00PFB0
        Serial Number:      WD-WCAPD2516974
        Firmware Revision:  21.00M21
Standards:
        Supported: 7 6 5 4
        Likely used: 7
Configuration:
        Logical        max    current
        cylinders      16383  16383
        heads          16      16
        sectors/track  63      63
        --
        CHS current addressable sectors:  16514064
        LBA    user addressable sectors:  268435455
        LBA48  user addressable sectors:  625142448
        device size with M = 1024*1024:      305245 MBytes
        device size with M = 1000*1000:      320072 MBytes (320 GB)
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 1
        Standby timer values: spec'd by Standard, with device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 0
        Recommended acoustic management value: 128, current value: 254
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5 udma6
            Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
            Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
          *    SMART feature set
                Security Mode feature set
          *    Power Management feature set
          *    Write cache
          *    Look-ahead
          *    Host Protected Area feature set
          *    WRITE_BUFFER command
          *    READ_BUFFER command
          *    NOP cmd
          *    DOWNLOAD_MICROCODE
                Power-Up In Standby feature set
          *    SET_FEATURES required to spinup after power up
                SET_MAX security extension
                Automatic Acoustic Management feature set
          *    48-bit Address feature set
          *    Device Configuration Overlay feature set
          *    Mandatory FLUSH_CACHE
          *    FLUSH_CACHE_EXT
          *    SMART error logging
          *    SMART self-test
          *    General Purpose Logging feature set
          *    SATA-I signaling speed (1.5Gb/s)
          *    SATA-II signaling speed (3.0Gb/s)
          *    Native Command Queueing (NCQ)
          *    Host-initiated interface power management
          *    Phy event counters
                DMA Setup Auto-Activate optimization
          *    Software settings preservation
          *    SMART Command Transport (SCT) feature set
          *    SCT Long Sector Access (AC1)
          *    SCT LBA Segment Access (AC2)
          *    SCT Error Recovery Control (AC3)
          *    SCT Features Control (AC4)
          *    SCT Data Tables (AC5)
                unknown 206[12]
Security:
        Master password revision code = 65534
                supported
        not    enabled
        not    locked
        not    frozen
        not    expired: security count
        not    supported: enhanced erase
Checksum: correct
sempron xushi #

Code:

sempron xushi # udevinfo -a -p /sys/block/sdd/

  looking at device '/block/sdd':
    KERNEL=="sdd"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{capability}=="12"
    ATTR{stat}=="    2351    2619    58020    24628    1767    5452    57776    2968        0    5740    27596"
    ATTR{size}=="625142448"
    ATTR{removable}=="0"
    ATTR{range}=="16"
    ATTR{dev}=="8:48"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.0/host7/target7:0:0/7:0:0:0':
    KERNELS=="7:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{modalias}=="scsi:t-0x00"
    ATTRS{ioerr_cnt}=="0x2"
    ATTRS{iodone_cnt}=="0x1028"
    ATTRS{iorequest_cnt}=="0x1028"
    ATTRS{iocounterbits}=="32"
    ATTRS{timeout}=="60"
    ATTRS{state}=="running"
    ATTRS{rev}=="21.0"
    ATTRS{model}=="WDC WD3200KS-00P"
    ATTRS{vendor}=="ATA    "
    ATTRS{scsi_level}=="6"
    ATTRS{type}=="0"
    ATTRS{queue_type}=="none"
    ATTRS{queue_depth}=="1"
    ATTRS{device_blocked}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.0/host7/target7:0:0':
    KERNELS=="target7:0:0"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.0/host7':
    KERNELS=="host7"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.0':
    KERNELS=="0000:02:09.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="sata_sil"
    ATTRS{msi_bus}==""
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{numa_node}=="0"
    ATTRS{modalias}=="pci:v00001095d00003114sv00001095sd00006114bc01sc04i00"
    ATTRS{local_cpus}=="00000001"
    ATTRS{irq}=="16"
    ATTRS{class}=="0x010400"
    ATTRS{subsystem_device}=="0x6114"
    ATTRS{subsystem_vendor}=="0x1095"
    ATTRS{device}=="0x3114"
    ATTRS{vendor}=="0x1095"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0':
    KERNELS=="0000:00:0e.0"
    SUBSYSTEMS=="pci"
    DRIVERS==""
    ATTRS{msi_bus}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{numa_node}=="0"
    ATTRS{modalias}=="pci:v000010DEd000000EDsv00000000sd00000000bc06sc04i00"
    ATTRS{local_cpus}=="00000001"
    ATTRS{irq}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{device}=="0x00ed"
    ATTRS{vendor}=="0x10de"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

sempron xushi #


And here's HD6
Code:

sempron xushi # hdparm -I /dev/sde

/dev/sde:

ATA device, with non-removable media
        Model Number:      WDC WD3200KS-00PFB0
        Serial Number:      WD-WCAPD2637232
        Firmware Revision:  21.00M21
Standards:
        Supported: 7 6 5 4
        Likely used: 7
Configuration:
        Logical        max    current
        cylinders      16383  16383
        heads          16      16
        sectors/track  63      63
        --
        CHS current addressable sectors:  16514064
        LBA    user addressable sectors:  268435455
        LBA48  user addressable sectors:  625142448
        device size with M = 1024*1024:      305245 MBytes
        device size with M = 1000*1000:      320072 MBytes (320 GB)
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 1
        Standby timer values: spec'd by Standard, with device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 0
        Recommended acoustic management value: 128, current value: 254
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5 udma6
            Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
            Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
          *    SMART feature set
                Security Mode feature set
          *    Power Management feature set
          *    Write cache
          *    Look-ahead
          *    Host Protected Area feature set
          *    WRITE_BUFFER command
          *    READ_BUFFER command
          *    NOP cmd
          *    DOWNLOAD_MICROCODE
                Power-Up In Standby feature set
          *    SET_FEATURES required to spinup after power up
                SET_MAX security extension
                Automatic Acoustic Management feature set
          *    48-bit Address feature set
          *    Device Configuration Overlay feature set
          *    Mandatory FLUSH_CACHE
          *    FLUSH_CACHE_EXT
          *    SMART error logging
          *    SMART self-test
          *    General Purpose Logging feature set
          *    SATA-I signaling speed (1.5Gb/s)
          *    SATA-II signaling speed (3.0Gb/s)
          *    Native Command Queueing (NCQ)
          *    Host-initiated interface power management
          *    Phy event counters
                DMA Setup Auto-Activate optimization
          *    Software settings preservation
          *    SMART Command Transport (SCT) feature set
          *    SCT Long Sector Access (AC1)
          *    SCT LBA Segment Access (AC2)
          *    SCT Error Recovery Control (AC3)
          *    SCT Features Control (AC4)
          *    SCT Data Tables (AC5)
                unknown 206[12]
Security:
        Master password revision code = 65534
                supported
        not    enabled
        not    locked
        not    frozen
        not    expired: security count
        not    supported: enhanced erase
Checksum: correct
sempron xushi #

Code:

sempron xushi # udevinfo -a -p /sys/block/sde
  looking at device '/block/sde':
    KERNEL=="sde"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{capability}=="12"
    ATTR{stat}=="      87    1248    3036      160        2        3      16        8        0      144      168"
    ATTR{size}=="625142448"
    ATTR{removable}=="0"
    ATTR{range}=="16"
    ATTR{dev}=="8:64"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.0/host8/target8:0:0/8:0:0:0':
    KERNELS=="8:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{modalias}=="scsi:t-0x00"
    ATTRS{ioerr_cnt}=="0x2"
    ATTRS{iodone_cnt}=="0x6b"
    ATTRS{iorequest_cnt}=="0x6b"
    ATTRS{iocounterbits}=="32"
    ATTRS{timeout}=="60"
    ATTRS{state}=="running"
    ATTRS{rev}=="21.0"
    ATTRS{model}=="WDC WD3200KS-00P"
    ATTRS{vendor}=="ATA    "
    ATTRS{scsi_level}=="6"
    ATTRS{type}=="0"
    ATTRS{queue_type}=="none"
    ATTRS{queue_depth}=="1"
    ATTRS{device_blocked}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.0/host8/target8:0:0':
    KERNELS=="target8:0:0"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.0/host8':
    KERNELS=="host8"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.0':
    KERNELS=="0000:02:09.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="sata_sil"
    ATTRS{msi_bus}==""
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{numa_node}=="0"
    ATTRS{modalias}=="pci:v00001095d00003114sv00001095sd00006114bc01sc04i00"
    ATTRS{local_cpus}=="00000001"
    ATTRS{irq}=="16"
    ATTRS{class}=="0x010400"
    ATTRS{subsystem_device}=="0x6114"
    ATTRS{subsystem_vendor}=="0x1095"
    ATTRS{device}=="0x3114"
    ATTRS{vendor}=="0x1095"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0':
    KERNELS=="0000:00:0e.0"
    SUBSYSTEMS=="pci"
    DRIVERS==""
    ATTRS{msi_bus}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{numa_node}=="0"
    ATTRS{modalias}=="pci:v000010DEd000000EDsv00000000sd00000000bc06sc04i00"
    ATTRS{local_cpus}=="00000001"
    ATTRS{irq}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{device}=="0x00ed"
    ATTRS{vendor}=="0x10de"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

sempron xushi #

What i learned is that i should build my udev rule using the information in udevinfo. Here is an example of how my rule started as,

Code:

SUBSYSTEMS=="scsi", ATTR{size}=="625142448", ATTRS{model}=="WDC WD3200KS-00P", NAME="storage3"
Notice from the above that what I managed to gather is the disk size and the disk model. However, I noticed when I tried to create the same rule for HD6, I got identical information too, so the rule was useless.

What supprized me is that I did not find any ATTR{serial} tag in udevinfo. That's when i switched over to hdparm, and I found one there! So here is how my two rules ended up looking at,

Code:

#hd3
KERNEL=="sd*", ATTR{serial}="WD-WCAPD2516974", ATTRS{model}=="WDC WD3200KS-00P", NAME="%k", SYMLINK+="storage3%n"

#hd6
KERNEL=="sd*", ATTR{serial}="WD-WCAPD2637232", ATTRS{model}=="WDC WD3200KS-00P", NAME="%k", SYMLINK+="storage6%n"

However, this gave me random results everytime i trigger udev. Sometimes /dev/storage6X points to totally other hard drives that are not on the list, sometimes it points to the same disk as HD3, and sometimes it doesn't exist at all. This led me to believe that the ATTR{serial}is not functioning or malfunctioning as a parameter in the rule. I also tried the same rules without the ATTR{model} but same results.

So now i'm stuck. I don't know what I can use to distinguish between the hard drives.


I don't really want to list the udevinfo and hdparm of every single hard drive i have, because that will make this thread too long. It's the same problem with the other hard drives, so I thought if we start with 2 or 3 of them, then the others will be solved the same way. However, If it will help the problem by listing all the information, please tell me and I will.

At first I thought it might have been a problem or limitation of my SATA Raid controller, so I had a look at the other controllers I have, but still, i have the same problem.

Here is the information of /dev/sda, which is a SCSI160 connected to an Adaptec 29160LP U160 controller card
Code:

sempron xushi # udevinfo -a -p /sys/block/sda

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/block/sda':
    KERNEL=="sda"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{capability}=="12"
    ATTR{stat}=="    3552    1032  151976    53580    1764    2706    35754    78884        0    20956  132464"
    ATTR{size}=="35916548"
    ATTR{removable}=="0"
    ATTR{range}=="16"
    ATTR{dev}=="8:0"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:08.0/host0/target0:0:4/0:0:4:0':
    KERNELS=="0:0:4:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{modalias}=="scsi:t-0x00"
    ATTRS{ioerr_cnt}=="0x1"
    ATTRS{iodone_cnt}=="0x1508"
    ATTRS{iorequest_cnt}=="0x1508"
    ATTRS{iocounterbits}=="32"
    ATTRS{timeout}=="60"
    ATTRS{state}=="running"
    ATTRS{rev}=="020W"
    ATTRS{model}=="ATLAS10K3_18_WLS"
    ATTRS{vendor}=="QUANTUM "
    ATTRS{scsi_level}=="4"
    ATTRS{type}=="0"
    ATTRS{queue_type}=="ordered"
    ATTRS{queue_depth}=="32"
    ATTRS{device_blocked}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:08.0/host0/target0:0:4':
    KERNELS=="target0:0:4"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:08.0/host0':
    KERNELS=="host0"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:08.0':
    KERNELS=="0000:02:08.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="aic7xxx"
    ATTRS{msi_bus}==""
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{numa_node}=="0"
    ATTRS{modalias}=="pci:v00009005d00000080sv00009005sd0000E2A0bc01sc00i00"
    ATTRS{local_cpus}=="00000001"
    ATTRS{irq}=="18"
    ATTRS{class}=="0x010000"
    ATTRS{subsystem_device}=="0xe2a0"
    ATTRS{subsystem_vendor}=="0x9005"
    ATTRS{device}=="0x0080"
    ATTRS{vendor}=="0x9005"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0':
    KERNELS=="0000:00:0e.0"
    SUBSYSTEMS=="pci"
    DRIVERS==""
    ATTRS{msi_bus}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{numa_node}=="0"
    ATTRS{modalias}=="pci:v000010DEd000000EDsv00000000sd00000000bc06sc04i00"
    ATTRS{local_cpus}=="00000001"
    ATTRS{irq}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{device}=="0x00ed"
    ATTRS{vendor}=="0x10de"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

sempron xushi #

Code:

sempron xushi # hdparm -I /dev/sda

/dev/sda:
 HDIO_DRIVE_CMD(identify) failed: Invalid argument
sempron xushi #

Odd with the hdparm, but no serial number found in udevinfo. The same is with my built in nVidia CK8S IDE controller with a 300Gb disk.

Code:

sempron xushi # udevinfo -a -p /sys/block/hda
  looking at device '/block/hda':
    KERNEL=="hda"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{capability}=="10"
    ATTR{stat}=="    118      286    1516      552        3        2      16        8        0      516      560"
    ATTR{size}=="586072368"
    ATTR{removable}=="0"
    ATTR{range}=="64"
    ATTR{dev}=="3:0"

  looking at parent device '/devices/pci0000:00/0000:00:08.0/ide0/0.0':
    KERNELS=="0.0"
    SUBSYSTEMS=="ide"
    DRIVERS=="ide-disk"
    ATTRS{modalias}=="ide:m-disk"
    ATTRS{drivename}=="hda"
    ATTRS{media}=="disk"

  looking at parent device '/devices/pci0000:00/0000:00:08.0/ide0':
    KERNELS=="ide0"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:08.0':
    KERNELS=="0000:00:08.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="AMD_IDE"
    ATTRS{msi_bus}==""
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{numa_node}=="0"
    ATTRS{modalias}=="pci:v000010DEd000000E5sv00001043sd0000813Fbc01sc01i8a"
    ATTRS{local_cpus}=="00000001"
    ATTRS{irq}=="0"
    ATTRS{class}=="0x01018a"
    ATTRS{subsystem_device}=="0x813f"
    ATTRS{subsystem_vendor}=="0x1043"
    ATTRS{device}=="0x00e5"
    ATTRS{vendor}=="0x10de"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

sempron xushi #

And the same thing with the built in SATA CK8 chipset too.


Extra Information
Finally, here is some additional information.

I'm running Linux on an AMD Sempron with udev v114, on kernel 2.6.22, GCC 4.1.2.

Code:

sempron xushi # uname -a
Linux sempron 2.6.22-gentoo-r2 #10 SMP Sat Aug 25 20:55:26 EEST 2007 x86_64 AMD Sempron(tm) Processor 2800+ AuthenticAMD GNU/Linux

Code:

sempron xushi # emerge --info
=================================================================
System uname: 2.6.22-gentoo-r2 x86_64 AMD Sempron(tm) Processor 2800+
app-shells/bash:    3.2_p17
dev-java/java-config: 1.3.7, 2.0.33-r1
dev-lang/python:    2.4.4-r4
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 1.12.9-r2
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.61
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.16
sys-devel/libtool:  1.5.23b
virtual/os-headers:  2.6.21
CFLAGS="-O2 -pipe -march=k8 -fomit-frame-pointer -msse3 -falign-functions=64"
CHOST="x86_64-pc-linux-gnu"
CXXFLAGS="-O2 -pipe -march=k8 -fomit-frame-pointer -msse3 -falign-functions=64"
MAKEOPTS="-j2"

Summary
So to sum it up, I'm not sure what I can use from the udevinfo information that I can distinguish between the hard drives. I'm not also sure if my udev rules are correct. I hope someone can shed some light onto this problem. If you need more info i'm happy to help.

Thanks a lot,

mmmmtmmmm 09-14-2007 07:38 AM

I found an article that might be of assistance to you:

http://www.reactivated.net/writing_udev_rules.html

There is a section that reads:

"Under some circumstances, you may require more flexibility than standard udev rules can provide. In this case, you can ask udev to run a program and use the standard output from that program to provide device naming."

I noticed that the serial numbers from hdparm were different for each drive...perhaps you could use this to write a script to grep the serial number and map them to the proper location with PROGRAM=...?

Do you know any Perl or other text processing languages?

---mmmmtmmmm

xushi 09-14-2007 07:45 AM

Quote:

Originally Posted by mmmmtmmmm (Post 2891649)
I found an article that might be of assistance to you:

http://www.reactivated.net/writing_udev_rules.html

There is a section that reads:

"Under some circumstances, you may require more flexibility than standard udev rules can provide. In this case, you can ask udev to run a program and use the standard output from that program to provide device naming."

I noticed that the serial numbers from hdparm were different for each drive...perhaps you could use this to write a script to grep the serial number and map them to the proper location with PROGRAM=...?

Do you know any Perl or other text processing languages?

---mmmmtmmmm

Thanks mmmmtmmmm, I got k-lined and banned by mistake.. Sorting it out now.

I know bash, and i'll give this a try.

I just would like to follow up, I did manage to get a serial number finally from the output of the following,

Code:

sempron sdd # udevinfo -q all -p /sys/block/sdd
P: /block/sdd
N: sdd
S: disk/by-id/scsi-SATA_WDC_WD3200KS-00_WD-WCAPD2516974
S: disk/by-id/ata-WDC_WD3200KS-00PFB0_WD-WCAPD2516974
S: disk/by-path/pci-0000:02:09.0-scsi-2:0:0:0
E: DEVTYPE=disk
E: ID_VENDOR=ATA
E: ID_MODEL=WDC_WD3200KS-00P
E: ID_REVISION=21.0
E: ID_SERIAL=SATA_WDC_WD3200KS-00_WD-WCAPD2516974
E: ID_SERIAL_SHORT=WD-WCAPD2516974
E: ID_TYPE=disk
E: ID_BUS=scsi
E: ID_ATA_COMPAT=WDC_WD3200KS-00PFB0_WD-WCAPD2516974
E: ID_PATH=pci-0000:02:09.0-scsi-2:0:0:0

But I couldn't figure out how to use it in my rule. I tried the following
Code:

KERNEL=="sd*", DEV{ID_SERIAL}=="SATA_WDC_WD3200KS-00_WD-WCAPD2516974", NAME="%k", SYMLINK+="storage3%n"
But it gave me random devs everytime i ran the trigger that even pointed to the wrong hard drive(s).
Code:

sempron sdd # udevtrigger
sempron sdd # ls -l /dev/sto*
lrwxrwxrwx 1 root root 3 2007-09-14 15:39 /dev/storage3 -> sdh
lrwxrwxrwx 1 root root 4 2007-09-14 15:39 /dev/storage31 -> sdg1
lrwxrwxrwx 1 root root 4 2007-09-14 15:39 /dev/storage32 -> sda2
lrwxrwxrwx 1 root root 4 2007-09-14 15:39 /dev/storage33 -> sda3
sempron sdd # udevtrigger
sempron sdd # ls -l /dev/sto*
lrwxrwxrwx 1 root root 3 2007-09-14 15:40 /dev/storage3 -> sdf
lrwxrwxrwx 1 root root 4 2007-09-14 15:40 /dev/storage31 -> sdf1
lrwxrwxrwx 1 root root 4 2007-09-14 15:39 /dev/storage32 -> sda2
lrwxrwxrwx 1 root root 4 2007-09-14 15:39 /dev/storage33 -> sda3
sempron sdd # udevtrigger
sempron sdd # ls -l /dev/sto*
lrwxrwxrwx 1 root root 3 2007-09-14 15:40 /dev/storage3 -> sdh
lrwxrwxrwx 1 root root 4 2007-09-14 15:40 /dev/storage31 -> sdh1
lrwxrwxrwx 1 root root 4 2007-09-14 15:39 /dev/storage32 -> sda2
lrwxrwxrwx 1 root root 4 2007-09-14 15:39 /dev/storage33 -> sda3


EDIT: Hmm, I don't think using an external program would help, unless I misunderstood. Even if i use an external program to get the serial and map it, it wont work, because it doesn't work currently when i manually enter that same serial. Am i talking any sense?

mcclurem 09-28-2007 12:18 PM

Just wanted to let you know that I was trying to do the same thing and succeeded. - I'd recommend using the ID_SERIAL_SHORT field instead of the ID_SERIAL field - I did and it worked (not to mention its easier to read)

Heres my udev rule:
KERNEL=="sd*", SUBSYSTEM=="block", DEV{ID_SERIAL_SHORT}=="6QF0WT18", SYMLINK+="old%n"

hope it helps

Joe_Sextus 01-02-2008 10:48 PM

@xushi

Did you ever find a solution to this? I am experiencing a similar issue with my hard drives.

Edit:
Nevermind, I fixed my issue. For me

Quote:

KERNEL=="sd*", SUBSYSTEM=="block", DEV{ID_SERIAL_SHORT}=="6QF0WT18", SYMLINK+="old%n"
needed to be

Quote:

KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="6QF0WT18", SYMLINK+="old%n"

xushi 01-03-2008 01:49 AM

I haven't had the time due to work and all, sorry.

However, I'll be getting another 4 hard drives this month, So i'll confirm the fixes as soon as i can.

Thanks.


All times are GMT -5. The time now is 05:17 AM.