[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

/dev/disk/by-slot links



Hello all,

I have a Poweredge T610 running wheezy (uname -r says: 3.2.0-4-amd64)
with several sata disks plugged in to an LSI SAS2008 (lspci says:
"02:00.0 Serial Attached SCSI controller: LSI Logic / Symbios Logic
SAS2008 PCI-Express Fusion-MPT SAS-2 [Falcon] (rev 03)").

When i connect disks to this machine, I get messages like the
following (apologies in advance: I'm using the Gmail web interface
which will inevitably wrap this):

May  8 15:07:41 vm-host kernel: [3008083.628449] scsi 0:0:7:0:
Direct-Access     ATA      WDC WD2503ABYZ-0 1S03 PQ: 0 ANSI: 5
May  8 15:07:41 vm-host kernel: [3008083.628455] scsi 0:0:7:0: SATA:
handle(0x0011), sas_addr(0x4433221101000000), phy(1),
device_name(0x4ee050015b1d5910)
May  8 15:07:41 vm-host kernel: [3008083.628458] scsi 0:0:7:0: SATA:
enclosure_logical_id(0x5d4ae52090b77700), slot(6)
May  8 15:07:41 vm-host kernel: [3008083.628570] scsi 0:0:7:0:
atapi(n), ncq(y), asyn_notify(n), smart(y), fua(y), sw_preserve(y)
May  8 15:07:41 vm-host kernel: [3008083.628574] scsi 0:0:7:0:
qdepth(32), tagged(1), simple(0), ordered(0), scsi_level(6),
cmd_que(1)
May  8 15:07:41 vm-host kernel: [3008083.628736] sd 0:0:7:0: Attached
scsi generic sg8 type 0
May  8 15:07:41 vm-host kernel: [3008083.629351] sd 0:0:7:0: [sdh]
490350672 512-byte logical blocks: (251 GB/233 GiB)
May  8 15:07:41 vm-host kernel: [3008083.635459] sd 0:0:7:0: [sdh]
Write Protect is off
May  8 15:07:41 vm-host kernel: [3008083.637180] sd 0:0:7:0: [sdh]
Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
May  8 15:07:41 vm-host kernel: [3008083.648605]  sdh: unknown partition table
May  8 15:07:41 vm-host kernel: [3008083.657680] sd 0:0:7:0: [sdh]
Attached SCSI disk

The important part is the third line, which includes "slot(6)", ie.
the kernel knows what physical slot the disk was plugged in to. Should
this information be exported to userspace in any way? I can't find
anything in sysfs which mentions 'slot' or 'enclosure', but I don't
know exactly what I might be looking for.

My goal is to write a udev rule to create the relevant device links by
slot; since I needed it Right Now(TM), I whipped up a nasty hack that
just scrapes dmesg - I'll paste it in at the end.

The question is: is there a better way of doing this? If this
information is exported systematically to userspace, where might it
be, and if not, is there likely to be any particular reason? I'd
rather not have to use some solution that's proprietary or specific to
the device, since clearly the information does already exist, but I
wouldn't mind it if there's no other option (or I might just stick
with my stopgap I guess).

Thanks,
Nye

-- 
So this is what I have:
/etc/udev/rules.d/65-persistent-storage-local.rules:
KERNEL=="sd?", PROGRAM="/usr/local/bin/disk_slot_namer.sh %k",
SYMLINK+="disk/by-slot/slot%c"


/usr/local/bin/disk_slot_namer.sh:
#!/bin/sh
set -e
DEV_PATH=$(udevadm info --query=path -n $1 2>/dev/null)
DEV_PATH_ID=$(basename $(dirname $(dirname $DEV_PATH)))
MSG=$(dmesg | grep -o "scsi $DEV_PATH_ID: SATA: .*slot([0-9]*)" -A0 -B0)
echo $MSG | sed -n -e '/.*slot(\([^)]*\)).*/s//\1/p'


Reply to: