201.3 Kernelverwaltung zur Laufzeit und Fehlersuche Gewichtung 4
201.3 Kernelverwaltung zur Laufzeit und Fehlersuche
lsusb
- lsusb is a utility for displaying information about USB buses in the system and the devices connected to them.
siehe man lsusb
# lsusb --help
Usage: lsusb [options]...
List USB devices
-v, --verbose
Increase verbosity (show descriptors)
-s [[bus]:][devnum]
Show only devices with specified device and/or
bus numbers (in decimal)
-d vendor:[product]
Show only devices with the specified vendor and
product ID numbers (in hexadecimal)
-D device
Selects which device lsusb will examine
-t, --tree
Dump the physical USB device hierarchy as a tree
Beispiel:
# lsusb
Bus 001 Device 003: ID 15a9:0004 Gemtek WUBR-177G [Ralink RT2571W]
Bus 001 Device 004: ID 058f:6377 Alcor Micro Corp. AU6375 4-LUN card reader
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 045e:0745 Microsoft Corp. Nano Transceiver v1.0 for Bluetooth
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
# lsusb -vs 001:003
Bus 001 Device 003: ID 15a9:0004 Gemtek WUBR-177G [Ralink RT2571W]
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x15a9 Gemtek
idProduct 0x0004 WUBR-177G [Ralink RT2571W]
bcdDevice 0.01
iManufacturer 1 Ralink
iProduct 2 802.11 bg WLAN
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 53
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 300mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
...
Interessant sind vor allem die Zeilen idVendor, idProduct und iSerial, da sich ihre Werte wegen ihrer Eindeutigkeit relativ gut für eine udev-Regel verwenden lassen. Mit diesen Angaben lassen sich bereits funktionierende Bedingungen für eine eigene udev-Regel bauen.
Die VendorId findet sich auch in der /var/log/messages
wieder:
May 21 21:17:59 slimline kernel: usb 1-9: New USB device found, idVendor=15a9, idProduct=0004, bcdDevice= 0.01
May 21 21:17:59 slimline kernel: usb 1-9: New USB device strings: Mfr=1, Product=2, SerialNumber=0
May 21 21:17:59 slimline kernel: usb 1-9: Product: 802.11 bg WLAN
May 21 21:17:59 slimline kernel: usb 1-9: Manufacturer: Ralink
Wir finden dieses WLAN-USB Gerät auch unter /sys/class/net
:
[root@slimline ~]# ls -l /sys/class/net/
insgesamt 0
lrwxrwxrwx 1 root root 0 21. Mai 2020 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 21. Mai 19:18 virbr0 -> ../../devices/virtual/net/virbr0
lrwxrwxrwx 1 root root 0 21. Mai 19:18 virbr0-nic -> ../../devices/virtual/net/virbr0-nic
lrwxrwxrwx 1 root root 0 21. Mai 19:18 wlp0s2f1u9 -> ../../devices/pci0000:00/0000:00:02.1/usb1/1-9/1-9:1.0/net/wlp0s2f1u9
Sie haben neue Post in /var/spool/mail/root.
[root@slimline ~]# ls -l /sys/class/net/wlp0s2f1u9
lrwxrwxrwx 1 root root 0 21. Mai 19:41 /sys/class/net/wlp0s2f1u9 -> ../../devices/pci0000:00/0000:00:02.1/usb1/1-9/1-9:1.0/net/wlp0s2f1u9
lspci
zeigt auch Informationen dazu an:
[root@slimline ~]# lspci
00:00.0 RAM memory: NVIDIA Corporation MCP61 Memory Controller (rev a1)
00:01.0 ISA bridge: NVIDIA Corporation MCP61 LPC Bridge (rev a2)
00:01.1 SMBus: NVIDIA Corporation MCP61 SMBus (rev a2)
00:01.2 RAM memory: NVIDIA Corporation MCP61 Memory Controller (rev a2)
00:02.0 USB controller: NVIDIA Corporation MCP61 USB 1.1 Controller (rev a3)
00:02.1 USB controller: NVIDIA Corporation MCP61 USB 2.0 Controller (rev a3)
00:04.0 PCI bridge: NVIDIA Corporation MCP61 PCI bridge (rev a1)
00:05.0 Audio device: NVIDIA Corporation MCP61 High Definition Audio (rev a2)
00:06.0 IDE interface: NVIDIA Corporation MCP61 IDE (rev a2)
00:07.0 Bridge: NVIDIA Corporation MCP61 Ethernet (rev a2)
00:08.0 IDE interface: NVIDIA Corporation MCP61 SATA Controller (rev a2)
00:09.0 PCI bridge: NVIDIA Corporation MCP61 PCI Express bridge (rev a2)
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:05.0 FireWire (IEEE 1394): LSI Corporation FW322/323 [TrueFire] 1394a Controller (rev 70)
02:00.0 VGA compatible controller: NVIDIA Corporation G96C [GeForce 9500 GS] (rev a1)
Die Parameter -nn
zeigen die Vendor und Device-ids und die zugehörigen Namen. -k
zeigt ausserdem den Kerneltreiben und das Modul.
Ohne passenden Treiber zur Ethernetkarte:
# lspci -nnk |grep -A5 Ethernet
00:07.0 Bridge [0680]: NVIDIA Corporation MCP61 Ethernet [10de:03ef] (rev a2)
Subsystem: Hewlett-Packard Company Device [103c:2a66]
00:08.0 IDE interface [0101]: NVIDIA Corporation MCP61 SATA Controller [10de:03f6] (rev a2)
Subsystem: Hewlett-Packard Company Device [103c:2a66]
Kernel driver in use: sata_nv
Kernel modules: sata_nv, pata_acpi, ata_generic
mit passenden Treiber:
# lspci -nnk |grep -A5 Ethernet
00:07.0 Bridge [0680]: NVIDIA Corporation MCP61 Ethernet [10de:03ef] (rev a2)
Subsystem: Hewlett-Packard Company Device [103c:2a66]
Kernel driver in use: forcedeth
Kernel modules: forcedeth
00:08.0 IDE interface [0101]: NVIDIA Corporation MCP61 SATA Controller [10de:03f6] (rev a2)
Subsystem: Hewlett-Packard Company Device [103c:2a66]
udev
ist ein Dienst der Geräte verwaltet, siehe udev ubuntu-wiki. Mit udevadm
kann man
udevadm --help
udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS]
Send control commands or test the device manager.
Commands:
info Query sysfs or the udev database
trigger Request events from the kernel
settle Wait for pending udev events
control Control the udev daemon
monitor Listen to kernel and udev events
test Test an event run
test-builtin Test a built-in command
monitor --env
verwendet man um udev-Regel-Filter auszulesen, die beim Entfernen eine Gerätes erscheinen.
udevadm monitor --env
siehe man udevadm
Informationen der Netzwerkkarte anschauen mit udevadm info
. -a
gibt alle Eigenschaften aus. -p
erwartet den sys-Pfad zum Device.
# lspci -nn |grep Ethernet
00:07.0 Bridge [0680]: NVIDIA Corporation MCP61 Ethernet [10de:03ef] (rev a2)
# ls /sys/class/net/
enp0s7 lo virbr0 virbr0-nic wlp0s2f1u9
# udevadm info -a -p /sys/devices/pci0000:00/0000:00:07.0/net/enp0s7
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:07.0/net/enp0s7':
KERNEL=="enp0s7"
SUBSYSTEM=="net"
DRIVER==""
ATTR{mtu}=="1500"
ATTR{type}=="1"
ATTR{netdev_group}=="0"
ATTR{flags}=="0x1003"
ATTR{speed}=="100"
ATTR{dormant}=="0"
ATTR{proto_down}=="0"
ATTR{addr_assign_type}=="0"
ATTR{dev_id}=="0x0"
ATTR{duplex}=="full"
ATTR{gro_flush_timeout}=="0"
ATTR{iflink}=="2"
ATTR{addr_len}=="6"
ATTR{address}=="00:23:54:2d:4d:43"
ATTR{operstate}=="up"
ATTR{carrier_changes}=="2"
ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
ATTR{tx_queue_len}=="1000"
ATTR{dev_port}=="0"
ATTR{ifalias}==""
ATTR{ifindex}=="2"
ATTR{link_mode}=="0"
ATTR{carrier}=="1"
looking at parent device '/devices/pci0000:00/0000:00:07.0':
KERNELS=="0000:00:07.0"
SUBSYSTEMS=="pci"
DRIVERS=="forcedeth"
ATTRS{irq}=="26"
ATTRS{subsystem_vendor}=="0x103c"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x068000"
ATTRS{driver_override}=="(null)"
ATTRS{consistent_dma_mask_bits}=="39"
ATTRS{dma_mask_bits}=="39"
ATTRS{local_cpus}=="3"
ATTRS{device}=="0x03ef"
ATTRS{enable}=="1"
ATTRS{msi_bus}==""
ATTRS{local_cpulist}=="0-1"
ATTRS{vendor}=="0x10de"
ATTRS{subsystem_device}=="0x2a66"
ATTRS{numa_node}=="0"
ATTRS{d3cold_allowed}=="1"
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""