命令dmesg 用于显示内核环形缓冲区(kernel-ring buffer)的内容
2020-09-29 08:25:11
卿卿小孩
49
在Linux系统中,命令dmesg 用于显示内核环形缓冲区(kernel-ring buffer)的内容。在进行系统引导时,内核会将硬件和模块初始化相关信息的信息写到这个缓冲区中,内核环形缓冲区中的消息对于诊断系统问题非常有用。
内核环形缓冲区的内容同时会保存在/var/logm目录中,即名为dmesg的文件里。可通过如下命令进行查看:
[root@qingqing ~]# ll -h /var/log/dmesg -rw-r--r-- 1 root root 35K Jun 24 17:11 /var/log/dmesg [root@qingqing ~]#
语法:
dmesg [选项]
参数说明:
-c 显示信息后,清除环形缓冲区中的内容
-s bufsize 设置缓冲区大小,默认16384(2.1.113内核或更高)
-n level 显示消息等级
案例:
查看内核环形缓冲区(less命令作用是将信息分页显示)
[root@qingqing ~]# dmesg | less [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 3.10.0-862.el7.x86_64 (builder@kbuilder.dev.centos. org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Fri Apr 20 16 :44:24 UTC 2018 [ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-862.el7.x86_64 root=UUID=21dbe030-aa71-4b3a-8610-3b942dd447fa ro crashkernel=auto console=ttyS0 console=tty0 panic=5 net.ifnames=0 biosdevname=0 [ 0.000000] e820: BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable [ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007ffdbfff] usable [ 0.000000] BIOS-e820: [mem 0x000000007ffdc000-0x000000007fffffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved [ 0.000000] NX (Execute Disable) protection: active [ 0.000000] SMBIOS 2.8 present. [ 0.000000] DMI: Smdbmds KVM, BIOS seabios-1.9.1-qemu-project.org 04/01/2014 [ 0.000000] Hypervisor detected: KVM [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved [ 0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable [ 0.000000] e820: last_pfn = 0x7ffdc max_arch_pfn = 0x400000000 :