Linux udevadm info命令

Linux udevadm info命令:查询udev数据库中的设备信息。

Linux udevadm info命令 功能描述

使用udevadm info命令可以查询udev数据库中的设备信息。也可以从sysfs文件系统中查询到设备的属性以辅助创建udev规则。

Linux udevadm info命令 语法

udevadm info [选项]

命令中各选项的含义如表所示。

udevadm info命令选项含义

Linux udevadm info命令 示例

查询/dev/sda设备的系统设备路径

[root@rhel ~]# udevadm info -q path -n /dev/sda
/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0/block/sda

查询/dev/sda设备的符号链接文件

[root@rhel ~]# udevadm info -q symlink -n /dev/sda
block/8:0 disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0
[root@rhel ~]# ls -l /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0
lrwxrwxrwx. 1 root root 9 10月 30 23:20 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-> ../../sda

查询/dev/sda设备的所有的值

[root@rhel ~]# udevadm info -q all -n /dev/sda
P: /devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0/block/sda
N: sda
W: 36
S: block/8:0
S: disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0/block/sda
E: MAJOR=8
E: MINOR=0
E: DEVNAME=/dev/sda
E: DEVTYPE=disk
E: SUBSYSTEM=block
E: ID_SCSI=1
E: ID_VENDOR=VMware_
E: ID_VENDOR_ENC=VMware\x2c\x20
E: ID_MODEL=VMware_Virtual_S
E: ID_MODEL_ENC=VMware\x20Virtual\x20S
E: ID_REVISION=1.0
E: ID_TYPE=disk
E: ID_BUS=scsi
E: ID_PATH=pci-0000:00:10.0-scsi-0:0:0:0
E: ID_PART_TABLE_TYPE=dos
E: LVM_SBIN_PATH=/sbin
E: UDISKS_PRESENTATION_NOPOLICY=0
E: UDISKS_PARTITION_TABLE=1
E: UDISKS_PARTITION_TABLE_SCHEME=mbr
E: UDISKS_PARTITION_TABLE_COUNT=3
E: DEVLINKS=/dev/block/8:0 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0

查询系统设备的路径/sys/block/sda

[root@rhel ~]# 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/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0/block/sda':
    KERNEL==''sda''
    SUBSYSTEM==''block''
    DRIVER==''''
    ATTR{range}==''16''
    ATTR{ext_range}==''256''
    ATTR{removable}==''0''
    ATTR{ro}==''0''
    ATTR{size}==''1048576000''
    ATTR{alignment_offset}==''0''
    ATTR{discard_alignment}==''0''
    ATTR{capability}==''52''
    ATTR{stat}==''10637  4649  744248  179728  345010321110184112061 0138159  291764''
    ATTR{inflight}==''      0       0''
  looking at parent device '/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0':
    KERNELS==''0:0:0:0''
    SUBSYSTEMS==''scsi''
    DRIVERS==''sd''
    ATTRS{device_blocked}==''0''
    ATTRS{type}==''0''
    ATTRS{scsi_level}==''3''
    ATTRS{vendor}==''VMware, ''
    ATTRS{model}==''VMware Virtual S''
    ATTRS{rev}==''1.0 ''
    ATTRS{state}==''running''
    ATTRS{timeout}==''30''
    ATTRS{iocounterbits}==''32''
    ATTRS{iorequest_cnt}==''0x3732''
    ATTRS{iodone_cnt}==''0x3732''
    ATTRS{ioerr_cnt}==''0xf ''
    ATTRS{modalias}==''scsi:t-0x00''
    ATTRS{evt_media_change}==''0''
    ATTRS{dh_state}==''detached''
    ATTRS{queue_depth}==''32''
    ATTRS{queue_ramp_up_period}==''120000''
    ATTRS{queue_type}==''simple''
  looking at parent device '/devices/pci0000:00/00
00:00:10.0/host0/target0:0:0':
    KERNELS==''target0:0:0''
    SUBSYSTEMS==''scsi''
    DRIVERS==''''
  looking at parent device '/devices/pci0000:00/0000:00:10.0/host0':
    KERNELS==''host0''
    SUBSYSTEMS==''scsi''
    DRIVERS==''''
  looking at parent device '/devices/pci0000:00/0000:00:10.0':
    KERNELS==''0000:00:10.0''
    SUBSYSTEMS==''pci''
    DRIVERS==''mptspi''
    ATTRS{vendor}==''0x1000''
    ATTRS{device}==''0x0030''
    ATTRS{subsystem_vendor}==''0x15ad''
    ATTRS{subsystem_device}==''0x1976''
    ATTRS{class}==''0x010000''
    ATTRS{irq}==''17''
    ATTRS{local_cpus}==''00000000,00000001''
    ATTRS{local_cpulist}==''0''
    ATTRS{modalias}==''pci:v00001000d00000030sv000015ADsd00001976bc01sc00i00''
    ATTRS{numa_node}==''-1''
    ATTRS{enable}==''1''
    ATTRS{broken_parity_status}==''0''
    ATTRS{msi_bus}==''''
    ATTRS{config}==''''
  looking at parent device '/devices/pci0000:00':
    KERNELS==''pci0000:00''
    SUBSYSTEMS==''''
    DRIVERS==''''

查询/block/sda设备

[root@rhel ~]# udevadm info -a -p /block/sda | grep -E “model|size”
    ATTR{size}==”1048576000”
    ATTRS{model}==''VMware Virtual S''

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程