Search Suggest

Display message or driver message - dmesg


Lệnh dmesg sẽ trace ra rất nhiều thông tin từ lúc hệ thống khởi động cho đến thời điểm hiện tại, các thông tin có thể là về kernel, device driver, ... hoặc các thành phần phần cứng.

 [ninhld@localhost docs]$ dmesg   
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 3.18.6-100.fc20.x86_64 (mockbuild@bkernel02.phx2.fedoraproject.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC) ) #1 SMP Fri Feb 6 22:55:01 UTC 2015
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.18.6-100.fc20.x86_64 root=UUID=e1f37513-df0d-4ca7-9ec4-c4c9987dbe60 ro vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8
[ 0.000000] Disabled fast string operations
[ 0.000000] e820: BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009d7ff] usable
[ 0.000000] BIOS-e820: [mem 0x000000000009d800-0x000000000009ffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000da99efff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000da99f000-0x00000000dae9efff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000dae9f000-0x00000000daf9efff] ACPI NVS
[ 0.000000] BIOS-e820: [mem 0x00000000daf9f000-0x00000000daffefff] ACPI data
[ 0.000000] BIOS-e820: [mem 0x00000000dafff000-0x00000000daffffff] usable
[ 0.000000] BIOS-e820: [mem 0x00000000db000000-0x00000000df9fffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000f8000000-0x00000000fbffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fed08000-0x00000000fed08fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fed10000-0x00000000fed19fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fed1c000-0x00000000fed1ffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000ffd20000-0x00000000ffffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000011e5fffff] usable
[ 0.000000] NX (Execute Disable) protection: active
[ 0.000000] SMBIOS 2.6 present.
[ 0.000000] DMI: LENOVO 4180AD9/4180AD9, BIOS 83ET61WW (1.31 ) 07/07/2011
[ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
...
[ 82.586529] Bluetooth: RFCOMM TTY layer initialized
[ 82.586562] Bluetooth: RFCOMM socket layer initialized
[ 82.587813] Bluetooth: RFCOMM ver 1.11
[ 96.951311] SELinux: initialized (dev proc, type proc), uses genfs_contexts
[ 98.859836] SELinux: initialized (dev proc, type proc), uses genfs_contexts



Bởi vì lệnh dmesg trace thông tin từ dưới kernel nên nó rất hữu ích trong một số trường hợp như:
+ Xem thông tin về peripheral device mới kết nối vào hệ thống
+ Debug kernel khi viết driver (khi viết driver, muốn trace thông tin thì phải dùng lệnh printk, tuy nhiên lệnh in này sẽ không trace trực tiếp ra terminal mà phải dùng lệnh dmesg mới thấy được)

Ex:
Gắn một thiết bị USB-to-COM (dùng với minicom phục vụ debug board nhúng) vào máy tính và dùng lệnh dmesg sẽ được các thông tin như dưới, cái quan trong nhất là biết được device node của thiết bị là /dev/ttyUSB0


 [ 7377.063526] usb 1-1.1: new full-speed USB device number 6 using ehci-pci  
[ 7377.149745] usb 1-1.1: New USB device found, idVendor=067b, idProduct=2303
[ 7377.149756] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 7377.149762] usb 1-1.1: Product: USB 2.0 To COM Device
[ 7377.149766] usb 1-1.1: Manufacturer: Prolific Technology Inc.
[ 7378.264479] usbcore: registered new interface driver pl2303
[ 7378.264505] usbserial: USB Serial support registered for pl2303
[ 7378.264534] pl2303 1-1.1:1.0: pl2303 converter detected
[ 7378.267971] usb 1-1.1: pl2303 converter now attached to ttyUSB0

Xem thêm tại:
+ Link 1

إرسال تعليق