2

Our application consists of testing hard disk drives and drives are inserted and removed after the testing. When a drive is inserted on our tester, udev created a file in the /dev/disk/by-path. Our application looks at these files to determine when a new drive is inserted or removed. The name contains the physical slot or bay the drive is connected so we know what drives is where. One HBA controller we are looking at creates this access file under this directory, but uses a LUN that is not related to the physical slot or bay the drive is in. With only the LUN we don't know where the drive is physically located in our tester. My question is who created the filename? Is it the HBA drives? I have the driver's source code so I am hoping I can modify it to create a filename with the physical slot or bay instead of the LUN.

Drives are being inserted and removed in real time all the time.

  • what brand/model of HBA? There may be well-known problems (or perhaps firmware configuration options) that google can find. Which driver does it use (and is it in the mainline kernel or manufacturer provided? if the latter, is there a mainline kernel driver which also works? manufacturer drivers often do things weirdly) – cas Aug 1 '17 at 3:22
2

The "files" under /dev/disk/by-* are symlinks created by udev, using information about the block device(s) provided by the kernel. The symlinks point to the actual device nodes for the drives. For example:

/dev/disk/by-path/pci-0000:00:11.0-ata-1 -> ../../sdn

and

/dev/disk/by-path/pci-0000:07:00.0-sas-phy0-lun-0 -> ../../sdb

The driver does not create them, and the kernel does not create them. they're entirely the responsibility of udev.

udev uses rules defined in /etc/udev/rules.d/ (for the local system admin's own rules and over-rides) and /lib/udev/rules.d/ (system defaults) to create them.

For example: /lib/udev/rules.d/60-persistent-storage.rules. On my debian system, the first few lines of that file are:

# do not edit this file, it will be overwritten on update

# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare@suse.de>

If you want to write your own custom rules for drives on that HBA, try running udevadm info /dev/disk/by-id/..... That may provide enough info to create a symlink that identifies the drive bay.

e.g. on one of my drives (a SATA drive connected to an IBM M1015, an LSI SAS2008, part of one of my ZFS pools):

# udevadm info /dev/disk/by-path/pci-0000:07:00.0-sas-phy0-lun-0
P: /devices/pci0000:00/0000:00:0b.0/0000:07:00.0/host0/port-0:1/end_device-0:1/target0:0:1/0:0:1:0/block/sdb
N: sdb
S: disk/by-id/ata-WDC_WD10EACS-00ZJB0_WD-WCASJ2114122
S: disk/by-id/wwn-0x50014ee2023dc46f
S: disk/by-path/pci-0000:07:00.0-sas-phy0-lun-0
E: DEVLINKS=/dev/disk/by-path/pci-0000:07:00.0-sas-phy0-lun-0 /dev/disk/by-id/ata-WDC_WD10EACS-00ZJB0_WD-WCASJ2114122 /dev/disk/by-id/wwn-0x50014ee2023dc46f
E: DEVNAME=/dev/sdb
E: DEVPATH=/devices/pci0000:00/0000:00:0b.0/0000:07:00.0/host0/port-0:1/end_device-0:1/target0:0:1/0:0:1:0/block/sdb
E: DEVTYPE=disk
E: ID_ATA=1
E: ID_ATA_DOWNLOAD_MICROCODE=1
E: ID_ATA_FEATURE_SET_AAM=1
E: ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=254
E: ID_ATA_FEATURE_SET_AAM_ENABLED=0
E: ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=128
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_PUIS=1
E: ID_ATA_FEATURE_SET_PUIS_ENABLED=0
E: ID_ATA_FEATURE_SET_SECURITY=1
E: ID_ATA_FEATURE_SET_SECURITY_ENABLED=0
E: ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=276
E: ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=276
E: ID_ATA_FEATURE_SET_SMART=1
E: ID_ATA_FEATURE_SET_SMART_ENABLED=1
E: ID_ATA_SATA=1
E: ID_ATA_SATA_SIGNAL_RATE_GEN1=1
E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1
E: ID_ATA_WRITE_CACHE=1
E: ID_ATA_WRITE_CACHE_ENABLED=1
E: ID_BUS=ata
E: ID_MODEL=WDC_WD10EACS-00ZJB0
E: ID_MODEL_ENC=WDC\x20WD10EACS-00ZJB0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_PART_TABLE_TYPE=gpt
E: ID_PART_TABLE_UUID=53ad1007-a736-ca41-a1fb-98ec491cc00a
E: ID_PATH=pci-0000:07:00.0-sas-phy0-lun-0
E: ID_PATH_TAG=pci-0000_07_00_0-sas-phy0-lun-0
E: ID_REVISION=01.01B01
E: ID_SERIAL=WDC_WD10EACS-00ZJB0_WD-WCASJ2114122
E: ID_SERIAL_SHORT=WD-WCASJ2114122
E: ID_TYPE=disk
E: ID_WWN=0x50014ee2023dc46f
E: ID_WWN_WITH_EXTENSION=0x50014ee2023dc46f
E: MAJOR=8
E: MINOR=16
E: SUBSYSTEM=block
E: TAGS=:systemd:
E: UDISKS_ATA_SMART_IS_AVAILABLE=1
E: UDISKS_IGNORE=1
E: UDISKS_PARTITION_TABLE=1
E: UDISKS_PARTITION_TABLE_COUNT=2
E: UDISKS_PARTITION_TABLE_SCHEME=gpt
E: UDISKS_PRESENTATION_HIDE=1
E: UDISKS_PRESENTATION_NOPOLICY=0
E: USEC_INITIALIZED=15128136

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.