LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 09-14-2007, 03:06 AM   #1
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Rep: Reputation: 45
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,

Last edited by xushi; 09-14-2007 at 03:50 AM.
 
Old 09-14-2007, 07:38 AM   #2
mmmmtmmmm
LQ Newbie
 
Registered: Aug 2007
Posts: 24

Rep: Reputation: 15
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
 
Old 09-14-2007, 07:45 AM   #3
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Original Poster
Rep: Reputation: 45
Quote:
Originally Posted by mmmmtmmmm View Post
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?

Last edited by xushi; 09-14-2007 at 07:53 AM.
 
Old 09-28-2007, 12:18 PM   #4
mcclurem
LQ Newbie
 
Registered: Sep 2007
Location: Massachusetts/Ohio
Distribution: Gentoo
Posts: 2

Rep: Reputation: 0
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
 
Old 01-02-2008, 10:48 PM   #5
Joe_Sextus
LQ Newbie
 
Registered: Jan 2006
Posts: 1

Rep: Reputation: 0
@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"

Last edited by Joe_Sextus; 01-02-2008 at 11:01 PM.
 
Old 01-03-2008, 01:49 AM   #6
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Original Poster
Rep: Reputation: 45
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 hard drives, XP on my main sata drives, 10.2 on my IDE LILO doesnt show on boot up Dachy Slackware 14 01-03-2008 07:01 AM
SATA Hard disk(Windows) MBR corrupted by IDE hard disk(Linux) Peter_APIIT Fedora 6 07-07-2007 12:20 AM
SATA RAID disk fail detection henrikost Linux - Hardware 2 09-21-2006 02:28 AM
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 03:43 AM
Hard drives fail to mount. MurX Linux - Hardware 4 11-01-2005 05:36 AM


All times are GMT -5. The time now is 02:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration