summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Lecher <jlec@gentoo.org>2012-03-18 07:46:02 +0000
committerJustin Lecher <jlec@gentoo.org>2012-03-18 07:46:02 +0000
commita27c16410984458fc66a2a1a7cfcc56cef83b82b (patch)
tree61e9b1134d67f5e8d824a779757bfb31a3a507b2 /sys-apps/kexec-tools/files
parentPass -Os in TARGET_CFLAGS for efi-64 on x86. Don't clobber TARGET variables i... (diff)
downloadgentoo-2-a27c16410984458fc66a2a1a7cfcc56cef83b82b.tar.gz
gentoo-2-a27c16410984458fc66a2a1a7cfcc56cef83b82b.tar.bz2
gentoo-2-a27c16410984458fc66a2a1a7cfcc56cef83b82b.zip
Use $RC_REBOOT instead of /sbin/runlevel, #401231 thanks William Hubbs for the patch; usability enhancements including better detection of the kernel image, additional option parsing, better descriptions in the config file, #392229, thanks teika for those things; better detection of genkernel, #370207, thanks Łukasz Stelmach & Dennis Schridde for their contributions
(Portage version: 2.2.0_alpha90/cvs/Linux x86_64)
Diffstat (limited to 'sys-apps/kexec-tools/files')
-rw-r--r--sys-apps/kexec-tools/files/README.Gentoo33
-rw-r--r--sys-apps/kexec-tools/files/kexec.conf-2.0.331
-rw-r--r--sys-apps/kexec-tools/files/kexec.init-2.0.3119
3 files changed, 183 insertions, 0 deletions
diff --git a/sys-apps/kexec-tools/files/README.Gentoo b/sys-apps/kexec-tools/files/README.Gentoo
new file mode 100644
index 000000000000..ad88924cbb23
--- /dev/null
+++ b/sys-apps/kexec-tools/files/README.Gentoo
@@ -0,0 +1,33 @@
+Usage
+=====
+
+Do
+ $ man 8 kexec
+for full understanding of the underlying kexec command.
+Gentoo offers a wrapper to the bare kexec command through
+/etc/init.d/kexec.
+
+Configuration
+-------------
+
+Configuration is done in /etc/conf.d/kexec, which is self-documented.
+
+Usage
+-----
+
+In Gentoo, kexec is invoked, i.e., the new kernel will be booted when
+rebooting, by reboot (8) command or by pressing Ctrl+Alt+Del.
+
+If you want to use kexec once, just run
+ $ /etc/init.d/kexec start
+
+It'll reserve kexec call at reboot. Later on, you can reboot anytime,
+letting kexec starts another (or the same) kernel. When all is done in
+the runlevel 6 - killing processes, unmounting volumes, etc - kexec
+starts the new kernel instead of doing the normal hardware reboot.
+
+If you want kexec to be run every time you reboot, add it to a runlevel:
+ $ rc-update add kexec <runlevel>
+
+If you want to reboot in the normal way this time, do:
+ $ touch /nokexec
diff --git a/sys-apps/kexec-tools/files/kexec.conf-2.0.3 b/sys-apps/kexec-tools/files/kexec.conf-2.0.3
new file mode 100644
index 000000000000..a1d409edabc6
--- /dev/null
+++ b/sys-apps/kexec-tools/files/kexec.conf-2.0.3
@@ -0,0 +1,31 @@
+# Load kexec kernel image into memory during shutdown instead of bootup
+# (default: yes)
+#LOAD_DURING_SHUTDOWN="yes"
+
+# Additional arguments passed to kexec (8)
+#KEXEC_OPT_ARGS=""
+
+# Kernel image partition. Mounted automatically if not.
+# (default: /boot)
+#BOOTPART="/boot"
+
+# Root partition (should be autodetected)
+#ROOTPART="/dev/hda3"
+
+# Kernel image pathname, relative from BOOTPART.
+# If it's one of
+# {kernel-genkernel,bzImage,vmlinuz,kernel}-<currently running kernel version>,
+# or bzImage, vmlinuz (without suffix),
+# then it's automaticaly detected.
+# Setting it to "-" will disable kexec.
+#KNAME="vmlinuz-2.6.10"
+
+# Initrd
+# Same automatic detection restriction as for KNAME apply.
+# initramfs-genkernel-<currently running kernel version>,
+# initrd{,.img}-<currently running kernel version>{,.img}
+# will be detected.
+#INITRD="/boot/fbsplash-emergence-1024x768"
+
+# Kernel parameters (should be autodetected)
+#KPARAM="splash=silent,theme:emergence"
diff --git a/sys-apps/kexec-tools/files/kexec.init-2.0.3 b/sys-apps/kexec-tools/files/kexec.init-2.0.3
new file mode 100644
index 000000000000..6ae811291133
--- /dev/null
+++ b/sys-apps/kexec-tools/files/kexec.init-2.0.3
@@ -0,0 +1,119 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-2.0.3,v 1.1 2012/03/18 07:46:02 jlec Exp $
+
+depend() {
+ need localmount
+}
+
+image_path() {
+ local x= kver=$(uname -r) karch=$(uname -m)
+ BOOTPART="${BOOTPART:-/boot}"
+ for x in "${KNAME:-bzImage}" vmlinuz \
+ bzImage-${kver} vmlinuz-${kver} \
+ kernel-genkernel-${karch}-${kver} \
+ kernel-${kver} kernel-${karch}; do
+ if [[ -e "${BOOTPART}/${x}" ]] ; then
+ echo "${BOOTPART}/${x}"
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+initrd_path() {
+ local x= kver=$(uname -r) karch=$(uname -m)
+ BOOTPART="${BOOTPART:-/boot}"
+ for x in "${INITRD:-initrd}" \
+ initrd.img-${kver} initrd-${kver}.img \
+ initrd-${kver} initramfs-${kver}.img \
+ initramfs-genkernel-${karch}-${kver} ; do
+ if [[ -e "${BOOTPART}/${x}" ]] ; then
+ echo "${BOOTPART}/${x}"
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+load_image() {
+ if [[ "${KNAME}" = "-" ]]; then
+ ebegin "Disabling kexec"
+ kexec -u
+ eend $?
+ return $?
+ fi
+
+ BOOTPART="${BOOTPART:-/boot}"
+ local img="$(image_path)" initrd="$(initrd_path)" mounted=false initrdopt=
+
+ if [[ -z "${img}" ]] || [[ -z "${initrd}" ]]; then
+ # If we cannot find our image, try mounting ${BOOTPART}
+ if ! grep -q " ${BOOTPART} " /proc/mounts; then
+ ebegin "Mounting ${BOOTPART}"
+ mount "${BOOTPART}" && mounted=true
+ eend $? || return $?
+ img="$(image_path)"
+ initrd="$(initrd_path)"
+ fi
+ fi
+
+ if [[ -z "${img}" ]]; then
+ eerror "No kernel image found in ${BOOTPART}!"
+ ${mounted} && umount "${BOOTPART}"
+ return 1
+ else
+ ebegin "Loading kernel image ${img} for kexec"
+ fi
+
+ [[ -n "${ROOTPART}" ]] || \
+ ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")"
+
+ [[ -n "${KPARAM}" ]] || KEXEC_OPT_ARGS+=" --reuse-cmdline"
+
+ [[ -n "${initrd}" ]] && [[ -e "${initrd}" ]] && initrdopt="--initrd=${initrd}"
+
+ einfo " Setting kexec with ${KEXEC_OPT_ARGS} -l ${img} root=${ROOTPART} ${KPARAM} ${initrdopt}"
+ kexec ${KEXEC_OPT_ARGS} -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt}
+ local res=$?
+
+ ${mounted} && umount "${BOOTPART}"
+ eend ${res}
+ return ${res}
+}
+
+start() {
+ if [[ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ]]; then
+ image_path > /dev/null || \
+ ewarn "Cannot find kernel image. Please make sure a valid kernel image is present before reboot."
+ return 0
+ else
+ ebegin "Configuring kexec"
+ load_image
+ eend $?
+ fi
+}
+
+stop() {
+ [[ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ]] && return 0
+
+ if ! yesno $RC_REBOOT; then
+ einfo "Not rebooting, so disabling"
+ kexec -u
+ return 0
+ fi
+
+ if [[ -f /nokexec ]]; then
+ einfo "Not using kexec during reboot"
+ rm -f /nokexec
+ kexec -u
+ return 0
+ fi
+
+ ebegin "Configuring kexec"
+ load_image
+ eend $?
+}