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

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

用途说明

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>boot.messages

and mail the boot.messages file to whoever can debug their problem.

[root@new55 ~]# dmesg >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" [email protected] <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 

Linuxversion2.6.18-194.el5([email protected])(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010

BIOS-providedphysicalRAMmap:

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(ACPINVS)

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)

0MBHIGHMEMavailable.

503MBLOWMEMavailable.

Memoryforcrashkernel(0x0to0x0)notwithinpermissiblerange

disablingkdump

Usingx86segmentlimitstoapproximateNXprotection

Onnode0totalpages:128976

DMAzone:4096pages,LIFObatch:0

Normalzone:124880pages,LIFObatch:31

DMI2.3present.

UsingAPICdriverdefault

ACPI:RSDP(v000HP)@0x000fe270

ACPI:RSDT(v001HP30C40x31100620HP0x00000001)@0x1f7efc84

ACPI:FADT(v002HP30C40x00000002HP0x00000001)@0x1f7efc00

ACPI:MADT(v001HP30C40x00000001HP0x00000001)@0x1f7efcb8

ACPI:MCFG(v001HP30C40x00000001HP0x00000001)@0x1f7efd14

ACPI:SSDT(v001HPHPQPpc0x00001001MSFT0x0100000e)@0x1f7f6698

ACPI:DSDT(v001HPDAU000x00010000MSFT0x0100000e)@0x00000000

ACPI:PM-TimerIOPort:0x1008

ACPI:LocalAPICaddress0xfec01000

ACPI:LAPIC(acpi_id[0x01]lapic_id[0x00]enabled)

Processor#06:13APICversion20

ACPI:LAPIC_NMI(acpi_id[0x01]highedgelint[0x1])

ACPI:IOAPIC(id[0x01]address[0xfec00000]gsi_base[0])

IOAPIC[0]:apic_id1,version32,address0xfec00000,GSI0-23

:

示例三 查看dmesg尾部的信息

[root@new55 ~]# dmesg | tail 

Bluetooth:L2CAPver2.8

Bluetooth:L2CAPsocketlayerinitialized

Bluetooth:RFCOMMsocketlayerinitialized

Bluetooth:RFCOMMTTYlayerinitialized

Bluetooth:RFCOMMver1.8

Bluetooth:HIDP(HumanInterfaceEmulation)ver1.1

eth0:noIPv6routerspresent

Installingknfsd(copyright(C)[email protected]).

NFSD:Using/var/lib/nfs/v4recoveryastheNFSv4staterecoverydirectory

NFSD:starting90-secondgraceperiod

[root@new55 ~]#

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

[root@localhost ss7dpklnx]# cd SS7HD_DRIVER/ 

[root@localhostSS7HD_DRIVER]#ls

bbdddlnx_iss.hbbd_hbi.hbbd_ioc.cbbd_isr.cbbd_pci.cBSD_license.txtGPL_V2-only_license.txtinstall_ss7hd.shMakefile26

bbd_def.hbbd_hs.cbbd_ioc.hbbd_lnx.cbbd_pro.hbuild_ss7hd.shi21555.hMakefile24

[root@localhostSS7HD_DRIVER]#./build_ss7hd.sh

make:Enteringdirectory`/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

Buildingmodules,stage2.

MODPOST

CC/root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.mod.o

LD[M]/root/setup/ss7dpklnx/SS7HD_DRIVER/ss7hddvr26.ko

make:Leavingdirectory`/usr/src/kernels/2.6.9-22.EL-i686'

[root@localhostSS7HD_DRIVER]#./install_ss7hd.sh

[root@localhostSS7HD_DRIVER]#lsmod|grepss7

ss7hddvr26258080

[root@localhostSS7HD_DRIVER]#dmesg|tail

ACPI:PCIinterrupt0000:02:0d.0[?]->GSI9(level,low)->IRQ9

BBD[0]64bit

SS7HD[0]-suspend

DialogicSS7HDDeviceDriverV100.00(SourceV1.21)

Copyright(C)DialogicCorporation2003-2010.AllRightsReserved

Usingmajordevicenumber251.

ACPI:PCIinterrupt0000:02:0d.0[?]->GSI9(level,low)->IRQ9

BBD[0]64bit

[root@localhostSS7HD_DRIVER]#./install_ss7hd.shremove

[root@localhostSS7HD_DRIVER]#lsmod|grepss7

[root@localhostSS7HD_DRIVER]#dmesg|tail

BBD[0]64bit

SS7HD[0]-suspend

DialogicSS7HDDeviceDriverV100.00(SourceV1.21)

Copyright(C)DialogicCorporation2003-2010.AllRightsReserved

Usingmajordevicenumber251.

ACPI:PCIinterrupt0000:02:0d.0[?]->GSI9(level,low)->IRQ9

BBD[0]64bit

SS7HD[0]-suspend

[root@localhost SS7HD_DRIVER]#

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

[root@new55 ~]# dmesg -c 

Linuxversion2.6.18-194.el5([email protected])(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010

BIOS-providedphysicalRAMmap:

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(ACPINVS)

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)

0MBHIGHMEMavailable.

503MBLOWMEMavailable.

Memoryforcrashkernel(0x0to0x0)notwithinpermissiblerange

disablingkdump

Usingx86segmentlimitstoapproximateNXprotection

Onnode0totalpages:128976

DMAzone:4096pages,LIFObatch:0

Normalzone:124880pages,LIFObatch:31

DMI 2.3 present.

省略输出

Bluetooth: HIDP (Human Interface Emulation) ver 1.1

eth0:noIPv6routerspresent

Installingknfsd(copyright(C)[email protected]).

NFSD:Using/var/lib/nfs/v4recoveryastheNFSv4staterecoverydirectory

NFSD:starting90-secondgraceperiod

[root@new55 ~]# dmesg

[root@new55 ~]# less /var/log/dmesg 

Linuxversion2.6.18-194.el5([email protected])(gccversion4.1.220080704(RedHat4.1.2-48))#1SMPTueMar1621:52:43EDT2010

BIOS-providedphysicalRAMmap:

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(ACPINVS)

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)

0MBHIGHMEMavailable.

503MBLOWMEMavailable.

Memoryforcrashkernel(0x0to0x0)notwithinpermissiblerange

disablingkdump

Usingx86segmentlimitstoapproximateNXprotection

Onnode0totalpages:128976

DMAzone:4096pages,LIFObatch:0

Normalzone:124880pages,LIFObatch:31

DMI2.3present.

UsingAPICdriverdefault

ACPI:RSDP(v000HP)@0x000fe270

ACPI:RSDT(v001HP30C40x31100620HP0x00000001)@0x1f7efc84

ACPI:FADT(v002HP30C40x00000002HP0x00000001)@0x1f7efc00

ACPI:MADT(v001HP30C40x00000001HP0x00000001)@0x1f7efcb8

ACPI:MCFG(v001HP30C40x00000001HP0x00000001)@0x1f7efd14

ACPI:SSDT(v001HPHPQPpc0x00001001MSFT0x0100000e)@0x1f7f6698

ACPI:DSDT(v001HPDAU000x00010000MSFT0x0100000e)@0x00000000

ACPI:PM-TimerIOPort:0x1008

ACPI:LocalAPICaddress0xfec01000

ACPI:LAPIC(acpi_id[0x01]lapic_id[0x00]enabled)

Processor#06:13APICversion20

ACPI:LAPIC_NMI(acpi_id[0x01]highedgelint[0x1])

ACPI:IOAPIC(id[0x01]address[0xfec00000]gsi_base[0])

IOAPIC[0]:apic_id1,version32,address0xfec00000,GSI0-23

[root@new55 ~]#

问题思考

相关资料

【1】baisafe   dmesg linux查看开机启动的信息    

【2】AnotherMELINUX这些日志信息处理的来龙去脉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指令篇:系统设置--dmesghttp://linux.chinaitlab.com/command/723897.html

相关推荐