Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
crashkernel: check if crashmemory is available
If a kernel was started with crashmemory enabled, create
/node/startup-crashmemory/available.

This in turn will allow a conditional startup of the
startup-crashmemory.service.
  • Loading branch information
thomas committed Nov 2, 2021
1 parent 511d690 commit 9ace072
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crashkernel/crashkernel.service
@@ -1,5 +1,8 @@
[Unit]
Description=load crashkernel
Description=load crashkernel if enabled
Wants=startup-crashmemory.service
After=startup-crashmemory.service
ConditionPathExists=/node/startup-crashmemory/available
ConditionPathExists=/boot/bzImage.crash

[Service]
Expand Down
21 changes: 21 additions & 0 deletions crashkernel/startup-crashmemory
@@ -0,0 +1,21 @@
#! /bin/sh

# Workaround for systemd versions missing certain ConditionXY= features.
# This helper is called by startup-crashmemory.service and creates
# /node/startup-crashmemory/available
# So other services can use
# Wants=startup-crashmemory.service
# After=startup-crashmemory.service
# ConditionPathExists=/node/startup-crashmemory/available
# to start a unit only if the memory can be used
#

kexec_crash_size='0'
if [ -e /sys/kernel/kexec_crash_size ]; then
kexec_crash_size=$(cat /sys/kernel/kexec_crash_size)
fi
mkdir -p /node/startup-crashmemory
rm /node/startup-crashmemory/* 2>/dev/null
if [ "$kexec_crash_size" != "0" ] ; then
touch /node/startup-crashmemory/available
fi
6 changes: 6 additions & 0 deletions crashkernel/startup-crashmemory.service
@@ -0,0 +1,6 @@
[Unit]

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/startup-crashmemory

0 comments on commit 9ace072

Please sign in to comment.