There's more...

Another method is to store the kernel log messages and kernel panics or oops into persistent storage. The Linux kernel's persistent store support (CONFIG_PSTORE) allows you to log in to the persistent memory kept across reboots.

To log panic and oops messages into persistent memory, we need to configure the kernel with the CONFIG_PSTORE_RAM configuration variable, and to log kernel messages, we need to configure the kernel with CONFIG_PSTORE_CONSOLE.

We then need to configure the location of the persistent storage on an unused memory location, but keep the last 1 MB of memory free:

  1. For example, we could pass the following kernel command-line arguments to reserve a 128 KB region starting at 0x30000000:
ramoops.mem_address=0x30000000 ramoops.mem_size=0x200000  
  1. We would then mount the persistent storage by adding it to /etc/fstab so that it is available on the next boot as well:
/etc/fstab:
pstore  /pstore  pstore  defaults  0  0  
  1. We then mount it as follows:
# mkdir /pstore
# mount /pstore 
  1. Next, we force a reboot with the magic SysRq key:
# echo b > /proc/sysrq-trigger  
  1. On reboot, we will see a file inside /pstore:
-r--r--r--  1 root root 4084 Sep 16 16:24 console-ramoops  
  1. This will have contents such as the following:
SysRq : Resetting
CPU3: stopping
CPU: 3 PID: 0 Comm: swapper/3 Not tainted 3.14.0-rc4-1.0.0-wandboard-37774-g1eae
[<80014a30>] (unwind_backtrace) from [<800116cc>] (show_stack+0x10/0x14)
[<800116cc>] (show_stack) from [<806091f4>] (dump_stack+0x7c/0xbc)
[<806091f4>] (dump_stack) from [<80013990>] (handle_IPI+0x144/0x158)
[<80013990>] (handle_IPI) from [<800085c4>] (gic_handle_irq+0x58/0x5c)
[<800085c4>] (gic_handle_irq) from [<80012200>] (__irq_svc+0x40/0x70)
Exception stack(0xee4c1f50 to 0xee4c1f98)  
  1. We should move it out of /pstore or remove it completely so that it doesn't occupy memory.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset