如何从 dmesg 中的“ata*”获取“/dev/sd*”路径?

如何从 dmesg 中的“ata*”获取“/dev/sd*”路径?

我有这个输出dmesg

[149939.146576] ata18.00: exception Emask 0x1 SAct 0x0 SErr 0x0 action 0x0
[149939.146592] ata18.00: irq_stat 0x40000001
[149939.146600] ata18.00: cmd a0/00:00:00:04:00/00:00:00:00:00/a0 tag 2 pio 16388 in
                         Log Sense 4d 00 40 ff 00 00 00 00 04 00res 40/00:00:01:00:00/00:00:00:00:00/00 Emask 0x1 (device error)
[149939.146615] ata18.00: status: { DRDY }
[156569.787604] ata18.00: exception Emask 0x1 SAct 0x0 SErr 0x0 action 0x0
[156569.787613] ata18.00: irq_stat 0x40000001
[156569.787617] ata18.00: cmd a0/00:00:00:04:00/00:00:00:00:00/a0 tag 4 pio 16388 in
                         Log Sense 4d 00 40 ff 00 00 00 00 04 00res 40/00:00:00:00:00/00:00:00:00:00/08 Emask 0x1 (device error)
[156569.787624] ata18.00: status: { DRDY }

我想知道这个输出对应的块设备是什么

我尝试过查看/sys/block/*/device/scsi_device/sys/block/*/device/scsi_disc/sys/block/*/device/scsi_generic这些似乎是死路一条

如果我这样做,ls -dal /sys/class/ata_port/ata18/device/host* 我会得到这个:

drwxr-xr-x 5 root root 0 Jun 30 03:00 /sys/class/ata_port/ata18/device/host17

这似乎表明这个 ata 端口适用于主机 17

但如果我这样做,lsblk -S 我会得到这个:

NAME HCTL       TYPE VENDOR   MODEL             REV SERIAL         TRAN
sda  4:0:0:0    disk ATA      ST3250318AS      CC38 ********       sata
sdb  5:0:0:0    disk ATA      Hitachi HDS5C303 A580 ********       sata
sdc  6:0:0:0    disk ATA      ST8000VN004-2M21 SC60 ********       sata
sdd  7:0:0:0    disk ATA      ST8000VN004-2M21 SC60 ********       sata
sde  8:0:0:0    disk ATA      ST8000VN004-2M21 SC60 ********       sata
sdf  9:0:0:0    disk ATA      ST8000VN004-2M21 SC60 ********       sata
sdg  10:0:0:0   disk ATA      ST8000VN004-2M21 SC60 ********       sata
sdh  11:0:0:0   disk ATA      ST8000VN004-2M21 SC60 ********       sata

这些都不是主机 17....我是不是漏掉了什么?有人能解释一下吗?谢谢

ls -l /sys/block/sd*编辑:这是按要求的输出

$ ls -l /sys/block/sd*
lrwxrwxrwx 1 root root 0 Jun 30 03:00 /sys/block/sda -> ../devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 Jun 30 03:00 /sys/block/sdb -> ../devices/pci0000:00/0000:00:1f.2/ata6/host5/target5:0:0/5:0:0:0/block/sdb
lrwxrwxrwx 1 root root 0 Jun 30 03:00 /sys/block/sdc -> ../devices/pci0000:00/0000:00:1f.2/ata7/host6/target6:0:0/6:0:0:0/block/sdc
lrwxrwxrwx 1 root root 0 Jun 30 03:00 /sys/block/sdd -> ../devices/pci0000:00/0000:00:1f.2/ata8/host7/target7:0:0/7:0:0:0/block/sdd
lrwxrwxrwx 1 root root 0 Jun 30 03:00 /sys/block/sde -> ../devices/pci0000:00/0000:00:1f.2/ata9/host8/target8:0:0/8:0:0:0/block/sde
lrwxrwxrwx 1 root root 0 Jun 30 03:00 /sys/block/sdf -> ../devices/pci0000:00/0000:00:1f.2/ata10/host9/target9:0:0/9:0:0:0/block/sdf
lrwxrwxrwx 1 root root 0 Jun 30 03:00 /sys/block/sdg -> ../devices/pci0000:00/0000:00:1c.2/0000:04:00.0/ata11/host10/target10:0:0/10:0:0:0/block/sdg
lrwxrwxrwx 1 root root 0 Jun 30 03:00 /sys/block/sdh -> ../devices/pci0000:00/0000:00:1c.2/0000:04:00.0/ata12/host11/target11:0:0/11:0:0:0/block/sdh

编辑:我正在考虑的一件事是离线阵列,然后逐个拉出驱动器并检查 dmesg,但要等待漫长的磁带备份过程先完成,这可能需要几天时间......

编辑:根据要求,我已包含 dmesg 过滤行:

[   66.398867] ata18.00: failed to IDENTIFY (device reports invalid type, err_mask=0x0)
[   66.804074] ata18.00: ATAPI: MARVELL VIRTUALL, 1.09, max UDMA/66
[   66.816444] ata18.00: configured for UDMA/66
[149939.146576] ata18.00: exception Emask 0x1 SAct 0x0 SErr 0x0 action 0x0
[149939.146592] ata18.00: irq_stat 0x40000001
[149939.146600] ata18.00: cmd a0/00:00:00:04:00/00:00:00:00:00/a0 tag 2 pio 16388 in
[149939.146615] ata18.00: status: { DRDY }
[156569.787604] ata18.00: exception Emask 0x1 SAct 0x0 SErr 0x0 action 0x0
[156569.787613] ata18.00: irq_stat 0x40000001
[156569.787617] ata18.00: cmd a0/00:00:00:04:00/00:00:00:00:00/a0 tag 4 pio 16388 in
[156569.787624] ata18.00: status: { DRDY }
[218674.843962] ata18.00: exception Emask 0x1 SAct 0x0 SErr 0x0 action 0x0
[218674.843974] ata18.00: irq_stat 0x40000001
[218674.843979] ata18.00: cmd a0/01:00:00:00:01/00:00:00:00:00/a0 tag 7 dma 16640 in
[218674.843989] ata18.00: status: { DRDY }
[218674.891963] ata18.00: exception Emask 0x1 SAct 0x0 SErr 0x0 action 0x0
[218674.891979] ata18.00: irq_stat 0x40000001
[218674.891988] ata18.00: cmd a0/01:00:00:00:01/00:00:00:00:00/a0 tag 8 dma 16640 in
[218674.892005] ata18.00: status: { DRDY }

“ATAPI: MARVELL VIRTUALL”看起来很可疑,不确定那是什么

答案1

尝试这个:

find /sys/class/ata_port/ata18/device/ -name block -exec ls {} +

或这个:

ls /sys/class/ata_port/ata18/device/host*/target*/*/block

我想您明白了。 ata18 上很可能没有块设备,在这种情况下sdX系统上就不会有块设备。 例如,那是 DVD 驱动器吗?

下面的内容也许能让你更好地了解这是什么:

find /sys/class/ata_port/ata18/device/ -name model -exec cat {} +

答案2

您可以使用 smartctl 快速检查所有磁盘。使用smartctl -H /dev/sdX或 获取更高级信息的示例smartctl -a /dev/sdX

我想澄清一下您是否曾尝试过这样做ls -l /sys/block/sd*

相关内容