dmesg(display message或者driver message)是Linux系統中的一個命令,用于顯示內核啟動以來的消息緩沖區內容。這些消息通常包括硬件檢測、驅動程序加載、系統事件等信息。要解析dmesg日志中的內核消息,可以按照以下步驟進行:
1. 查看dmesg日志
首先,你可以直接運行dmesg命令來查看所有的內核消息:
dmesg
或者使用less或more命令分頁查看:
dmesg | less
2. 過濾關鍵信息
如果你只對某些類型的消息感興趣,可以使用grep命令進行過濾。例如,查找與USB相關的消息:
dmesg | grep usb
或者查找包含特定關鍵詞的消息:
dmesg | grep "error"
3. 分析關鍵消息
在內核消息中,有一些常見的關鍵詞和短語可以幫助你理解發生了什么:
- [ 0.000000]: 系統啟動的初始時間戳。
- [ 0.000000] Initializing cgroup subsys cpuset: 初始化cpuset子系統。
- [ 0.000000] Linux version 5.4.0-42-generic: 顯示當前運行的Linux內核版本。
- [ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-42-generic root=UUID=… ro quiet splash vt.handoff=7: 顯示啟動時的命令行參數。
- [ 0.000000] KERNEL supported cpus:: 列出支持的內核CPU。
- [ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: ‘x87 floating point registers’: 支持的XSAVE特性。
- [ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: ‘SSE registers’: 支持的XSAVE特性。
- [ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256: XSAVE狀態偏移和大小。
- [ 0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using ‘compacted’ format.: 啟用的XSAVE特性及上下文大小。
- [ 0.000000] BIOS-provided physical RAM map:: BIOS提供的物理內存映射。
- [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ffff] usable: 可用內存范圍。
- [ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000bfffffff] usable: 可用內存范圍。
- [ 0.000000] BIOS-e820: [mem 0x00000000c0000000-0x00000000cfffffff] reserved: 保留內存范圍。
- [ 0.000000] BIOS-e820: [mem 0x00000000d0000000-0x00000000d1ffffff] ACPI data: ACPI數據區域。
- [ 0.000000] BIOS-e820: [mem 0x00000000d2000000-0x00000000d2000fff] ACPI NVS: ACPI非易失性存儲。
- [ 0.000000] BIOS-e820: [mem 0x00000000d2001000-0x00000000dbffffff] reserved: 保留內存范圍。
- [ 0.000000] BIOS-e820: [mem 0x00000000dc000000-0x00000000dfffffff] reserved: 保留內存范圍。
- [ 0.000000] BIOS-e820: [mem 0x00000000e0000000-0x00000000ffffffff] reserved: 保留內存范圍。
- [ 0.000000] BIOS-e820: add [mem 0x00000000-0x00000fff] usable: 添加可用內存范圍。
- [ 0.000000] BIOS-e820: remove [mem 0x000a0000-0x000fffff] usable: 移除可用內存范圍。
- [ 0.000000] NX (Execute Disable) protection: active: 啟用NX保護。
- [ 0.000000] SMBIOS 2.8 present.
- [ 0.000000] DMI: QEMU Virtual Machine, BIOS QEMU_EFI_20200229_01 1.0 20200229
- [ 0.000000] tsc: Fast TSC calibration using PIT
- [ 0.000000] tsc: Detected 2499.999 MHz processor
- [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
- [ 0.000000] e820: remove [mem 0x00000000-0xffffffff] usable
- [ 0.000000] e820: add [mem 0x00090000-0x0009ffff] usable
- [ 0.000000] e820: add [mem 0x00100000-0xbfffffff] usable
- [ 0.000000] e820: add [mem 0xc0000000-0xcfffffff] reserved
- [ 0.000000] e820: add [mem 0xd0000000-0xdfffffff] ACPI data
- [ 0.000000] e820: add [mem 0xe0000000-0xefffffff] ACPI NVS
- [ 0.000000] e820: add [mem 0xf0000000-0xffffffff] reserved
- [ 0.000000] NX (Execute Disable) protection: active
- [ 0.000000] SMBIOS 2.8 present.
- [ 0.000000] DMI: QEMU Virtual Machine, BIOS QEMU_EFI_20200229_01 1.0 20200229
- [ 0.000000] tsc: Fast TSC calibration using PIT
- [ 0.000000] tsc: Detected 2499.999 MHz processor
- [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
- [ 0.000000] e820: remove [mem 0x00000000-0xffffffff] usable
- [ 0.000000] e820: add [mem 0x00090000-0x0009ffff] usable
- [ 0.000000] e820: add [mem 0x00100000-0xbfffffff] usable
- [ 0.000000] e820: add [mem 0xc0000000-0xcfffffff] reserved
- [ 0.000000] e820: add [mem 0xd0000000-0xdfffffff] ACPI data
- [ 0.000000] e820: add [mem 0xe0000000-0xefffffff] ACPI NVS
- [ 0.000000] e820: add [mem 0xf0000000-0xffffffff] reserved
- [ 0.000000] NX (Execute Disable) protection: active
- [ 0.000000] SMBIOS 2.8 present.
- [ 0.000000] DMI: QEMU Virtual Machine, BIOS QEMU_EFI_20200229_01 1.0 20200229
- [ 0.000000] tsc: Fast TSC calibration using PIT
- [ 0.000000] tsc: Detected 2499.999 MHz processor
- [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
- [ 0.000000] e820: remove [mem 0x00000000-0xffffffff] usable
- [ 0.000000] e820: add [mem 0x00090000-0x0009ffff] usable
- [ 0.000000] e820: add [mem 0x00100000-0xbfffffff] usable
- [ 0.000000] e820: add [mem 0xc0000000-0xcfffffff] reserved
- [ 0.000000] e820: add [mem 0xd0000000-0xdfffffff] ACPI data
- [ 0.000000] e820: add [mem 0xe0000000-0xefffffff] ACPI NVS
- [ 0.000000] e820: add [mem 0xf0000000-0xffffffff] reserved
- [ 0.000000] NX (Execute Disable) protection: active
- [ 0.000000] SMBIOS 2.8 present.
- [ 0.000000] DMI: QEMU Virtual Machine, BIOS QEMU_EFI_20200229_01 1.0 20200229
- [ 0.000000] tsc: Fast TSC calibration using PIT
- [ 0.000000] tsc: Detected 2499.999 MHz processor
- [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
- [ 0.000000] e820: remove [mem 0x00000000-0xffffffff] usable
- [ 0.000000] e820: add [mem 0x00090000-0x0009ffff] usable
- [ 0.000000] e820: add [mem 0x00100000-0xbfffffff] usable
- [ 0.000000] e820: add [mem 0xc0000000-0xcfffffff] reserved
- [ 0.000000] e820: add [mem 0xd0000000-0xdfffffff] ACPI data
- [ 0.000000] e820: add [mem 0xe0000000-0xefffffff] ACPI NVS
- [ 0.000000] e820: add [mem 0xf0000000-0xffffffff] reserved
- [ 0.000000] NX (Execute Disable) protection: active
- [ 0.000000] SMBIOS 2.8 present.
- [ 0.000000] DMI: QEMU Virtual Machine, BIOS QEMU_EFI_20200229_01 1.0 20200229
- [ 0.000000] tsc: Fast TSC calibration using PIT
- [ 0.000000] tsc: Detected 2499.999 MHz processor
- [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
- [ 0.000000] e820: remove [mem 0x00000000-0xffffffff] usable
- [ 0.000000] e820: add [mem 0x00090000-0x0009ffff] usable
- [ 0.000000] e820: add [mem 0x00100000-0xbfffffff] usable
- [ 0.000000] e820: add [mem 0xc0000000-0xcfffffff] reserved
- [ 0.000000] e820: add [mem 0xd0000000-0xdfffffff] ACPI data
- [ 0.000000] e820: add [mem 0xe0000000-0xefffffff] ACPI NVS
- [ 0.000000] e820: add [mem 0xf0000000-0xffffffff] reserved
- [ 0.000000] NX (Execute Disable) protection: active
- [ 0.000000] SMBIOS 2.8 present.
- [ 0.000000] DMI: QEMU Virtual Machine, BIOS QEMU_EFI_20200229_01 1.0 20200229
- [ 0.000000] tsc: Fast TSC calibration using PIT
- [ 0.000000] tsc: Detected 2499.999 MHz processor
- [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
- [ 0.000000] e820: remove [mem 0x00000000-0xffffffff] usable
- [ 0.000000] e820: add [mem 0x00090000-0x0009ffff] usable
- [ 0.000000] e820: add [mem 0x00100000-0xbfffffff] usable
- [ 0.000000] e820: add [mem 0xc0000000-0xcfffffff] reserved
- [ 0.000000] e820: add [mem 0xd0000000-0xdfffffff] ACPI data
- [ 0.000000] e820: add [mem 0xe0000000-0xefffffff] ACPI NVS
- **[