linux识别硬盘位置,linux 通过udevadm info检测硬盘位置

linux 通过udevadm info检测硬盘位置

我们知道,在linux 中,所有的块设备都以/dev/sd[a-z]的形式表现,如:/dev/sda,/dev/sdb,/dev/sdc等等.但是,在多硬盘中,我们只看设备设点/dev/sda,/dev/sdb是无法分清哪个设备代表是哪个实际硬盘.怎么办呢?我们可以通过检测硬件设备的总线来辨别设备节点代表的是哪个位置.

命令:udevadm info -a -p /sys/block/sda ,这条命条可以打印出设备总线的所有位置的父子关系.如(关键字高亮):

dm814x:/work$ udevadm info -a -p /sys/block/sda

Udevadm info starts with the device specified by the devpath and then

walks up the chain of parent devices. It prints for every device

found, all possible attributes in the udev rules key format.

A rule to match, can be composed by the attributes of the device

and the attributes from one single parent device.

looking at device '/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/usb1/1-1/1-1:1.0/host1/target1:0:0/1:0:0:0/block/sda':  //总线路径和子路径.子路径好像不准确会变.

KERNEL=="sda"

SUBSYSTEM=="block"

DRIVER==""

ATTR{range}=="16"

ATTR{ext_range}=="256"

ATTR{removable}=="0"//设备热插拔,0为不能,1为能.    ATTR{ro}=="0"

ATTR{size}=="976773168"

ATTR{alignment_offset}=="0"

ATTR{discard_alignment}=="0"

ATTR{capability}=="50"

ATTR{stat}=="       9       26      280       90        0        0        0        0        0       90       90"

ATTR{inflight}=="       0        0"

looking a

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值