如何在 Ubuntu 18.04 上启用 pstore 以应对内核恐慌?

如何在 Ubuntu 18.04 上启用 pstore 以应对内核恐慌?

我拥有的:

  • 带有 HWE 5.4.0-136 内核的 Ubuntu 18.04 服务器

  • systemd-237(无systemd-pstore服务)。

  • /sys/module/pstore/parameters/backend包含(null)

  • pstore自动安装到/sys/fs/pstore

  • EFI 相关信息dmesg | grep -i efi

    ACPI: UEFI 0x000000003B55B7B8 000048 (v01 ALASKA A M I    00000002      01000013)
    ACPI: Reserving UEFI table memory at [mem 0x3b55b7b8-0x3b55b7ff]
    
  • Pstore 相关的变量/boot/config

    CONFIG_EFI_VARS_PSTORE=m
    # CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE is not set
    CONFIG_CHROMEOS_PSTORE=m
    CONFIG_PSTORE=y
    CONFIG_PSTORE_DEFLATE_COMPRESS=y
    # CONFIG_PSTORE_LZO_COMPRESS is not set
    # CONFIG_PSTORE_LZ4_COMPRESS is not set
    # CONFIG_PSTORE_LZ4HC_COMPRESS is not set
    # CONFIG_PSTORE_842_COMPRESS is not set
    # CONFIG_PSTORE_ZSTD_COMPRESS is not set
    CONFIG_PSTORE_COMPRESS=y
    CONFIG_PSTORE_DEFLATE_COMPRESS_DEFAULT=y
    CONFIG_PSTORE_COMPRESS_DEFAULT="deflate"
    # CONFIG_PSTORE_CONSOLE is not set
    # CONFIG_PSTORE_PMSG is not set
    # CONFIG_PSTORE_FTRACE is not set
    CONFIG_PSTORE_RAM=m
    

我想要的是:

  • 内核崩溃后访问 dmesg。

我做了什么:

  • vi /etc/default/grub

    GRUB_CMDLINE_LINUX="pstore.backend=efi efi_pstore.pstore_disable=0"
    
  • update-grub

  • vi /etc/sysctl.d/KernelPanic.conf

    kernel.panic=30
    
  • vi /etc/modules-load.d/KernelPanic.conf

    efi_pstore
    ramoops
    

重启后:

  • lsmod报告模块已加载,但没有消息dmesg
  • /sys/module/pstore/parameters/backend包含efi
  • dmesg | grep -i pstore仅显示内核命令行

引发恐慌:

echo 65535 > /proc/sys/kernel/sysrq
sync
echo c > /proc/sysrq-trigger

重启后:

  • /sys/fs/pstore是空的——为什么?

相关内容