1. dmesg命令简介
本文主要介绍在Linux系统上如何使用dmesg工具集查看服务器硬件信息。dmesg命令是Linux上查询硬件信息的常用工具之一。
安装dmesg工具,以CentOS为例:
[root@zcwyou ~]# yum -y install util-linux
2. 查看硬件的详细信息
命令:
[root@zcwyou ~]# dmesg |more
部分输出结果如下:
[ 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.11.6.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Tue Aug 14 21:49:04 UTC 2018
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-862.11.6.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_U
S.UTF-8
[ 0.000000] e820: BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009dfff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000cf378fff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000cf379000-0x00000000cf38efff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000cf38f000-0x00000000cf3cdfff] ACPI data
[ 0.000000] BIOS-e820: [mem 0x00000000cf3ce000-0x00000000cfffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000e0000000-0x00000000efffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fe000000-0x00000000ffffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000082fffffff] usable
[ 0.000000] NX (Execute Disable) protection: active
linux使用dmesg查看硬件的详细信息
3. 查看前面15行信息
命令:
[root@zcwyou ~]# dmesg |head -15
输出结果:
[ 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.11.6.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Tue Aug 14 21:49:04 UTC 2018
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-862.11.6.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_US.UTF-8
[ 0.000000] e820: BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009dfff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000cf378fff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000cf379000-0x00000000cf38efff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000cf38f000-0x00000000cf3cdfff] ACPI data
[ 0.000000] BIOS-e820: [mem 0x00000000cf3ce000-0x00000000cfffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000e0000000-0x00000000efffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fe000000-0x00000000ffffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000082fffffff] usable
[ 0.000000] NX (Execute Disable) protection: active
linux使用dmesg命令输出的前15行
4. 查看与USB有关的信息
命令:
[root@zcwyou ~]# dmesg | grep -i usb
输出结果:
[ 0.428134] ACPI: bus type USB registered
[ 0.428152] usbcore: registered new interface driver usbfs
[ 0.428161] usbcore: registered new interface driver hub
[ 0.428191] usbcore: registered new device driver usb
[ 1.046066] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 1.046380] ehci-pci 0000:00:1a.7: new USB bus registered, assigned bus number 1
[ 1.055679] ehci-pci 0000:00:1a.7: USB 2.0 started, EHCI 1.00
[ 1.055732] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 1.055734] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1.055737] usb usb1: Product: EHCI Host Controller
[ 1.055739] usb usb1: Manufacturer: Linux 3.10.0-862.11.6.el7.x86_64 ehci_hcd
linux使用dmesg命令查看USB信息
5. 查看与DMA有关的信息
[root@zcwyou ~]# dmesg | grep -i dma
[ 0.000000] ACPI: DMAR 00000000cf3b3668 001C0 (v01 DELL PE_SC3 00000001 DELL 00000001)
[ 0.000000] DMA [mem 0x00001000-0x00ffffff][ 0.000000] DMA32 [mem 0x01000000-0xffffffff][ 0.000000] DMA zone: 64 pages used for memmap
[ 0.000000] DMA zone: 21 pages reserved
[ 0.000000] DMA zone: 3997 pages, LIFO batch:0
[ 0.000000] DMA32 zone: 13198 pages used for memmap
[ 0.000000] DMA32 zone: 844665 pages, LIFO batch:31
[ 0.044071] DMAR-IR: This system BIOS has enabled interrupt remapping
[ 0.972056] DMAR: Host address width 40
[ 0.972060] DMAR: DRHD base: 0x000000fed90000 flags: 0x1
[ 0.972076] DMAR: dmar0: reg_base_addr fed90000 ver 1:0 cap c90780106f0462 ecap f020fe
[ 0.972078] DMAR: RMRR base: 0x000000cf4c8000 end: 0x000000cf4dffff
[ 0.972080] DMAR: RMRR base: 0x000000cf4b1000 end: 0x000000cf4bffff
[ 0.972081] DMAR: RMRR base: 0x000000cf4a1000 end: 0x000000cf4a1fff
[ 0.972083] DMAR: RMRR base: 0x000000cf4a3000 end: 0x000000cf4a3fff
[ 0.972084] DMAR: RMRR base: 0x000000cf4a5000 end: 0x000000cf4a5fff
[ 0.972085] DMAR: RMRR base: 0x000000cf4a7000 end: 0x000000cf4a7fff
[ 0.972087] DMAR: RMRR base: 0x000000cf4a9000 end: 0x000000cf4a9fff
[ 0.972088] DMAR: RMRR base: 0x000000cf4c0000 end: 0x000000cf4c0fff
[ 0.972090] DMAR: RMRR base: 0x000000cf4c2000 end: 0x000000cf4c2fff
[ 0.972091] DMAR: ATSR flags: 0x0
[ 0.972129] PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
[ 1.432149][TTM] Zone dma32: Available graphics memory: 2097152 kiB
[ 1.432154][TTM] Initializing DMA pool allocator
[ 1.529806] ata1: SATA max UDMA/133 cmd 0xd8e0 ctl 0xd8d0 bmdma 0xdc00 irq 23
[ 1.529813] ata2: SATA max UDMA/133 cmd 0xd8e8 ctl 0xd8d4 bmdma 0xdc08 irq 23
[ 1.681686] ata3: SATA max UDMA/133 cmd 0xd8f0 ctl 0xd8d8 bmdma 0xdc20 irq 22
[ 1.681689] ata4: SATA max UDMA/133 cmd 0xd8f8 ctl 0xd8dc bmdma 0xdc28 irq 22
5. 查看与内存有关的信息
命令:
[root@zcwyou ~]# dmesg | grep -i memory
输出结果:
[ 0.000000] Base memory trampoline at [ffff8e6580098000] 98000 size 24576
[ 0.000000] Reserving 162MB of memory at 688MB for crashkernel (System RAM: 32755MB)
[ 0.000000] Early memory node ranges
[ 0.000000] PM: Registered nosave memory: [mem 0x0009e000-0x000fffff][ 0.000000] PM: Registered nosave memory: [mem 0xcf379000-0xcf38efff][ 0.000000] PM: Registered nosave memory: [mem 0xcf38f000-0xcf3cdfff][ 0.000000] PM: Registered nosave memory: [mem 0xcf3ce000-0xcfffffff][ 0.000000] PM: Registered nosave memory: [mem 0xd0000000-0xdfffffff][ 0.000000] PM: Registered nosave memory: [mem 0xe0000000-0xefffffff][ 0.000000] PM: Registered nosave memory: [mem 0xf0000000-0xfdffffff][ 0.000000] PM: Registered nosave memory: [mem 0xfe000000-0xffffffff][ 0.000000] Memory: 5239464k/34340864k available (7348k kernel code, 799656k absent, 800680k reserved, 6281k data, 1836k init)
[ 0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[ 0.013720] Initializing cgroup subsys memory
[ 0.968797] Freeing initrd memory: 20796k freed
[ 1.045694] Non-volatile memory driver v1.3
[ 1.045834] crash memory driver: version 1.1
[ 1.080076] memory memory118: hash matches
[ 1.081410] Freeing unused kernel memory: 1836k freed
[ 1.084219] Freeing unused kernel memory: 832k freed
[ 1.086287] Freeing unused kernel memory: 676k freed
[ 1.432146][TTM] Zone kernel: Available graphics memory: 16382346 kiB
[ 1.432149][TTM] Zone dma32: Available graphics memory: 2097152 kiB
[ 23.543146] EDAC i7core: Driver loaded, 1 memory controller(s) found.
linux使用dmesg命令查看内存有关的信息
6. 查看与CPU有关的信息
命令:
[root@zcwyou ~]# dmesg | grep -i cpu
输出结果:
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] smpboot: Allowing 32 CPUs, 24 hotplug CPUs
[ 0.000000] setup_percpu: NR_CPUS:5120 nr_cpumask_bits:32 nr_cpu_ids:32 nr_node_ids:1
[ 0.000000] PERCPU: Embedded 35 pages/cpu @ffff8e6d8ee00000 s104920 r8192 d30248 u262144
[ 0.000000] pcpu-alloc: s104920 r8192 d30248 u262144 alloc=1*2097152
[ 0.000000] pcpu-alloc: [0] 00 01 02 03 04 05 06 07 [0] 08 09 10 11 12 13 14 15
[ 0.000000] pcpu-alloc: [0] 16 17 18 19 20 21 22 23 [0] 24 25 26 27 28 29 30 31
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=32, Nodes=1
[ 0.000000] RCU restricting CPUs from NR_CPUS=5120 to nr_cpu_ids=32.
[ 0.013773] mce: CPU supports 9 MCE banks
[ 0.013780] CPU0: Thermal monitoring enabled (TM1)
[ 0.044038] smpboot: CPU 0 Converting physical 1 to logical package 0
[ 0.054625] smpboot: CPU0: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz (fam: 06, model: 2c, stepping: 02)
linux使用dmesg命令查看CPU信息
7. 查看与网卡有关的信息
命令:
[root@zcwyou ~]# dmesg | grep -i nic
输出的结果:
[ 33.487156] bnx2 0000:01:00.1 em2: NIC Copper Link is Up, 1000 Mbps full duplex
[ 34.122938] bnx2 0000:01:00.0 em1: NIC Copper Link is Up, 1000 Mbps full duplex
[ 46.657807] virbr0: port 1(virbr0-nic) entered blocking state
[ 46.657812] virbr0: port 1(virbr0-nic) entered disabled state
[ 46.657902] device virbr0-nic entered promiscuous mode
[ 46.863299] virbr0: port 1(virbr0-nic) entered blocking state
[ 46.863306] virbr0: port 1(virbr0-nic) entered listening state
[ 46.980328] virbr0: port 1(virbr0-nic) entered disabled state
利用dmesg命令查询各种硬件的配置。
linux使用dmesg命令查看网卡信息