# identify SAME hdd with udev

## jancici

hi, trying to find a solution 

I have TWO same HDD, I need to identify those with udev 

for FIRST hdd

```
udevadm info -a -p $(udevadm info -q path -n /dev/sdc1)

Udevadm info 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 '/devices/pci0000:00/0000:00:1f.2/host5/target5:0:0/5:0:0:0/block/sdc/sdc1':

    KERNEL=="sdc1"

    SUBSYSTEM=="block"

    DRIVER==""

    ATTR{partition}=="1"

    ATTR{start}=="63"

    ATTR{size}=="976768002"

    ATTR{alignment_offset}=="0"

    ATTR{discard_alignment}=="4294935040"

    ATTR{stat}=="   37041    10798 13789130   593346     4826     1239   223872    85110        0   107590   678373"

    ATTR{inflight}=="       0        0"

  looking at parent device '/devices/pci0000:00/0000:00:1f.2/host5/target5:0:0/5:0:0:0/block/sdc':

    KERNELS=="sdc"

    SUBSYSTEMS=="block"

    DRIVERS==""

    ATTRS{range}=="16"

    ATTRS{ext_range}=="256"

    ATTRS{removable}=="0"

    ATTRS{ro}=="0"

    ATTRS{size}=="976773168"

    ATTRS{alignment_offset}=="0"

    ATTRS{discard_alignment}=="0"

    ATTRS{capability}=="52"

    ATTRS{stat}=="   37053    10844 13789594   593383     4826     1239   223872    85110        0   107626   678410"

    ATTRS{inflight}=="       0        0"

  looking at parent device '/devices/pci0000:00/0000:00:1f.2/host5/target5:0:0/5:0:0:0':

    KERNELS=="5:0:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS=="sd"

    ATTRS{device_blocked}=="0"

    ATTRS{type}=="0"

    ATTRS{scsi_level}=="6"

    ATTRS{vendor}=="ATA     "

    ATTRS{model}=="SAMSUNG HD502HJ "

    ATTRS{rev}=="1AJ1"

    ATTRS{state}=="running"

    ATTRS{timeout}=="30"

    ATTRS{iocounterbits}=="32"

    ATTRS{iorequest_cnt}=="0xa6c0"

    ATTRS{iodone_cnt}=="0xa682"

    ATTRS{ioerr_cnt}=="0x106"

    ATTRS{modalias}=="scsi:t-0x00"

    ATTRS{evt_media_change}=="0"

    ATTRS{queue_depth}=="31"

    ATTRS{queue_ramp_up_period}=="120000"

    ATTRS{queue_type}=="simple"

  looking at parent device '/devices/pci0000:00/0000:00:1f.2/host5/target5:0:0':

    KERNELS=="target5:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:1f.2/host5':

    KERNELS=="host5"

    SUBSYSTEMS=="scsi"

    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:1f.2':

    KERNELS=="0000:00:1f.2"

    SUBSYSTEMS=="pci"

    DRIVERS=="ahci"

    ATTRS{vendor}=="0x8086"

    ATTRS{device}=="0x3a22"

    ATTRS{subsystem_vendor}=="0x1043"

    ATTRS{subsystem_device}=="0x82d4"

    ATTRS{class}=="0x010601"

    ATTRS{irq}=="55"

    ATTRS{local_cpus}=="ff"

    ATTRS{local_cpulist}=="0-7"

    ATTRS{modalias}=="pci:v00008086d00003A22sv00001043sd000082D4bc01sc06i01"

    ATTRS{numa_node}=="-1"

    ATTRS{dma_mask_bits}=="64"

    ATTRS{consistent_dma_mask_bits}=="64"

    ATTRS{enable}=="1"

    ATTRS{broken_parity_status}=="0"

    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':

    KERNELS=="pci0000:00"

    SUBSYSTEMS==""

    DRIVERS==""
```

for SECOND hdd

```
udevadm info -a -p $(udevadm info -q path -n /dev/sdd1)

Udevadm info 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 '/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sdd/sdd1':

    KERNEL=="sdd1"

    SUBSYSTEM=="block"

    DRIVER==""

    ATTR{partition}=="1"

    ATTR{start}=="63"

    ATTR{size}=="976768002"

    ATTR{alignment_offset}=="0"

    ATTR{discard_alignment}=="4294935040"

    ATTR{stat}=="      41      444     1054       36    55336    18634 13468720  2115183        0    39946  2115146"

    ATTR{inflight}=="       0        0"

  looking at parent device '/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sdd':

    KERNELS=="sdd"

    SUBSYSTEMS=="block"

    DRIVERS==""

    ATTRS{range}=="16"

    ATTRS{ext_range}=="256"

    ATTRS{removable}=="0"

    ATTRS{ro}=="0"

    ATTRS{size}=="976773168"

    ATTRS{alignment_offset}=="0"

    ATTRS{discard_alignment}=="0"

    ATTRS{capability}=="52"

    ATTRS{stat}=="      88      653     3102       96    55337    18634 13468728  2115186        0    40010  2115210"

    ATTRS{inflight}=="       0        0"

  looking at parent device '/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0':

    KERNELS=="4:0:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS=="sd"

    ATTRS{device_blocked}=="0"

    ATTRS{type}=="0"

    ATTRS{scsi_level}=="6"

    ATTRS{vendor}=="ATA     "

    ATTRS{model}=="SAMSUNG HD502HJ "

    ATTRS{rev}=="1AJ1"

    ATTRS{state}=="running"

    ATTRS{timeout}=="30"

    ATTRS{iocounterbits}=="32"

    ATTRS{iorequest_cnt}=="0xd8fe"

    ATTRS{iodone_cnt}=="0xd8de"

    ATTRS{ioerr_cnt}=="0x14"

    ATTRS{modalias}=="scsi:t-0x00"

    ATTRS{evt_media_change}=="0"

    ATTRS{queue_depth}=="31"

    ATTRS{queue_ramp_up_period}=="120000"

    ATTRS{queue_type}=="simple"

  looking at parent device '/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0':

    KERNELS=="target4:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:1f.2/host4':

    KERNELS=="host4"

    SUBSYSTEMS=="scsi"

    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:1f.2':

    KERNELS=="0000:00:1f.2"

    SUBSYSTEMS=="pci"

    DRIVERS=="ahci"

    ATTRS{vendor}=="0x8086"

    ATTRS{device}=="0x3a22"

    ATTRS{subsystem_vendor}=="0x1043"

    ATTRS{subsystem_device}=="0x82d4"

    ATTRS{class}=="0x010601"

    ATTRS{irq}=="55"

    ATTRS{local_cpus}=="ff"

    ATTRS{local_cpulist}=="0-7"

    ATTRS{modalias}=="pci:v00008086d00003A22sv00001043sd000082D4bc01sc06i01"

    ATTRS{numa_node}=="-1"

    ATTRS{dma_mask_bits}=="64"

    ATTRS{consistent_dma_mask_bits}=="64"

    ATTRS{enable}=="1"

    ATTRS{broken_parity_status}=="0"

    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':

    KERNELS=="pci0000:00"

    SUBSYSTEMS==""

    DRIVERS==""
```

I am not able to find different atribute

maybe I am running wrong command

thanks for any tip / help

----------

## Telemin

When I run the command:

```

# udevadm --query=all --path=/sys/block/sda

P: /devices/pci0000:00/0000:00:09.0/host0/target0:0:0/0:0:0:0/block/sda

N: sda

S: block/8:0

S: disk/by-id/ata-WDC_WD5000BEVT-22A0RT0_WD-WXD0AA901758

S: disk/by-id/scsi-SATA_WDC_WD5000BEVT-_WD-WXD0AA901758

S: disk/by-path/pci-0000:00:09.0-scsi-0:0:0:0

S: disk/by-id/wwn-0x50014ee2ae5a1380

E: UDEV_LOG=3

E: DEVPATH=/devices/pci0000:00/0000:00:09.0/host0/target0:0:0/0:0:0:0/block/sda

E: SUBSYSTEM=block

E: DEVNAME=sda

E: ID_ATA=1

E: ID_TYPE=disk

E: ID_BUS=ata

E: ID_MODEL=WDC_WD5000BEVT-22A0RT0

E: ID_MODEL_ENC=WDC\x20WD5000BEVT-22A0RT0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20

E: ID_REVISION=01.01A10

E: ID_SERIAL=WDC_WD5000BEVT-22A0RT0_WD-WXD0AA901758

E: ID_SERIAL_SHORT=WD-WXD0AA901758

E: ID_ATA_WRITE_CACHE=1

E: ID_ATA_WRITE_CACHE_ENABLED=1

E: ID_ATA_FEATURE_SET_HPA=1

E: ID_ATA_FEATURE_SET_HPA_ENABLED=1

E: ID_ATA_FEATURE_SET_PM=1

E: ID_ATA_FEATURE_SET_PM_ENABLED=1

E: ID_ATA_FEATURE_SET_SECURITY=1

E: ID_ATA_FEATURE_SET_SECURITY_ENABLED=0

E: ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=154

E: ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=154

E: ID_ATA_FEATURE_SET_SECURITY_FROZEN=1

E: ID_ATA_FEATURE_SET_SMART=1

E: ID_ATA_FEATURE_SET_SMART_ENABLED=1

E: ID_ATA_FEATURE_SET_AAM=1

E: ID_ATA_FEATURE_SET_AAM_ENABLED=0

E: ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=128

E: ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=254

E: ID_ATA_FEATURE_SET_APM=1

E: ID_ATA_FEATURE_SET_APM_ENABLED=1

E: ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=96

E: ID_ATA_DOWNLOAD_MICROCODE=1

E: ID_ATA_SATA=1

E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1

E: ID_ATA_SATA_SIGNAL_RATE_GEN1=1

E: ID_ATA_ROTATION_RATE_RPM=5400

E: ID_WWN=0x50014ee2ae5a1380

E: ID_WWN_WITH_EXTENSION=0x50014ee2ae5a1380

E: ID_SCSI_COMPAT=SATA_WDC_WD5000BEVT-_WD-WXD0AA901758

E: ID_PATH=pci-0000:00:09.0-scsi-0:0:0:0

E: ID_PART_TABLE_TYPE=dos

E: MAJOR=8

E: MINOR=0

E: DEVTYPE=disk

E: DEVLINKS=/dev/block/8:0 /dev/disk/by-id/ata-WDC_WD5000BEVT-22A0RT0_WD-WXD0AA901758 /dev/disk/by-id/scsi-SATA_WDC_WD5000BEVT-_WD-WXD0AA901758 /dev/disk/by-path/pci-0000:00:09.0-scsi-0:0:0:0 /dev/disk/by-id/wwn-0x50014ee2ae5a1380

```

This includes an "E: ID_SERIAL=WDC_WD5000BEVT-22A0RT0_WD-WXD0AA901758" line which if it produces something sinilar for your drive could be what you are looking for.

-Telemin-

----------

## krinn

or label them and use /dev/disk/by-label

it will just help identify partition on them, but as you just have sdc1 and sdd1 it will solve your problem.

----------

## Sadako

Take a look in /dev/disk/by-id, it should contain symlinks to the real device nodes, but the symlinks contain the serial numbers of the actual device and are dynamically created at boot, so even if sdc and add should "swap" the symlinks will still point to the correct devices.

----------

## jancici

thanks for tips

how can I change LABEL of disk?

anyway I can used ID ...

----------

## krinn

for infos:

mkswap -L labelname for swap

e2label partition for ext? filessystem

for others, i don't know

----------

## jancici

thanks 

I will find others  :Wink: 

----------

