---
title: "我使用过的Linux命令之dmesg - 查看开机信息/打印或控制内核环形缓冲区"
author: "codingstandards"
date: "2010-12-09T13:20:32Z"
tags: ["C++", "HP", "IOC", "Linux", "RedHat"]
categories: ["操作系统"]
slug: "linux-dmesg"
draft: false
lastmod: "2011-04-10T11:47:26Z"
id: 837486
url: "https://codingstandards.iteye.com/blog/837486"
---

# 我使用过的Linux命令之dmesg - 查看开机信息/打印或控制内核环形缓冲区

本文链接：[http://codingstandards.iteye.com/blog/837486](/blog/837486)     （转载请注明出处）

 

## 用途说明

dmesg命令用于打印Linux系统开机启动信息，kernel会将开机信息存储在ring buffer中。您若是开机时来不及查看信息，可利用dmesg来查看（print or control the kernel ring buffer）。开机信息亦保存在/var/log/dmesg的文件里。某些硬件设备（比如七号信令卡、语音卡之类）在安装的时候，通常会安装驱动程序（内核模块），会打印一些信息，就可以通过dmesg命令来查看。

 

## 常用参数

格式：dmesg

查看开机信息。

 

格式：dmesg -c

清除开机信息，但/var/log/dmesg文件中仍然有这些信息。

 

因为dmesg命令输出的东西有点多，通常与less/more/tail/grep等命令配合使用。

 

## 使用示例

### 示例一 将开机信息发邮件

man dmesg 写道

The program helps users to print out their bootup messages. Instead of copying the messages by hand, the user need only:  
dmesg &gt; boot.messages  
and mail the boot.messages file to whoever can debug their problem.

 

\[root@new55 ~]# dmesg &gt;boot.messages

\[root@new55 ~]# ls -l boot.messages  
\-rw-r--r-- 1 root root 15838 12-09 12:55 boot.messages

\[root@new55 ~]# mail -s "Boot Log of Linux Server" public@web3q.net &lt;boot.messages  
\[root@new55 ~]#

### 示例二 浏览dmesg输出的信息

\[root@new55 ~]# uname -a  
Linux new55 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux

\[root@new55 ~]# dmesg | less  
Linux version 2.6.18-194.el5 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010  
BIOS-provided physical RAM map:  
 BIOS-e820: 0000000000010000 - 000000000009fc00 (usable)  
 BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)  
 BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)  
 BIOS-e820: 0000000000100000 - 000000001f7d0000 (usable)  
 BIOS-e820: 000000001f7d0000 - 000000001f7efc00 (reserved)  
 BIOS-e820: 000000001f7efc00 - 000000001f7fb000 (ACPI NVS)  
 BIOS-e820: 000000001f7fb000 - 000000001f800000 (reserved)  
 BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)  
 BIOS-e820: 00000000fec00000 - 00000000fec02000 (reserved)  
 BIOS-e820: 00000000fed20000 - 00000000fed9b000 (reserved)  
 BIOS-e820: 00000000feda0000 - 00000000fedc0000 (reserved)  
 BIOS-e820: 00000000ffb00000 - 00000000ffc00000 (reserved)  
 BIOS-e820: 00000000fff00000 - 0000000100000000 (reserved)  
0MB HIGHMEM available.  
503MB LOWMEM available.  
Memory for crash kernel (0x0 to 0x0) notwithin permissible range  
disabling kdump  
Using x86 segment limits to approximate NX protection  
On node 0 totalpages: 128976  
  DMA zone: 4096 pages, LIFO batch:0  
  Normal zone: 124880 pages, LIFO batch:31  
DMI 2.3 present.  
Using APIC driver default  
ACPI: RSDP (v000 HP                                    ) @ 0x000fe270  
ACPI: RSDT (v001 HP     30C4     0x31100620 HP   0x00000001) @ 0x1f7efc84  
ACPI: FADT (v002 HP     30C4     0x00000002 HP   0x00000001) @ 0x1f7efc00  
ACPI: MADT (v001 HP     30C4     0x00000001 HP   0x00000001) @ 0x1f7efcb8  
ACPI: MCFG (v001 HP     30C4     0x00000001 HP   0x00000001) @ 0x1f7efd14  
ACPI: SSDT (v001 HP       HPQPpc 0x00001001 MSFT 0x0100000e) @ 0x1f7f6698  
ACPI: DSDT (v001 HP       DAU00  0x00010000 MSFT 0x0100000e) @ 0x00000000  
ACPI: PM-Timer IO Port: 0x1008  
ACPI: Local APIC address 0xfec01000  
ACPI: LAPIC (acpi\_id\[0x01] lapic\_id\[0x00] enabled)  
Processor #0 6:13 APIC version 20  
ACPI: LAPIC\_NMI (acpi\_id\[0x01] high edge lint\[0x1])  
ACPI: IOAPIC (id\[0x01] address\[0xfec00000] gsi\_base\[0])  
IOAPIC\[0]: apic\_id 1, version 32, address 0xfec00000, GSI 0-23  
:

 

### 示例三 查看dmesg尾部的信息

\[root@new55 ~]# dmesg | tail  
Bluetooth: L2CAP ver 2.8  
Bluetooth: L2CAP socket layer initialized  
Bluetooth: RFCOMM socket layer initialized  
Bluetooth: RFCOMM TTY layer initialized  
Bluetooth: RFCOMM ver 1.8  
Bluetooth: HIDP (Human Interface Emulation) ver 1.1  
eth0: no IPv6 routers present  
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).  
NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory  
NFSD: starting 90-second grace period  
\[root@new55 ~]#

 

### 示例四 安装SS7卡驱动时的内核日志

\[root@localhost ss7dpklnx]# cd SS7HD\_DRIVER/  
\[root@localhost SS7HD\_DRIVER]# ls  
bbdddlnx\_iss.h  bbd\_hbi.h  bbd\_ioc.c  bbd\_isr.c  bbd\_pci.c  BSD\_license.txt  GPL\_V2-only\_license.txt  install\_ss7hd.sh  Makefile26  
bbd\_def.h       bbd\_hs.c   bbd\_ioc.h  bbd\_lnx.c  bbd\_pro.h  build\_ss7hd.sh   i21555.h                 Makefile24  
\[root@localhost SS7HD\_DRIVER]# ./build\_ss7hd.sh  
make: Entering directory \`/usr/src/kernels/2.6.9-22.EL-i686'  
  CC \[M]  /root/setup/ss7dpklnx/SS7HD\_DRIVER/bbd\_hs.o  
  CC \[M]  /root/setup/ss7dpklnx/SS7HD\_DRIVER/bbd\_ioc.o  
  CC \[M]  /root/setup/ss7dpklnx/SS7HD\_DRIVER/bbd\_isr.o  
  CC \[M]  /root/setup/ss7dpklnx/SS7HD\_DRIVER/bbd\_pci.o  
  CC \[M]  /root/setup/ss7dpklnx/SS7HD\_DRIVER/bbd\_lnx.o  
  LD \[M]  /root/setup/ss7dpklnx/SS7HD\_DRIVER/ss7hddvr26.o  
  Building modules, stage 2.  
  MODPOST  
  CC      /root/setup/ss7dpklnx/SS7HD\_DRIVER/ss7hddvr26.mod.o  
  LD \[M]  /root/setup/ss7dpklnx/SS7HD\_DRIVER/ss7hddvr26.ko  
make: Leaving directory \`/usr/src/kernels/2.6.9-22.EL-i686'  
\[root@localhost SS7HD\_DRIVER]# ./install\_ss7hd.sh  
\[root@localhost SS7HD\_DRIVER]# lsmod | grep ss7  
ss7hddvr26             25808  0  
\[root@localhost SS7HD\_DRIVER]# dmesg | tail  
ACPI: PCI interrupt 0000:02:0d.0\[?] -&gt; GSI 9 (level, low) -&gt; IRQ 9  
BBD\[0] 64bit  
SS7HD\[0] - suspend

Dialogic SS7HD Device Driver V100.00 (Source V1.21)  
Copyright (C) Dialogic Corporation 2003-2010.  All Rights Reserved  
Using major device number 251.  
ACPI: PCI interrupt 0000:02:0d.0\[?] -&gt; GSI 9 (level, low) -&gt; IRQ 9  
BBD\[0] 64bit  
\[root@localhost SS7HD\_DRIVER]# ./install\_ss7hd.sh remove  
\[root@localhost SS7HD\_DRIVER]# lsmod | grep ss7  
\[root@localhost SS7HD\_DRIVER]# dmesg | tail  
BBD\[0] 64bit  
SS7HD\[0] - suspend

Dialogic SS7HD Device Driver V100.00 (Source V1.21)  
Copyright (C) Dialogic Corporation 2003-2010.  All Rights Reserved  
Using major device number 251.  
ACPI: PCI interrupt 0000:02:0d.0\[?] -&gt; GSI 9 (level, low) -&gt; IRQ 9  
BBD\[0] 64bit  
SS7HD\[0] - suspend  
\[root@localhost SS7HD\_DRIVER]#

 

### 示例五 打印并清除内核环形缓冲区

\[root@new55 ~]# dmesg -c  
Linux version 2.6.18-194.el5 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010  
BIOS-provided physical RAM map:  
 BIOS-e820: 0000000000010000 - 000000000009fc00 (usable)  
 BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)  
 BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)  
 BIOS-e820: 0000000000100000 - 000000001f7d0000 (usable)  
 BIOS-e820: 000000001f7d0000 - 000000001f7efc00 (reserved)  
 BIOS-e820: 000000001f7efc00 - 000000001f7fb000 (ACPI NVS)  
 BIOS-e820: 000000001f7fb000 - 000000001f800000 (reserved)  
 BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)  
 BIOS-e820: 00000000fec00000 - 00000000fec02000 (reserved)  
 BIOS-e820: 00000000fed20000 - 00000000fed9b000 (reserved)  
 BIOS-e820: 00000000feda0000 - 00000000fedc0000 (reserved)  
 BIOS-e820: 00000000ffb00000 - 00000000ffc00000 (reserved)  
 BIOS-e820: 00000000fff00000 - 0000000100000000 (reserved)  
0MB HIGHMEM available.  
503MB LOWMEM available.  
Memory for crash kernel (0x0 to 0x0) notwithin permissible range  
disabling kdump  
Using x86 segment limits to approximate NX protection  
On node 0 totalpages: 128976  
  DMA zone: 4096 pages, LIFO batch:0  
  Normal zone: 124880 pages, LIFO batch:31  
DMI 2.3 present.

省略输出

Bluetooth: HIDP (Human Interface Emulation) ver 1.1  
eth0: no IPv6 routers present  
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).  
NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory  
NFSD: starting 90-second grace period  
\[root@new55 ~]# dmesg

\[root@new55 ~]# less /var/log/dmesg  
Linux version 2.6.18-194.el5 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010  
BIOS-provided physical RAM map:  
 BIOS-e820: 0000000000010000 - 000000000009fc00 (usable)  
 BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)  
 BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)  
 BIOS-e820: 0000000000100000 - 000000001f7d0000 (usable)  
 BIOS-e820: 000000001f7d0000 - 000000001f7efc00 (reserved)  
 BIOS-e820: 000000001f7efc00 - 000000001f7fb000 (ACPI NVS)  
 BIOS-e820: 000000001f7fb000 - 000000001f800000 (reserved)  
 BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)  
 BIOS-e820: 00000000fec00000 - 00000000fec02000 (reserved)  
 BIOS-e820: 00000000fed20000 - 00000000fed9b000 (reserved)  
 BIOS-e820: 00000000feda0000 - 00000000fedc0000 (reserved)  
 BIOS-e820: 00000000ffb00000 - 00000000ffc00000 (reserved)  
 BIOS-e820: 00000000fff00000 - 0000000100000000 (reserved)  
0MB HIGHMEM available.  
503MB LOWMEM available.  
Memory for crash kernel (0x0 to 0x0) notwithin permissible range  
disabling kdump  
Using x86 segment limits to approximate NX protection  
On node 0 totalpages: 128976  
  DMA zone: 4096 pages, LIFO batch:0  
  Normal zone: 124880 pages, LIFO batch:31  
DMI 2.3 present.  
Using APIC driver default  
ACPI: RSDP (v000 HP                                    ) @ 0x000fe270  
ACPI: RSDT (v001 HP     30C4     0x31100620 HP   0x00000001) @ 0x1f7efc84  
ACPI: FADT (v002 HP     30C4     0x00000002 HP   0x00000001) @ 0x1f7efc00  
ACPI: MADT (v001 HP     30C4     0x00000001 HP   0x00000001) @ 0x1f7efcb8  
ACPI: MCFG (v001 HP     30C4     0x00000001 HP   0x00000001) @ 0x1f7efd14  
ACPI: SSDT (v001 HP       HPQPpc 0x00001001 MSFT 0x0100000e) @ 0x1f7f6698  
ACPI: DSDT (v001 HP       DAU00  0x00010000 MSFT 0x0100000e) @ 0x00000000  
ACPI: PM-Timer IO Port: 0x1008  
ACPI: Local APIC address 0xfec01000  
ACPI: LAPIC (acpi\_id\[0x01] lapic\_id\[0x00] enabled)  
Processor #0 6:13 APIC version 20  
ACPI: LAPIC\_NMI (acpi\_id\[0x01] high edge lint\[0x1])  
ACPI: IOAPIC (id\[0x01] address\[0xfec00000] gsi\_base\[0])  
IOAPIC\[0]: apic\_id 1, version 32, address 0xfec00000, GSI 0-23  
\[root@new55 ~]#

## 问题思考

## 相关资料

【1】baisafe   dmesg linux查看开机启动的信息     
【2】Another ME   LINUX这些日志信息处理的来龙去脉    http://www.ys250.com/2009/03/16/dmesg/  
【3】旅途    Linux中的dmesg了解    http://www.cppblog.com/mydriverc/archive/2009/10/13/98534.html  
【4】Linux频道   Linux 指令篇：系统设置--dmesg     http://linux.chinaitlab.com/command/723897.html

 

返回 [我使用过的Linux命令系列总目录](/blog/786653)