The OpenRC init script for kexec has a few issues. For instance, if INITRD is specified kexec will fail to stop (as $initrd is assigned the value ${BOOTPATH}/${INITRD}, and load_image fails is ${initrd} != ${INITRD}). There are a couple of syntactical issues [ -n ${DONT_MOUNT_BOOT} ] is always true, so mount_boot always returns 1 and never mounts /boot (if present), so kernel image and initrd are not found. Reproducible: Always Steps to Reproduce: 1. Have a separate /boot partition 2. Install and configure kexec-tools-2.0.4-r1 3. Specify an INITRD in /etc/conf.d/kexec Actual Results: kexec fails to stop, resulting in a regular reboot (via BIOS and bootloader) Expected Results: kexec succeeds in stopping, resulting in a fast reboot (bypassing BIOS and bootloader) I updated /etc/init.d/kexec as follows to get things working again: --- 1/kexec 2013-08-17 21:44:08.000000000 -0400 +++ 2/kexec 2013-08-17 21:42:57.000000000 -0400 @@ -26,8 +26,13 @@ initrd_path() { local x= kver=$(uname -r) karch=$(uname -m) BOOTPART="${BOOTPART:-/boot}" - for x in "${INITRD:-initrd}" \ - initrd.img-${kver} initrd-${kver}.img \ + + if [ -e "${INITRD:-initrd}" ]; then + echo "${INITRD:-initrd}" + return 0 + fi + + for x in initrd.img-${kver} initrd-${kver}.img \ initrd-${kver} initramfs-${kver}.img \ initramfs-genkernel-${karch}-${kver} ; do if [ -e "${BOOTPART}/${x}" ]; then @@ -42,7 +47,7 @@ mount_boot(){ local ret - [ -n ${DONT_MOUNT_BOOT} ] && return 1 + [ -n "${DONT_MOUNT_BOOT}" ] && return 1 grep -q " ${BOOTPART:-/boot} " /proc/mounts && return 1 BOOTPART="${BOOTPART:-/boot}" @@ -95,7 +100,7 @@ [ -n "${initrd}" ] && [ -e "${initrd}" ] && initrdopt="--initrd=${initrd}" local msg= - [ -n ${initrd} ] && \ + [ -n "${initrd}" ] && \ msg="with ${initrd}" einfo "Using kernel image ${img} ${msg} for kexec"
As an alternative to spltting the "for" in initrd_path to an "if" and a "for" the following from load_image: if [ -n "${INITRD}" ] && \ ! [ "${INITRD}" = "${initrd}" ]; then could be changed to: if [ -n "${INITRD}" ] && \ ! [ "${BOOTPART:-/boot}"/"${INITRD}" = "${initrd}" ]; then provided the path to initrd is removed from /etc/conf.d/kexec...
Thanks for all the patches. I will look into that
Created attachment 356552 [details, diff] Updated patch This patch also addresses warnings at boot time by mounting /boot (if present) before testing for existence of kernel image, and unmounts /boot if the init script needed to mount it to find the kernel. This may introduce issues if run in parallel with other scripts that need to access /boot (are there any?), though removes potentially misleading warnings.
/etc/init.d/kexec doesn't detect an initrd image during startup. Steps to Reproduce: 1. Compile a new devel kernel gentoo-sources-3.10.10 against a current kernel with older version (gentoo-sources-3.8.12 for example) via genkernel. #ls -lh /boot/kernel-genkernel-x86_64-3.10.10-gentoo -rw-r--r-- 1 root root 2.7M Sep 4 14:26 /boot/kernel-genkernel-x86_64-3.10.10-gentoo #ls -lh /boot/initramfs-genkernel-x86_64-3.10.10-gentoo -rw-r--r-- 1 root root 2.6M Sep 4 14:28 /boot/initramfs-genkernel-x86_64-3.10.10-gentoo 2. Edit the following lines in /etc/conf.d/kexec LOAD_DURING_SHUTDOWN="no" KNAME="kernel-genkernel-x86_64-3.10.10-gentoo" INITRD="/boot/initramfs-genkernel-x86_64-3.10.10-gentoo" 3. Start kexec /etc/init.d/kexec start /etc/init.d/kexec start * Configuring kexec ... * Requested initrd: /boot/initramfs-genkernel-x86_64-3.10.10-gentoo * could not be found [ !! ] * ERROR: kexec failed to start Comment "return 1" in /etc/init.d/kexec line 87 if [ -n "${INITRD}" ] && \ ! [ "${INITRD}" = "${initrd}" ]; then eerror "Requested initrd: ${INITRD}" eerror "could not be found" # return 1 fi Start kexec again #/etc/init.d/kexec start * Caching service dependencies ... [ ok ] * Configuring kexec ... * Requested initrd: /boot/initramfs-genkernel-x86_64-3.10.10-gentoo * could not be found * Using kernel image /boot/kernel-genkernel-x86_64-3.10.10-gentoo with /boot//boot/initramfs-genkernel-x86_64-3.10.10-gentoo for kexec * Setting kexec with --reuse-cmdline -l /boot/kernel-genkernel-x86_64-3.10.10-gentoo root=/dev/sda2 --initrd=/boot//boot/initramfs-genkernel-x86_64-3.10.10-gentoo ...
+*kexec-tools-2.0.4-r2 (21 Sep 2013) + + 21 Sep 2013; Justin Lecher <jlec@gentoo.org> +kexec-tools-2.0.4-r2.ebuild, + kexec-tools-9999.ebuild, -files/kexec.conf-2.0.3, -files/kexec.init-2.0.3, + +files/kexec.init-2.0.4-r2, +files/kexec.conf-9999, +files/kexec.init-9999, + files/kexec.conf, -files/kexec.init, -files/kexec.init-ng, + +files/kexec.service: + Add support for systemd, #478072; Fix issues with openrc init scripts, + #481506; thanks BobbyK for the patches + I applied your patches but also now test INITRD and KNAME directly and/or strip BOOTPART from them. PLease test if that works.
*** Bug 486118 has been marked as a duplicate of this bug. ***