linux设备识别

在/usr/share/ 下有文件pci.ids文件,表示了设备的类别,厂商信息


C 01  Mass storage controller
00  SCSI storage controller
01  IDE interface
02  Floppy disk controller
03  IPI bus controller
04  RAID bus controller
05  ATA controller


c开头说明是class说明,01  Mass storage controller表示Mass storage controller的类号是01,设备子类为下面列举的
00  SCSI storage controller
01  IDE interface
02  Floppy disk controller
03  IPI bus controller
04  RAID bus controller
05  ATA controller


SCSI storage controller的设备类合起来就是0x0100了


*如何识别硬盘(SCSI disk devices)的主次设备号?
SCSI disk devices的主设备号范围为:
8;65;66;67;68;69;70;71;128;129;130;131;132;133;134;135;
*如何识别是整个硬盘还是一个分区?
使用次设备号识别,如为整个硬盘则次设备号为16的整数倍(0;16;32;...;240);
如为分区则取值为1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;由此得一个盘的分区最多为15


在/sys/devices下有pci0000:00目录,说明挂在pci总线上的设备,里面0000:00:1c.0


2011.3.14在172.16.0.140上的/sys/devices/pci0000:00的内容
0000:00:00.0  class 0x060000(Host bridge)
0000:00:1a.0  class 0x0c0320(USB Controller EHCI)
0000:00:1c.6  class 0x060400(PCI bridge)
0000:04:00.0 class 0x030000(VGA compatible controller)
0000:00:1e.0  class 0x060401 (PCI bridge Subtractive decode)
0000:00:1f.3  class 0x0c0500(SMBus)
0000:00:01.0  class 0x060400(PCI bridge)
0000:01:00.0 class 0x020000(Network controller)
0000:01:00.1 class 0x020000(Network controller)
0000:00:1c.0  class 0x060400(PCI bridge)
0000:02:00.0 class 0x010000(SCSI storage controller)
0000:00:1c.7  class 0x060400(PCI bridge)
0000:00:1f.0  class 0x060100(ISA bridge)
0000:00:19.0  class 0x020000(Network controller)
0000:00:1c.4  class 0x060400(PCI bridge)
0000:03:00.0 class 0x020000(Network controller)
0000:00:1d.0 class 0x0c0320(USB Controller EHCI)
0000:00:1f.2 class 0x010601(SATA controller AHCI 1.0)




在/sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/host6/scsi_host/host6下
board_assembly  L3-00159-02A
board_name   SAS3081E
board_tracer  P298362108
这3个在hba卡上有标识




/sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/host6/port-6:1/expander-6:1/port-6:1:1/end_device-6:1:1/target6:0:5/6:0:5:0/block/sdf
/sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/host6/port-6:1/expander-6:1/port-6:1:1/end_device-6:1:1/sas_device/end_device-6:1:1/sas_address
上两条一个最后为地址,一个最后为block,要有盘才有/block/sd*




如何识别是sas盘得热插拔?
1、首先确定SCSI storage controller或Serial Attached SCSI controller的所在在位置
    可以通过lspci的管道输出得到0000:02:00.0上的设备是SCSI storage controller(也有可能为Serial Attached SCSI controller),确认该总线下为阵列磁盘说在位置磁盘,在该总线下的事件既是整列的事件,忽略其他总线的事件
2、将在该总线上的磁盘归为一组
expander-6:1和expander-6:0有区别吗?


3、热插拔事件的过滤
   首先根据(1)得到的总线号过滤掉其他总线上的信息,然后在热插拔事件中寻找主设备号为SCSI disk devices的那段信息,对该段信息进行解析得到进一步的数据















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值