Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make KEXEC_INITRD optional. #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions Linux/tree-common/init
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,10 @@ if [ "$(get_any is_in_kexec no)" = "yes" ]; then
esuccess "Running in a kexec"
export NO_SIGNAL_STATE=1
else
if [ "$(get_any KEXEC_KERNEL 'default')" != "default" -a "$(get_any KEXEC_INITRD 'default')" != "default" ]; then
if [ "$(get_any KEXEC_KERNEL 'default')" != "default" ]; then
KEXEC_KERNEL="$(get_any KEXEC_KERNEL default)"
KEXEC_INITRD="$(get_any KEXEC_INITRD default)"
# do not use default initrd
KEXEC_INITRD="$(get_any KEXEC_INITRD)"
KEXEC_APPEND="$(get_any KEXEC_APPEND '')"
esuccess "kexec: kernel=${KEXEC_KERNEL} initrd=${KEXEC_INITRD} append='${KEXEC_APPEND}'"

Expand All @@ -297,22 +298,26 @@ else
wget ${KEXEC_KERNEL} -O /boot/kernel
fi
fi
if [ -f "${rootmnt}/${KEXEC_INITRD}" ]; then
cp "${rootmnt}/${KEXEC_INITRD}" /boot/initrd
else
wget ${KEXEC_INITRD} -O /boot/initrd
# if initrd was given
if [ -n "${KEXEC_INITRD}" ]; then
if [ -f "${rootmnt}/${KEXEC_INITRD}" ]; then
cp "${rootmnt}/${KEXEC_INITRD}" /boot/initrd
else
wget ${KEXEC_INITRD} -O /boot/initrd
fi
fi

# run kexec
if [ -f /boot/kernel ]; then
if [ -f /boot/initrd ]; then
# detach nbd devices
detach_nbd_devices

# kexec
kexec -l /boot/kernel --initrd=/boot/initrd --append="$(cat /proc/cmdline) is_in_kexec=yes ${KEXEC_APPEND}" -f
if [ -f /boot/initrd ]; then
# kexec
kexec -l /boot/kernel --initrd=/boot/initrd --append="$(cat /proc/cmdline) is_in_kexec=yes ${KEXEC_APPEND}" -f
else
ewarn "kexec: initrd not found"
# do not include initrd in kexec
# kexec
kexec -l /boot/kernel --append="$(cat /proc/cmdline) is_in_kexec=yes ${KEXEC_APPEND}" -f
fi
else
ewarn "kexec: kernel not found"
Expand Down