[Pkg-sysvinit-devel] Bug#387599: initscripts: Support for kexec
Julien Danjou
acid at debian.org
Fri Sep 15 10:29:05 UTC 2006
Package: initscripts
Version: 2.86.ds1-20
Severity: wishlist
Hi init scripts maintainers!
I wrote a small patch to add kexec support for the reboot method.
It is quite simple, I let you take a look at the code.
I am really open to any suggestions to see this integrated. I first
thought to create a special package to handle this, but I guess letting
this job done by initscripts is better.
The patch consists into the following:
- recommends kexec-tools. Maybe a Depends is better, I let you judge
about that.
- add /etc/default/reboot to choose between standard reboot (default) and
kexec
- add /etc/default/kexec with working standard parameters
(image/initrd/append)
- add an init script in run level 6 just before umounting file systems
to load the kernel image
- if kexec is chosen, reboot via kexec -e in /etc/init.d/reboot and if
it fails, call reboot -f. That may be a clever behaviour in case of a
problem loading a kernel image.
Cheers,
--
Julien Danjou
.''`. Debian Developer
: :' : http://julien.danjou.info
`. `' http://people.debian.org/~acid
`- 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD
-------------- next part --------------
diff -Nur sysvinit-2.86.ds1/debian/changelog sysvinit-2.86.ds1.kexec/debian/changelog
--- sysvinit-2.86.ds1/debian/changelog 2006-09-15 11:31:50.000000000 +0200
+++ sysvinit-2.86.ds1.kexec/debian/changelog 2006-09-15 11:45:58.000000000 +0200
@@ -1,3 +1,9 @@
+sysvinit (2.86.ds1-20.kexec) unstable; urgency=low
+
+ * Kexec support
+
+ -- Julien Danjou <acid at debian.org> Fri, 15 Sep 2006 11:45:54 +0200
+
sysvinit (2.86.ds1-20) unstable; urgency=low
* Change initscripts postinst to use update-rc.d program instead of
diff -Nur sysvinit-2.86.ds1/debian/control sysvinit-2.86.ds1.kexec/debian/control
--- sysvinit-2.86.ds1/debian/control 2006-09-15 11:31:50.000000000 +0200
+++ sysvinit-2.86.ds1.kexec/debian/control 2006-09-15 11:32:53.000000000 +0200
@@ -35,6 +35,7 @@
Package: initscripts
Architecture: any
+Recommends: kexec-tools
Depends: ${shlibs:Depends}, ${glibc:Depends}, ${mount:Depends}, e2fsprogs (>= 1.32+1.33-WIP-2003.04.14-1), debianutils (>= 2.13.1), lsb-base (>= 3.0-6)
Conflicts: mdutils, sysv-rc (<< 2.86.ds1-1.2), sysvinit (<< 2.86.ds1-12)
Replaces: mdutils, sysvinit (<< 2.85-12), libc6, libc6.1, libc0.1, libc0.3
diff -Nur sysvinit-2.86.ds1/debian/initscripts/conffiles sysvinit-2.86.ds1.kexec/debian/initscripts/conffiles
--- sysvinit-2.86.ds1/debian/initscripts/conffiles 2006-09-15 11:31:50.000000000 +0200
+++ sysvinit-2.86.ds1.kexec/debian/initscripts/conffiles 2006-09-15 11:49:46.000000000 +0200
@@ -24,8 +24,11 @@
/etc/init.d/umountnfs.sh
/etc/init.d/umountroot
/etc/init.d/urandom
+/etc/init.d/kexec
/etc/default/bootlogd
/etc/default/devpts
/etc/default/halt
+/etc/default/reboot
+/etc/default/kexec
/etc/default/tmpfs
/etc/network/if-up.d/mountnfs
diff -Nur sysvinit-2.86.ds1/debian/initscripts/etc/default/kexec sysvinit-2.86.ds1.kexec/debian/initscripts/etc/default/kexec
--- sysvinit-2.86.ds1/debian/initscripts/etc/default/kexec 1970-01-01 01:00:00.000000000 +0100
+++ sysvinit-2.86.ds1.kexec/debian/initscripts/etc/default/kexec 2006-09-15 11:45:12.000000000 +0200
@@ -0,0 +1,8 @@
+# Defaults for kexec initscript
+# sourced by /etc/init.d/kexec
+
+KERNEL_IMAGE="/vmlinuz"
+INITRD="/initrd.img"
+
+# If empty, use current /proc/cmdline
+APPEND=""
diff -Nur sysvinit-2.86.ds1/debian/initscripts/etc/default/reboot sysvinit-2.86.ds1.kexec/debian/initscripts/etc/default/reboot
--- sysvinit-2.86.ds1/debian/initscripts/etc/default/reboot 1970-01-01 01:00:00.000000000 +0100
+++ sysvinit-2.86.ds1.kexec/debian/initscripts/etc/default/reboot 2006-09-15 11:37:29.000000000 +0200
@@ -0,0 +1,2 @@
+# Default behaviour of shutdown -r / reboot. Set to "reboot" or "kexec".
+REBOOT=reboot
diff -Nur sysvinit-2.86.ds1/debian/initscripts/etc/init.d/kexec sysvinit-2.86.ds1.kexec/debian/initscripts/etc/init.d/kexec
--- sysvinit-2.86.ds1/debian/initscripts/etc/init.d/kexec 1970-01-01 01:00:00.000000000 +0100
+++ sysvinit-2.86.ds1.kexec/debian/initscripts/etc/init.d/kexec 2006-09-15 11:39:44.000000000 +0200
@@ -0,0 +1,41 @@
+#! /bin/sh
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+. /lib/lsb/init-functions
+
+[ -r /etc/default/kexec ] && . /etc/default/kexec
+[ -r /etc/default/reboot ] && . /etc/default/reboot
+
+do_stop () {
+ if [ "$REBOOT" = "kexec" ]
+ then
+ REAL_APPEND="$APPEND"
+
+ # If append is not given, use current cmdline
+ test -z "$REAL_APPEND" && REAL_APPEND="`cat /proc/cmdline`"
+
+ # Load image with kexec
+ if [ -e "$KERNEL_IMAGE" ] && [ -e "$INITRD" ]
+ then
+ kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$REAL_APPEND"
+ fi
+ fi
+}
+
+case "$1" in
+ start)
+ # No-op
+ ;;
+ restart|reload|force-reload)
+ echo "Error: argument '$1' not supported" >&2
+ exit 3
+ ;;
+ stop)
+ do_stop
+ ;;
+ *)
+ echo "Usage: $0 start|stop" >&2
+ exit 3
+ ;;
+esac
diff -Nur sysvinit-2.86.ds1/debian/initscripts/etc/init.d/reboot sysvinit-2.86.ds1.kexec/debian/initscripts/etc/init.d/reboot
--- sysvinit-2.86.ds1/debian/initscripts/etc/init.d/reboot 2006-09-15 11:31:50.000000000 +0200
+++ sysvinit-2.86.ds1.kexec/debian/initscripts/etc/init.d/reboot 2006-09-15 11:41:48.000000000 +0200
@@ -13,11 +13,13 @@
PATH=/usr/sbin:/usr/bin:/sbin:/bin
. /lib/lsb/init-functions
+[ -r /etc/default/reboot ] && . /etc/default/reboot
do_stop () {
# Message should end with a newline since kFreeBSD may
# print more stuff (see #323749)
log_action_msg "Will now restart"
+ test "$REBOOT" = "kexec" && kexec -e && log_action_msg "Kexec failed, rebooting"
reboot -d -f -i
}
diff -Nur sysvinit-2.86.ds1/debian/initscripts/postinst sysvinit-2.86.ds1.kexec/debian/initscripts/postinst
--- sysvinit-2.86.ds1/debian/initscripts/postinst 2006-09-15 11:31:50.000000000 +0200
+++ sysvinit-2.86.ds1.kexec/debian/initscripts/postinst 2006-09-15 12:08:33.000000000 +0200
@@ -121,6 +121,7 @@
updatercd halt start 90 0 .
updatercd reboot start 90 6 .
updatercd umountroot start 60 0 6 .
+updatercd kexec start 39 6 .
updatercd umountfs start 40 0 6 .
updatercd umountnfs.sh start 31 0 6 .
updatercd sendsigs start 20 0 6 .
More information about the Pkg-sysvinit-devel
mailing list