Centos – Where is udev getting the ID for iSCSI devices

centosudev

I'm using iscsi-initiator-utils successfully to use some iscsi devices on CentOS 5, and I have some symlinks created by udev in /dev/disk:

# ls -l /dev/disk/by-path/ip-* /dev/disk/by-id/scsi-*
lrwxrwxrwx 1 root root 9 Sep 29 15:41 /dev/disk/by-id/scsi-14f504e46494c45006779706e4d772d746d36582d6869556e -> ../../sdb
lrwxrwxrwx 1 root root 9 Sep 29 15:41 /dev/disk/by-path/ip-192.168.20.149:3260-iscsi-iqn.2006-01.com.openfiler:tsn.0a16ba8cb6c9-lun-0 -> ../../sdb

I know that the by-path one is the IQN of the device, and I presume that the by-id one is a SCSI device identifier.

I would like to know how to get these values myself from e.g. /dev/sdb. scsi_id -g /dev/sdb returns nothing.

(I know I could map symlinks back and scrap the IDs from the filenames, but that would be redundant: udev is getting those IDs from somewhere, and I'd like to know where).

Best Answer

Try udevinfo command

Also man 7 udev

Example:

[root@centos ~]# udevinfo -q all -n /dev/sda1 | grep 'ID_FS_UUID=' | awk -F'='  '{print $2}'
358c8298-3889-4982-8831-817a18ae4e67

[root@centos ~]# ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Dec  1 12:47 358c8298-3889-4982-8831-817a18ae4e67 -> ../../sda1
[root@centos ~]# readlink -e /dev/disk/by-uuid/358c8298-3889-4982-8831-817a18ae4e67 
/dev/sda1

Another one is blkid, which has integration with udev to show uuid

[root@centos ~]# blkid 
/dev/mapper/VolGroup00-LogVol01: TYPE="swap" 
/dev/mapper/VolGroup00-LogVol00: UUID="7951711f-0564-46a5-8e1c-427eff4b4115" TYPE="ext3" 
/dev/sda1: LABEL="/boot" UUID="358c8298-3889-4982-8831-817a18ae4e67" TYPE="ext3" 
/dev/hdc: LABEL="VBOXADDITIONS_4.1.2_73507" TYPE="iso9660" 
/dev/VolGroup00/LogVol00: UUID="7951711f-0564-46a5-8e1c-427eff4b4115" TYPE="ext3" 
/dev/VolGroup00/LogVol01: TYPE="swap" 
Related Question