dmesg
(display message或者driver message)是Linux系统中用于显示内核启动信息和运行时状态的命令。它可以帮助我们了解硬件驱动的加载情况、设备状态以及系统运行过程中遇到的问题。
在dmesg
的输出中,我们可以找到与硬件驱动相关的信息,主要包括以下几个方面:
[ ]
或[U]
开头,表示驱动已加载(Loaded)或未加载(Unloaded)。例如:[ 0.000000] Linux version 5.4.0-42-generic (buildd@lgw01-amd64-039) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-42-generic root=UUID=xxxx-xxxx-xxxx-xxxx-xxxx rw quiet splash vt.handoff=7
[ 0.000000] KERNEL supported cpus:
...
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
...
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
...
[ 0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'compacted' format.
...
[ 0.123456] usbcore: registered new interface driver usbfs
[ 0.123456] usbcore: registered new interface driver hub
[ 0.123456] usbcore: registered new device driver usb
...
[ 0.234567] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[ 0.234567] usb 1-1: New USB device found, idVendor=xxxx, idProduct=xxxx
[ 0.234567] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 0.234567] usb 1-1: Product: USB Disk
[ 0.234567] usb 1-1: Manufacturer: Generic
[ 0.234567] usb 1-1: SerialNumber: 1234567890
...
[ ]
或[!]
开头,表示错误(Error)或警告(Warning)。例如:[ 1.234567] ata1.00: exception Emask 0x0 SAct 0x10 SErr 0x0 action 0x0
[ 1.234567] ata1.00: irq_stat 0x40000008
[ 1.234567] ata1.00: failed command: READ FPDMA QUEUED
[ 1.234567] ata1.00: cmd 60/08:00:10:9d:00/00:00:08:00:00/e0 tag 0 ncq dma 1024 in
[ 1.234567] res 41/40:00:10:9d:00/00:00:08:00:00/e0 Emask 0x409 (media error) <F>
[ 1.234567] ata1.00: status: { DRDY ERR }
[ 1.234567] ata1.00: error: { UNC }
通过分析dmesg
中的硬件驱动信息,我们可以了解系统硬件的工作状态,诊断和解决硬件相关的问题。如果你遇到问题,可以尝试运行dmesg
命令并查看相关输出,以便找到问题的根源。