Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
In which SATA port my hard drive is connected (eudev)?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Zucca
l33t
l33t


Joined: 14 Jun 2007
Posts: 959
Location: KUUSANKOSKI, Finland

PostPosted: Sat Nov 25, 2017 6:08 pm    Post subject: In which SATA port my hard drive is connected (eudev)? Reply with quote

I'd need a simple way to determine which sata port a hard drive is using. This is because I have 6 2.5" hard drive hotswap slots. I tend to swap out the drives to new ones when the prices drop. When I remove a drive (or when one fails) I need to be able to deternime the SATA port assosciated with the drive so that I don't eject wrong drive. I had this done by systemd's udev earlier (see here for the udev rule), but eudev doesn't export PATH_ID from which I was able to determine the port. My current setup is quite simple in the way that all the SATA connectors are handled by the same SATA chip. So I don't need to create several rules for different busses.

The sysfs device path isn't realiable, I've found. For example /devices/pci0000:00/0000:00:11.0/ata2/ does not always point to second SATA port.

Any tips?
_________________
..: Zucca :..
This space is not for rent.
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5325

PostPosted: Sun Nov 26, 2017 5:39 am    Post subject: Reply with quote

/dev/disk/by-path or /dev/disk/by-id should work...
Back to top
View user's profile Send private message
Zucca
l33t
l33t


Joined: 14 Jun 2007
Posts: 959
Location: KUUSANKOSKI, Finland

PostPosted: Sun Nov 26, 2017 1:15 pm    Post subject: Reply with quote

The /dev/disk/by-id has links to disks (and partitions) based on the information gathered from the disk itself, so there's nothing I can utilize.
/dev/disk/by-path on the other hand could be the answer, but for some reason there are only usb entries from my USB card reader and USB DVD drive:
shellcmd: ls -lF /dev/disk/by-path/ :
total 0
lrwxrwxrwx 1 root root 9 Nov 25 19:40 pci-0000:00:13.2-usb-0:2.3:1.0-scsi-0:0:0:0 -> ../../sr0
lrwxrwxrwx 1 root root 9 Nov 26 15:11 pci-0000:00:16.2-usb-0:2:1.0-scsi-0:0:0:0 -> ../../sdg
lrwxrwxrwx 1 root root 9 Nov 25 19:40 pci-0000:00:16.2-usb-0:2:1.0-scsi-0:0:0:1 -> ../../sdh
lrwxrwxrwx 1 root root 9 Nov 25 19:40 pci-0000:00:16.2-usb-0:2:1.0-scsi-0:0:0:2 -> ../../sdi
lrwxrwxrwx 1 root root 9 Nov 25 19:40 pci-0000:00:16.2-usb-0:2:1.0-scsi-0:0:0:3 -> ../../sdj

So none of my actual hard drives have symlinks there.

Earlier udev rule worked flawlessly. It (somewhat) simply created links based on which port the hard drive was attached.
_________________
..: Zucca :..
This space is not for rent.
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 5982

PostPosted: Mon Nov 27, 2017 10:41 am    Post subject: Reply with quote

You don't have a problem with ID_PATH and eudev, you have a problem elsewhere:
- first because you have no symlink to your other drives, while you should
- second, because ID_PATH is handle.
Quote:
udevadm info -qall -n sda
P: /devices/pci0000:00/0000:00:1c.4/0000:05:00.0/host0/target0:0:0/0:0:0:0/block/sda
N: sda
S: disk/by-id/scsi-22dd815bb00d00000
S: disk/by-path/pci-0000:05:00.0-scsi-0:0:0:0
E: DEVLINKS=/dev/disk/by-id/scsi-22dd815bb00d00000 /dev/disk/by-path/pci-0000:05:00.0-scsi-0:0:0:0
E: DEVNAME=/dev/sda
E: DEVPATH=/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/host0/target0:0:0/0:0:0:0/block/sda
E: DEVTYPE=disk
E: ID_BUS=scsi
E: ID_MODEL=TINYSEAGATE
E: ID_MODEL_ENC=TINYSEAGATE\x20\x20\x20\x20\x20
E: ID_PART_TABLE_TYPE=dos
E: ID_PART_TABLE_UUID=3c3655a5
E: ID_PATH=pci-0000:05:00.0-scsi-0:0:0:0
E: ID_PATH_TAG=pci-0000_05_00_0-scsi-0_0_0_0
E: ID_REVISION=V1.0
E: ID_SCSI=1
E: ID_SCSI_SERIAL=BB15D82D
E: ID_SERIAL=22dd815bb00d00000
E: ID_SERIAL_SHORT=2dd815bb00d00000
E: ID_TYPE=disk
E: ID_VENDOR=Adaptec
E: ID_VENDOR_ENC=Adaptec\x20
E: MAJOR=8
E: MINOR=0
E: SUBSYSTEM=block
E: USEC_INITIALIZED=5616284

equery b udevadm
sys-fs/eudev-3.2.2-r1 (/bin/udevadm)
Back to top
View user's profile Send private message
Zucca
l33t
l33t


Joined: 14 Jun 2007
Posts: 959
Location: KUUSANKOSKI, Finland

PostPosted: Mon Nov 27, 2017 12:07 pm    Post subject: Reply with quote

Thanks for the reply.
I seem to have my SATA in ATA mode for some reason...
shellcmd: udevadm info -qall -n sda :
calling: info
P: /devices/pci0000:00/0000:00:11.0/ata1/host0/target0:0:0/0:0:0:0/block/sda
N: sda
S: disk/by-id/ata-SAMSUNG_SSD_830_Series_S0Z4NEAC856660
S: disk/by-id/wwn-0x5002538043584d30
E: DEVLINKS=/dev/disk/by-id/ata-SAMSUNG_SSD_830_Series_S0Z4NEAC856660 /dev/disk/by-id/wwn-0x5002538043584d30
E: DEVNAME=/dev/sda
E: DEVPATH=/devices/pci0000:00/0000:00:11.0/ata1/host0/target0:0:0/0:0:0:0/block/sda
E: DEVTYPE=disk
E: ID_ATA=1
E: ID_ATA_DOWNLOAD_MICROCODE=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_ENHANCED_ERASE_UNIT_MIN=32
E: ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=6
E: ID_ATA_FEATURE_SET_SMART=1
E: ID_ATA_FEATURE_SET_SMART_ENABLED=1
E: ID_ATA_ROTATION_RATE_RPM=0
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=SAMSUNG_SSD_830_Series
E: ID_MODEL_ENC=SAMSUNG\x20SSD\x20830\x20Series\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_PART_TABLE_TYPE=dos
E: ID_PART_TABLE_UUID=e534661e
E: ID_REVISION=CXM03B1Q
E: ID_SERIAL=SAMSUNG_SSD_830_Series_S0Z4NEAC856660
E: ID_SERIAL_SHORT=S0Z4NEAC856660
E: ID_TYPE=disk
E: ID_WWN=0x5002538043584d30
E: ID_WWN_WITH_EXTENSION=0x5002538043584d30
E: MAJOR=8
E: MINOR=0
E: SUBSYSTEM=block
E: USEC_INITIALIZED=3341940
shellcmd: equery b udevadm :
 * Searching for udevadm ...
sys-fs/eudev-3.2.4 (/bin/udevadm)
sys-fs/eudev-3.2.4 (/sbin/udevadm -> /bin/udevadm)

I must have flipped some setting accidentaly. Now to wonder how to get it back...
_________________
..: Zucca :..
This space is not for rent.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum