trying to get my head around udev rules

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

trying to get my head around udev rules

Postby maxeaves » Thu Mar 01, 2012 11:59 am

I send this posting with an apology first; as I am probably being a complete numpty over this issue, but I cannot get my head around the nightmare that is udev.

I have a server, with 4 internal IcyBox drive caddies which is running Centos 6.2, and has several virtual machines running under Virtualbox. The plan is that I will plug in a drive into a caddy - and depending on the physical position of the caddy, the system will map the drive to /dev/sd[c-f]. The problem is that when a drive is plug into a caddy, it allocates a random drive letter. I need a static drive letter allocated depending on the internal drive caddy location.

e.g. top caddy - should be /dev/sdc
middle caddy - should be /dev/sdd
bottom caddy - should be /dev/sde

I cannot lock down udev rules by UUID [because I have 30,000 drives to read the data off] or by drive name either, so I have been using udevadm info to try and find some constants in terms of drive positioning data.

The reason why I need the persistence is that I plan to map /mnt/drive1 to /dev/sdc1 [as an example], and then perform a 'fake' smb share across to the Virtualbox VM, so that the Windows software can directly read the information on the drive.

The GOOD NEWS is that I've found the constant from udevadm, but I'm not sure show to map it in udev. I'm not expecting an answer, just some pointers please.

I'm in an environment where we are using semi-skilled operators here, so some pointers should be useful.

Thanks


Max
maxeaves
 
Posts: 63
Joined: Thu Oct 18, 2007 8:54 am

Postby maxeaves » Thu Mar 01, 2012 12:02 pm

What I did was I took one drive, and put it into each of the 4 slots that I have....and here is the udevadm data....

P: /devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:8/end_device-4:8/target4:0:8/4:0:8:0/block/sdc/sdc1
N: sdc1
W: 76
S: block/8:33
S: disk/by-id/ata-Hitachi_HDS722020ALA330_JK1175YAJ1NZNX-part1
S: disk/by-id/scsi-SATA_Hitachi_HDS7220_JK1175YAJ1NZNX-part1
S: disk/by-path/pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0-part1
S: disk/by-uuid/3EEC82AFEC8260CF
S: disk/by-label/AELT10\x20C14\x20C18\x20DISK\x2006
S: disk/by-id/wwn-0x5000cca221dcf22b-part1
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:8/end_device-4:8/target4:0:8/4:0:8:0/block/sdc/sdc1
E: MAJOR=8
E: MINOR=33
E: DEVNAME=/dev/sdc1
E: DEVTYPE=partition
E: SUBSYSTEM=block
E: ID_ATA=1
E: ID_TYPE=disk
E: ID_BUS=ata
E: ID_MODEL=Hitachi_HDS722020ALA330
E: ID_MODEL_ENC=Hitachi\x20HDS722020ALA330\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_REVISION=JKAOA2A8
E: ID_SERIAL=Hitachi_HDS722020ALA330_JK1175YAJ1NZNX
E: ID_SERIAL_SHORT=JK1175YAJ1NZNX
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=520
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=1
E: ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=128
E: ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=128
E: ID_ATA_FEATURE_SET_PUIS=1
E: ID_ATA_FEATURE_SET_PUIS_ENABLED=0
E: ID_ATA_FEATURE_SET_APM=1
E: ID_ATA_FEATURE_SET_APM_ENABLED=0
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=7200
E: ID_WWN=0x5000cca221dcf22b
E: ID_WWN_WITH_EXTENSION=0x5000cca221dcf22b
E: ID_SCSI_COMPAT=SATA_Hitachi_HDS7220_JK1175YAJ1NZNX
E: ID_PATH=pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0
E: ID_PART_TABLE_TYPE=dos
E: ID_FS_LABEL=AELT10_C14_C18_DISK_06
E: ID_FS_LABEL_ENC=AELT10\x20C14\x20C18\x20DISK\x2006
E: ID_FS_UUID=3EEC82AFEC8260CF
E: ID_FS_UUID_ENC=3EEC82AFEC8260CF
E: ID_FS_TYPE=ntfs
E: ID_FS_USAGE=filesystem
E: UDISKS_PRESENTATION_NOPOLICY=0
E: UDISKS_PARTITION=1
E: UDISKS_PARTITION_SCHEME=mbr
E: UDISKS_PARTITION_NUMBER=1
E: UDISKS_PARTITION_TYPE=0x07
E: UDISKS_PARTITION_SIZE=2000396289024
E: UDISKS_PARTITION_SLAVE=/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:8/end_device-4:8/target4:0:8/4:0:8:0/block/sdc
E: UDISKS_PARTITION_OFFSET=32256
E: UDISKS_PARTITION_ALIGNMENT_OFFSET=0
E: DEVLINKS=/dev/block/8:33 /dev/disk/by-id/ata-Hitachi_HDS722020ALA330_JK1175YAJ1NZNX-part1 /dev/disk/by-id/scsi-SATA_Hitachi_HDS7220_JK1175YAJ1NZNX-part1 /dev/disk/by-path/pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0-part1 /dev/disk/by-uuid/3EEC82AFEC8260CF /dev/disk/by-label/AELT10\x20C14\x20C18\x20DISK\x2006 /dev/disk/by-id/wwn-0x5000cca221dcf22b-part1

P: /devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:9/end_device-4:9/target4:0:9/4:0:9:0/block/sdc/sdc1
N: sdc1
W: 78
S: block/8:33
S: disk/by-id/ata-Hitachi_HDS722020ALA330_JK1175YAJ1NZNX-part1
S: disk/by-id/scsi-SATA_Hitachi_HDS7220_JK1175YAJ1NZNX-part1
S: disk/by-path/pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0-part1
S: disk/by-uuid/3EEC82AFEC8260CF
S: disk/by-label/AELT10\x20C14\x20C18\x20DISK\x2006
S: disk/by-id/wwn-0x5000cca221dcf22b-part1
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:9/end_device-4:9/target4:0:9/4:0:9:0/block/sdc/sdc1
E: MAJOR=8
E: MINOR=33
E: DEVNAME=/dev/sdc1
E: DEVTYPE=partition
E: SUBSYSTEM=block
E: ID_ATA=1
E: ID_TYPE=disk
E: ID_BUS=ata
E: ID_MODEL=Hitachi_HDS722020ALA330
E: ID_MODEL_ENC=Hitachi\x20HDS722020ALA330\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_REVISION=JKAOA2A8
E: ID_SERIAL=Hitachi_HDS722020ALA330_JK1175YAJ1NZNX
E: ID_SERIAL_SHORT=JK1175YAJ1NZNX
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=520
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=1
E: ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=128
E: ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=128
E: ID_ATA_FEATURE_SET_PUIS=1
E: ID_ATA_FEATURE_SET_PUIS_ENABLED=0
E: ID_ATA_FEATURE_SET_APM=1
E: ID_ATA_FEATURE_SET_APM_ENABLED=0
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=7200
E: ID_WWN=0x5000cca221dcf22b
E: ID_WWN_WITH_EXTENSION=0x5000cca221dcf22b
E: ID_SCSI_COMPAT=SATA_Hitachi_HDS7220_JK1175YAJ1NZNX
E: ID_PATH=pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0
E: ID_PART_TABLE_TYPE=dos
E: ID_FS_LABEL=AELT10_C14_C18_DISK_06
E: ID_FS_LABEL_ENC=AELT10\x20C14\x20C18\x20DISK\x2006
E: ID_FS_UUID=3EEC82AFEC8260CF
E: ID_FS_UUID_ENC=3EEC82AFEC8260CF
E: ID_FS_TYPE=ntfs
E: ID_FS_USAGE=filesystem
E: UDISKS_PRESENTATION_NOPOLICY=0
E: UDISKS_PARTITION=1
E: UDISKS_PARTITION_SCHEME=mbr
E: UDISKS_PARTITION_NUMBER=1
E: UDISKS_PARTITION_TYPE=0x07
E: UDISKS_PARTITION_SIZE=2000396289024
E: UDISKS_PARTITION_SLAVE=/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:9/end_device-4:9/target4:0:9/4:0:9:0/block/sdc
E: UDISKS_PARTITION_OFFSET=32256
E: UDISKS_PARTITION_ALIGNMENT_OFFSET=0
E: DEVLINKS=/dev/block/8:33 /dev/disk/by-id/ata-Hitachi_HDS722020ALA330_JK1175YAJ1NZNX-part1 /dev/disk/by-id/scsi-SATA_Hitachi_HDS7220_JK1175YAJ1NZNX-part1 /dev/disk/by-path/pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0-part1 /dev/disk/by-uuid/3EEC82AFEC8260CF /dev/disk/by-label/AELT10\x20C14\x20C18\x20DISK\x2006 /dev/disk/by-id/wwn-0x5000cca221dcf22b-part1

P: /devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:10/end_device-4:10/target4:0:10/4:0:10:0/block/sdc/sdc1
N: sdc1
W: 80
S: block/8:33
S: disk/by-id/ata-Hitachi_HDS722020ALA330_JK1175YAJ1NZNX-part1
S: disk/by-id/scsi-SATA_Hitachi_HDS7220_JK1175YAJ1NZNX-part1
S: disk/by-path/pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0-part1
S: disk/by-uuid/3EEC82AFEC8260CF
S: disk/by-label/AELT10\x20C14\x20C18\x20DISK\x2006
S: disk/by-id/wwn-0x5000cca221dcf22b-part1
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:10/end_device-4:10/target4:0:10/4:0:10:0/block/sdc/sdc1
E: MAJOR=8
E: MINOR=33
E: DEVNAME=/dev/sdc1
E: DEVTYPE=partition
E: SUBSYSTEM=block
E: ID_ATA=1
E: ID_TYPE=disk
E: ID_BUS=ata
E: ID_MODEL=Hitachi_HDS722020ALA330
E: ID_MODEL_ENC=Hitachi\x20HDS722020ALA330\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_REVISION=JKAOA2A8
E: ID_SERIAL=Hitachi_HDS722020ALA330_JK1175YAJ1NZNX
E: ID_SERIAL_SHORT=JK1175YAJ1NZNX
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=520
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=1
E: ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=128
E: ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=128
E: ID_ATA_FEATURE_SET_PUIS=1
E: ID_ATA_FEATURE_SET_PUIS_ENABLED=0
E: ID_ATA_FEATURE_SET_APM=1
E: ID_ATA_FEATURE_SET_APM_ENABLED=0
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=7200
E: ID_WWN=0x5000cca221dcf22b
E: ID_WWN_WITH_EXTENSION=0x5000cca221dcf22b
E: ID_SCSI_COMPAT=SATA_Hitachi_HDS7220_JK1175YAJ1NZNX
E: ID_PATH=pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0
E: ID_PART_TABLE_TYPE=dos
E: ID_FS_LABEL=AELT10_C14_C18_DISK_06
E: ID_FS_LABEL_ENC=AELT10\x20C14\x20C18\x20DISK\x2006
E: ID_FS_UUID=3EEC82AFEC8260CF
E: ID_FS_UUID_ENC=3EEC82AFEC8260CF
E: ID_FS_TYPE=ntfs
E: ID_FS_USAGE=filesystem
E: UDISKS_PRESENTATION_NOPOLICY=0
E: UDISKS_PARTITION=1
E: UDISKS_PARTITION_SCHEME=mbr
E: UDISKS_PARTITION_NUMBER=1
E: UDISKS_PARTITION_TYPE=0x07
E: UDISKS_PARTITION_SIZE=2000396289024
E: UDISKS_PARTITION_SLAVE=/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:10/end_device-4:10/target4:0:10/4:0:10:0/block/sdc
E: UDISKS_PARTITION_OFFSET=32256
E: UDISKS_PARTITION_ALIGNMENT_OFFSET=0
E: DEVLINKS=/dev/block/8:33 /dev/disk/by-id/ata-Hitachi_HDS722020ALA330_JK1175YAJ1NZNX-part1 /dev/disk/by-id/scsi-SATA_Hitachi_HDS7220_JK1175YAJ1NZNX-part1 /dev/disk/by-path/pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0-part1 /dev/disk/by-uuid/3EEC82AFEC8260CF /dev/disk/by-label/AELT10\x20C14\x20C18\x20DISK\x2006 /dev/disk/by-id/wwn-0x5000cca221dcf22b-part1

P: /devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:11/end_device-4:11/target4:0:11/4:0:11:0/block/sdc/sdc1
N: sdc1
W: 82
S: block/8:33
S: disk/by-id/ata-Hitachi_HDS722020ALA330_JK1175YAJ1NZNX-part1
S: disk/by-id/scsi-SATA_Hitachi_HDS7220_JK1175YAJ1NZNX-part1
S: disk/by-path/pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0-part1
S: disk/by-uuid/3EEC82AFEC8260CF
S: disk/by-label/AELT10\x20C14\x20C18\x20DISK\x2006
S: disk/by-id/wwn-0x5000cca221dcf22b-part1
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:11/end_device-4:11/target4:0:11/4:0:11:0/block/sdc/sdc1
E: MAJOR=8
E: MINOR=33
E: DEVNAME=/dev/sdc1
E: DEVTYPE=partition
E: SUBSYSTEM=block
E: ID_ATA=1
E: ID_TYPE=disk
E: ID_BUS=ata
E: ID_MODEL=Hitachi_HDS722020ALA330
E: ID_MODEL_ENC=Hitachi\x20HDS722020ALA330\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_REVISION=JKAOA2A8
E: ID_SERIAL=Hitachi_HDS722020ALA330_JK1175YAJ1NZNX
E: ID_SERIAL_SHORT=JK1175YAJ1NZNX
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=520
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=1
E: ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=128
E: ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=128
E: ID_ATA_FEATURE_SET_PUIS=1
E: ID_ATA_FEATURE_SET_PUIS_ENABLED=0
E: ID_ATA_FEATURE_SET_APM=1
E: ID_ATA_FEATURE_SET_APM_ENABLED=0
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=7200
E: ID_WWN=0x5000cca221dcf22b
E: ID_WWN_WITH_EXTENSION=0x5000cca221dcf22b
E: ID_SCSI_COMPAT=SATA_Hitachi_HDS7220_JK1175YAJ1NZNX
E: ID_PATH=pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0
E: ID_PART_TABLE_TYPE=dos
E: ID_FS_LABEL=AELT10_C14_C18_DISK_06
E: ID_FS_LABEL_ENC=AELT10\x20C14\x20C18\x20DISK\x2006
E: ID_FS_UUID=3EEC82AFEC8260CF
E: ID_FS_UUID_ENC=3EEC82AFEC8260CF
E: ID_FS_TYPE=ntfs
E: ID_FS_USAGE=filesystem
E: UDISKS_PRESENTATION_NOPOLICY=0
E: UDISKS_PARTITION=1
E: UDISKS_PARTITION_SCHEME=mbr
E: UDISKS_PARTITION_NUMBER=1
E: UDISKS_PARTITION_TYPE=0x07
E: UDISKS_PARTITION_SIZE=2000396289024
E: UDISKS_PARTITION_SLAVE=/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host4/port-4:11/end_device-4:11/target4:0:11/4:0:11:0/block/sdc
E: UDISKS_PARTITION_OFFSET=32256
E: UDISKS_PARTITION_ALIGNMENT_OFFSET=0
E: DEVLINKS=/dev/block/8:33 /dev/disk/by-id/ata-Hitachi_HDS722020ALA330_JK1175YAJ1NZNX-part1 /dev/disk/by-id/scsi-SATA_Hitachi_HDS7220_JK1175YAJ1NZNX-part1 /dev/disk/by-path/pci-0000:05:00.0-sas-0x816f9e2f9fdaf9c7-lun-0-part1 /dev/disk/by-uuid/3EEC82AFEC8260CF /dev/disk/by-label/AELT10\x20C14\x20C18\x20DISK\x2006 /dev/disk/by-id/wwn-0x5000cca221dcf22b-part1
maxeaves
 
Posts: 63
Joined: Thu Oct 18, 2007 8:54 am

Postby maxeaves » Thu Mar 01, 2012 12:03 pm

So - the port location and drive scsi number - seem to be the changing factor here, but not sure how to proceed from here....
maxeaves
 
Posts: 63
Joined: Thu Oct 18, 2007 8:54 am

Postby nelz » Thu Mar 01, 2012 2:15 pm

Run udevadm info with the --attribute-walk option. This outputs in the same format as used by udev rules. Once you have identified the unique property of a caddy, you can paste that straight into a udev rule.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8504
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron