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
命令并查看相關輸出,以便找到問題的根源。