db7d74
Introduction
db7d74
============
db7d74
db7d74
This document describes features the kexec-tools package provides for setting
db7d74
and estimating the crashkernel value.
db7d74
db7d74
Kdump lives in a pre-reserved chunk of memory, and the size of the reserved
db7d74
memory is specified by the `crashkernel=` kernel parameter. It's hard to
db7d74
estimate an accurate `crashkernel=` value, so it's always recommended to test
db7d74
kdump after you updated the `crashkernel=` value or changed the dump target.
db7d74
db7d74
db7d74
Default crashkernel value
db7d74
=========================
db7d74
41d07d
Latest kernel packages include a `crashkernel.default` file installed in kernel
db7d74
modules folder, available as:
db7d74
db7d74
	/usr/lib/modules/<kernel>/crashkernel.default
db7d74
db7d74
The content of the file will be taken as the default value of 'crashkernel=', or
db7d74
take this file as a reference for setting crashkernel value manually.
db7d74
db7d74
db7d74
New installed system
db7d74
====================
db7d74
41d07d
Anaconda is the OS installer which sets all the kernel boot cmdline on a newly
41d07d
installed system. If kdump is enabled during Anaconda installation, Anaconda
db7d74
will use the `crashkernel.default` file as the default `crashkernel=` value on
41d07d
the newly installed system.
db7d74
41d07d
Users can override the value during Anaconda installation manually.
db7d74
db7d74
db7d74
Auto update of crashkernel boot parameter
db7d74
=========================================
db7d74
db7d74
Following context in this section assumes all kernel packages have a
db7d74
`crashkernel.default` file bundled, which is true for the latest official kernel
db7d74
packages. For kexec-tools behavior with a kernel that doesn't have a
db7d74
`crashkernel.default` file, please refer to the “Custom Kernel” section of this
db7d74
doc.
db7d74
db7d74
When `crashkernel=` is using the default value, kexec-tools will need to update
db7d74
the `crashkernel=` value of new installed kernels, since the default value may
db7d74
change in new kernel packages.
db7d74
db7d74
kexec-tools does so by adding a kernel installation hook, which gets triggered
db7d74
every time a new kernel is installed, so kexec-tools can do necessary checks and
db7d74
updates.
db7d74
db7d74
db7d74
Supported Bootloaders
db7d74
---------------------
db7d74
db7d74
This auto update only works with GRUB2 and ZIPL, as kexec-tools heavily depends
db7d74
on `grubby`. If other boot loaders are used, the user will have to update the
db7d74
`crashkernel=` value manually.
db7d74
db7d74
db7d74
Updating kernel package
db7d74
-----------------------
db7d74
db7d74
When a new version of package kernel is released in the official repository, the
db7d74
package will always come with a `crashkernel.default` file bundled. Kexec-tools
db7d74
will act with following rules:
db7d74
db7d74
If current boot kernel is using the default `crashkernel=` boot param value from
db7d74
its `crashkernel.default` file, then kexec-tools will update new installed
db7d74
kernel’s `crashkernel=` boot param using the value from the new installed
db7d74
kernel’s `crashkernel.default` file. This ensures `crashkernel=` is always using
db7d74
the latest default value.
db7d74
db7d74
If current boot kernel's `crashkernel=` value is set to a non-default value, the
db7d74
new installed kernel simply inherits this value.
db7d74
db7d74
On systems using GRUB2 as the bootloader, each kernel has its own boot entry,
db7d74
making it possible to set different `crashkernel=` boot param values for
db7d74
different kernels. So kexec-tools won’t touch any already installed kernel's
db7d74
boot param, only new installed kernel's `crashkernel=` boot param value will be
db7d74
updated.
db7d74
db7d74
But some utilities like `grub2-mkconfig` and `grubby` can override all boot
db7d74
entry's boot params with the boot params value from the GRUB config file
db7d74
`/etc/defaults/grub`, so kexec-tools will also update the GRUB config file in
db7d74
case old `crashkernel=` value overrides new installed kernel’s boot param.
db7d74
db7d74
db7d74
Downgrading kernel package
db7d74
--------------------------
db7d74
db7d74
When upgrading a kernel package, kexec-tools may update the `crashkernel=` value
db7d74
in GRUB2 config file to the new value. So when downgrading the kernel package,
db7d74
kexec-tools will also try to revert that update by setting GRUB2 config file’s
db7d74
`crashkernel=` value back to the default value in the older kernel package. This
db7d74
will only occur when the GRUB2 config file is using the default `crashkernel=`
db7d74
value.
db7d74
db7d74
db7d74
Custom kernel
db7d74
=============
db7d74
db7d74
To make auto crashkernel update more robust, kexec-tools will try to keep
db7d74
tracking the default 'crashkernel=` value with kernels that don’t have a
db7d74
`crashkernel.default` file, such kernels are referred to as “custom kernel” in
db7d74
this doc. This is only a best-effort support to make it easier debugging and
db7d74
testing the system.
db7d74
db7d74
When installing a custom kernel that doesn’t have a `crashkernel.default` file,
db7d74
the `crashkernel=` value will be simply inherited from the current boot kernel.
db7d74
db7d74
When installing a new official kernel package and current boot kernel is a
db7d74
custom kernel, since the boot kernel doesn’t have a `crashkernel.default` file,
db7d74
kexec-tools will iterate installed kernels and check if the boot kernel
db7d74
inherited the default value from any other existing kernels’
db7d74
`crashkernel.default` file. If a matching `crashkernel.default` file is found,
db7d74
kexec-tools will update the new installed kernel `crashkernel=` boot param using
db7d74
the value from the new installed kernel’s `crashkernel.default` file, ensures
db7d74
the auto crashkernel value update won’t break over one or two custom kernel
db7d74
installations.
db7d74
db7d74
It is possible that the auto crashkernel value update will fail when custom
db7d74
kernels are used. One example is a custom kernel inheriting the default
db7d74
`crashkernel=` value from an older official kernel package, but later that
db7d74
kernel package is uninstalled. So when booted with the custom kernel,
db7d74
kexec-tools can't determine if the boot kernel is inheriting a default
db7d74
`crashkernel=` value from any official build. In such a case, please refer to
db7d74
the "Reset crashkernel to default value" section of this doc.
db7d74
db7d74
db7d74
Reset crashkernel to default value
db7d74
==================================
db7d74
db7d74
kexec-tools only perform the auto update of crashkernel value when it can
db7d74
confirm the boot kernel's crashkernel value is using its corresponding default
db7d74
value or inherited from any installed kernel.
db7d74
db7d74
kexec-tools may fail to determine if the boot kernel is using default
db7d74
crashkernel value in some use cases:
db7d74
- kexec-tools package is absent during a kernel package upgrade, and the new
db7d74
  kernel package’s `crashkernel.default` value has changed.
db7d74
- Custom kernel is used and the kernel it inherits `crashkernel=`  value from is
db7d74
  uninstalled.
db7d74
db7d74
So it's recommended to reset the crashkernel value if users have uninstalled
db7d74
kexec-tools or using a custom kernel.
db7d74
db7d74
Reset using kdumpctl
db7d74
--------------------
db7d74
db7d74
To make it easier to reset the `crashkernel=` kernel cmdline to this default
db7d74
value properly, `kdumpctl` also provides a sub-command:
db7d74
db7d74
	`kdumpctl reset-crashkernel [<kernel version>]`
db7d74
db7d74
This command will read from the `crashkernel.default` file and reset
db7d74
bootloader's kernel cmdline to the default value. It will also update bootloader
db7d74
config if the bootloader has a standalone config file. User will have to reboot
db7d74
the machine after this command to make it take effect.
db7d74
db7d74
Reset manually
db7d74
--------------
db7d74
db7d74
To reset the crashkernel value manually, it's recommended to use utils like
db7d74
`grubby`. A one liner script for resetting `crashkernel=` value of all installed
db7d74
kernels to current boot kernel's  crashkernel.default` is:
db7d74
db7d74
	grubby --update-kernel ALL --args "$(cat /usr/lib/modules/$(uname -r)/crashkernel.default)"
db7d74
db7d74
Estimate crashkernel
db7d74
====================
db7d74
db7d74
The best way to estimate a usable crashkernel value is by testing kdump
db7d74
manually.  And you can set crashkernel to a large value, then adjust the
db7d74
crashkernel value to an acceptable value gradually.
db7d74
db7d74
`kdumpctl` also provides a sub-command for doing rough estimating without
db7d74
triggering kdump:
db7d74
db7d74
	`kdumpctl estimate`
db7d74
db7d74
The output will be like this:
db7d74
db7d74
```
db7d74
      Encrypted kdump target requires extra memory, assuming using the keyslot with minimun memory requirement
db7d74
db7d74
      Reserved crashkernel:    256M
db7d74
      Recommended crashkernel: 655M
db7d74
db7d74
      Kernel image size:   47M
db7d74
      Kernel modules size: 12M
db7d74
      Initramfs size:      19M
db7d74
      Runtime reservation: 64M
db7d74
      LUKS required size:  512M
db7d74
      Large modules:
db7d74
          xfs: 1892352
db7d74
          nouveau: 2318336
db7d74
      WARNING: Current crashkernel size is lower than recommended size 655M.
db7d74
```
db7d74
db7d74
It will generate a summary report about the estimated memory consumption
db7d74
of each component of kdump. The value may not be accurate enough, but
db7d74
would be a good start for finding a suitable crashkernel value.