Debugging dei crash del kernel con kdump

Introduzione

Kdump è un servizio che crea dump di crash in caso di crash del kernel. Utilizza [kexec(8)](https://www.mankier.com/8/kexec) per avviare un kernel secondario (noto come capture kernel) e quindi esporta i contenuti della memoria del kernel (noti come crash dump o vmcore) nel filesystem. I contenuti di vmcore possono quindi essere analizzati per identificare la causa del crash del kernel.

Per configurare kdump, è necessario impostare l’argomento del kernel crashkernel e abilitare il servizio systemd kdump. Bisogna riservare memoria per il crash kernel durante l’avvio del primo kernel. L’impostazione crashkernel=auto generalmente non riserva abbastanza memoria su Fedora CoreOS, quindi è consigliato specificare crashkernel=300M.

Per impostazione predefinita, il vmcore verrà salvato in /var/crash. È anche possibile scrivere il dump in un’altra posizione sul sistema locale o inviarlo tramite rete modificando /etc/kdump.conf. Per ulteriori informazioni, consulta [kdump.conf(5)](https://www.mankier.com/5/kdump.conf) e i commenti in /etc/kdump.conf e /etc/sysconfig/kdump.

Configuring kdump via Ignition

Example kdump configuration
variant: fcos
version: 1.6.0
kernel_arguments:
  should_exist:
  - 'crashkernel=300M'
systemd:
  units:
  - name: kdump.service
    enabled: true

Configuring kdump after initial provision

  1. Set the crashkernel kernel argument

    sudo rpm-ostree kargs --append='crashkernel=300M'

    More information on how to modify kargs via rpm-ostree.

  2. Enable the kdump systemd service.

    sudo systemctl enable kdump.service
  3. Reboot your system.

    sudo systemctl reboot
It is highly recommended to test the configuration after setting up the kdump service, with extra attention to the amount of memory reserved for the crash kernel. For information on how to test that kdump is properly armed and how to analyze the dump, refer to the kdump documentation for Fedora and the Linux kernel documentation on kdump.