ブログ

カーネルのメッセージログを出力する方法

at_shiita.ishigaki
2021年11月4日 9時13分

カーネルのメッセージログを出力するにはdmesgコマンドを使用します。

[armadillo ~]# dmesg
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14-at38 (atmark@atde8) (gcc version 8.3.0 (Debian 8.3.0-2)) #1 Mon Oct 18 17:40:36 JST 2021
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Atmark Techno Armadillo-640
[    0.000000] Memory policy: Data cache writeback
[    0.000000] cma: Reserved 16 MiB at 0x9f000000
[    0.000000] On node 0 totalpages: 131072
:省略

出力のレベルを確認するには-xオプションを使用します。

[armadillo ~]# dmesg -x
kern  :info  : [    0.000000] Booting Linux on physical CPU 0x0
kern  :notice: [    0.000000] Linux version 4.14-at38 (atmark@atde8) (gcc version 8.3.0 (Debian 8.3.0-2)) #1 Mon Oct 18 17:40:36 JST 2021
kern  :info  : [    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
kern  :info  : [    0.000000] CPU: div instructions available: patching division code
kern  :info  : [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
kern  :info  : [    0.000000] OF: fdt: Machine model: Atmark Techno Armadillo-640
kern  :info  : [    0.000000] Memory policy: Data cache writeback
kern  :info  : [    0.000000] cma: Reserved 16 MiB at 0x9f000000
kern  :debug : [    0.000000] On node 0 totalpages: 131072
:省略

表示するレベルを指定するには-lオプションを使用します。
指定できるレベルは以下の通りです。

  • emerg
  • alert
  • crit
  • err
  • warn
  • notice
  • info
  • debug
[armadillo ~]# dmesg -xl notice                                              
kern  :notice: [    0.000000] Linux version 4.14-at38 (atmark@atde8) (gcc version 8.3.0 (Debian 8.3.0-2)) #1 Mon Oct 18 17:40:36 1
kern  :notice: [    0.000000] Kernel command line: root=/dev/mmcblk0p2 rootwait
kern  :notice: [    0.000000] Virtual kernel memory layout:
                                  vector  : 0xffff0000 - 0xffff1000   (   4 kB)
                                  fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
                                  vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
                                  lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
                                    .text : 0xc0008000 - 0xc0700000   (7136 kB)
                                    .init : 0xc0900000 - 0xc0c00000   (3072 kB)
                                    .data : 0xc0c00000 - 0xc0c44ae0   ( 275 kB)
                                     .bss : 0xc0c49d84 - 0xc0c86824   ( 243 kB)
kern  :notice: [    0.017312] random: get_random_u32 called from bucket_table_alloc+0x84/0x1a4 with crng_init=0
kern  :notice: [    0.077089] SCSI subsystem initialized
kern  :notice: [    0.493531] NFS: Registering the id_resolver key type
kern  :notice: [    0.493649] Key type id_resolver registered
kern  :notice: [    0.493683] Key type id_legacy registered
kern  :notice: [    2.211258] random: fast init done
kern  :notice: [    2.640374] Key type dns_resolver registered
kern  :notice: [    3.135426] random: systemd-udevd: uninitialized urandom read (16 bytes read)
kern  :notice: [    6.440741] random: systemd: uninitialized urandom read (16 bytes read)
kern  :notice: [    6.467428] random: systemd: uninitialized urandom read (16 bytes read)
kern  :notice: [    6.523143] random: systemd: uninitialized urandom read (16 bytes read)
kern  :notice: [   73.453185] random: crng init done
kern  :notice: [   73.456799] random: 6 urandom warning(s) missed due to ratelimiting