| 1 | |
| 2 |
|
| 3 | Debugging Kernel Shutdown Hangs with pstore
|
| 4 | +++++++++++++++++++++++++++++++++++++++++++
|
| 5 |
|
| 6 | Overview
|
| 7 | ========
|
| 8 | If the system hangs while shutting down, the kernel logs may need to be
|
| 9 | retrieved to debug the issue.
|
| 10 |
|
| 11 | On systems that have a UART available, it is best to configure the kernel to use
|
| 12 | this UART for kernel console output.
|
| 13 |
|
| 14 | If a UART isn't available, the ``pstore`` subsystem provides a mechanism to
|
| 15 | persist this data across a system reset, allowing it to be retrieved on the next
|
| 16 | boot.
|
| 17 |
|
| 18 | Kernel Configuration
|
| 19 | ====================
|
| 20 | To enable ``pstore`` and enable saving kernel ring buffer logs, set the
|
| 21 | following kernel configuration options:
|
| 22 |
|
| 23 | * ``CONFIG_PSTORE=y``
|
| 24 | * ``CONFIG_PSTORE_CONSOLE=y``
|
| 25 |
|
| 26 | Additionally, enable a backend to store the data. Depending upon your platform
|
| 27 | some potential options include:
|
| 28 |
|
| 29 | * ``CONFIG_EFI_VARS_PSTORE=y``
|
| 30 | * ``CONFIG_PSTORE_RAM=y``
|
| 31 | * ``CONFIG_CHROMEOS_PSTORE=y``
|
| 32 | * ``CONFIG_PSTORE_BLK=y``
|
| 33 |
|
| 34 | Kernel Command-line Parameters
|
| 35 | ==============================
|
| 36 | Add these parameters to your kernel command line:
|
| 37 |
|
| 38 | * ``printk.always_kmsg_dump=Y``
|
| 39 | * Forces the kernel to dump the entire message buffer to pstore during
|
| 40 | shutdown
|
| 41 | * ``efi_pstore.pstore_disable=N``
|
| 42 | * For EFI-based systems, ensures the EFI backend is active
|
| 43 |
|
| 44 | Userspace Interaction and Log Retrieval
|
| 45 | =======================================
|
| 46 | On the next boot after a hang, pstore logs will be available in the pstore
|
| 47 | filesystem (``/sys/fs/pstore``) and can be retrieved by userspace.
|
| 48 |
|
| 49 | On systemd systems, the ``systemd-pstore`` service will help do the following:
|
| 50 |
|
| 51 | #. Locate pstore data in ``/sys/fs/pstore``
|
| 52 | #. Read and save it to ``/var/lib/systemd/pstore``
|
| 53 | #. Clear pstore data for the next event
|