set up kernel crashkernel for osbuild in kernel hook
osbuild is a tool to build OS images. It uses bwrap to install packages inside a sandbox/container. Since the kernel package recommends kexec-tools which in turn recommends grubby, the installation order would be grubby -> kexec-tools -> kernel. So we can use the kernel hook 92-crashkernel.install provided by kexec-tools to set up kernel crashkernel for the target OS image. But in osbuild's case, there is no current running kernel and running `uname -r` in the container/sandbox actually returns the host kernel release. To set up kernel crashkernel for the OS image built by osbuild, a different logic is needed. We will check if kernel hook is running inside the osbuild container then set up kernel crashkernel only if osbuild hasn't specified a custome value. osbuild exposes [1] the container=bwrap-osbuild environment variable. According to [2], the environment variable is not inherited down the process tree, so we need to check /proc/1/environ to detect this environment variable to tell if the kernel hook is running inside a bwrap-osbuild container. After that we need to know if osbuild wants to use custom crashkernel value. This is done by checking if /etc/kernel/cmdline has crashkernel set [3]. /etc/kernel/cmdline is written before packages are installed. [1] https://github.com/osbuild/osbuild/pull/926 [2] https://systemd.io/CONTAINER_INTERFACE/ [3] https://bugzilla.redhat.com/show_bug.cgi?id=2024976#c5 Reviewed-by: Pingfan Liu <piliu@redhat.com> Reviewed-by: Philipp Rudo <prudo@redhat.com> Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
parent
5e8c751c39
commit
ddd428a1d0
10
kdumpctl
10
kdumpctl
@ -1576,6 +1576,11 @@ reset_crashkernel_after_update()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_is_osbuild()
|
||||||
|
{
|
||||||
|
[[ $(sed -n -E 's/.*(^|\s)container=(\S*).*/\2/p' < /proc/1/environ) == bwrap-osbuild ]]
|
||||||
|
}
|
||||||
|
|
||||||
reset_crashkernel_for_installed_kernel()
|
reset_crashkernel_for_installed_kernel()
|
||||||
{
|
{
|
||||||
local _installed_kernel _running_kernel _crashkernel _crashkernel_running
|
local _installed_kernel _running_kernel _crashkernel _crashkernel_running
|
||||||
@ -1585,6 +1590,11 @@ reset_crashkernel_for_installed_kernel()
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if _is_osbuild && ! grep -q crashkernel= /etc/kernel/cmdline; then
|
||||||
|
reset_crashkernel "--kernel=$_installed_kernel"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if ! _running_kernel=$(_get_current_running_kernel_path); then
|
if ! _running_kernel=$(_get_current_running_kernel_path); then
|
||||||
derror "Couldn't find current running kernel"
|
derror "Couldn't find current running kernel"
|
||||||
exit
|
exit
|
||||||
|
Loading…
Reference in New Issue
Block a user