Hi Khalid,
* Khalid Aziz <[EMAIL PROTECTED]> [21. Jun. 2007]:
> On Fri, 2007-06-15 at 16:01 +0200, Philipp Matthias Hahn wrote:
>> It would be nice if "$USE_KEXEC" whould distinguish between three
>> states:
>>
>> DISABLED:
>> TRY_EXEC:
>> FORCE_LOAD:
>
> I like this idea but I am concerned about implementation. TRY_KEXEC can
> be implemented cleanly on 2.6.18 and newer kernels due to the presence
> of /sys/kernel/kexec_loaded. On older kernels, there is no way to know
> if a kexec kernel has been loaded. Attempting kexec on older kernels
> without a kexec kernel loaded fails with cryptic error message - " kexec
> failed: Invalid argument". I can of course follow kexec -e with a
> regular reboot, but I am concerned about this cryptic error message.
Please enable this feature since nobody will run lenny on
kernels older than 2.6.18.1 (the oldest kernel sources I
checked for /sys/kernel/kexec_loaded). I would like to use
your init scripts to boot a default kernel but would also
like to boot other kernels when needed. The following simple
modification of the init scripts accomplishes this:
/etc/init.d/kexec_loaded should only load the default kernel as
defined in /etc/default/kexec if $USE_KEXEC = 1 *and*
/sys/kernel/kexec_loaded = 0.
/etc/init.d/kexec should not test $USE_KEXEC but kexec only if
/sys/kernel/kexec_loaded = 1.
This would enable 3 different possibilities:
+--+-++
| |kernel loaded prior |no kernel loaded|
| |to runtime of init |prior to runtime of |
| |scripts |init-scripts|
+--+-++
|$USE_KEXEC = 1|kexec kernel loaded |load and kexec |
| |from command line or |default kernel |
| |other script ||
+--+-++
|$USE_KEXEC = 0|kexec kernel loaded |boot via bios |
| |from command line or ||
| |other script ||
+--+-++
This proposal would change the meaning of $USE_KEXEC from "enable
kexec" to "use kexec as default". Why should one install
kexec-tools and disable its use?
Please find attached the two slightely modified init scripts.
They work very well for me.
Ciao, Gregor
#! /bin/sh
### BEGIN INIT INFO
# Provides: kexec
# Required-Start:
# Required-Stop:reboot
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop: 6
# Short-Description: Execute the kexec -e command to reboot system
# Description:
### END INIT INFO
PATH=/usr/sbin:/usr/bin:/sbin:/bin
. /lib/lsb/init-functions
test -r /etc/default/kexec && . /etc/default/kexec
do_stop () {
test "x`cat /sys/kernel/kexec_loaded`y" == "x1y" || exit 0
test -x /sbin/kexec || exit 0
log_action_msg "Will now restart with kexec"
kexec -e
log_failure_msg "kexec failed"
}
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
exit 0
#! /bin/sh
### BEGIN INIT INFO
# Provides: kexec-load
# Required-Start:
# Required-Stop:$local_fs kexec
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop: 6
# Short-Description: Load kernel image with kexec
# Description:
### END INIT INFO
PATH=/usr/sbin:/usr/bin:/sbin:/bin
. /lib/lsb/init-functions
test -r /etc/default/kexec && . /etc/default/kexec
do_stop () {
test "$USE_KEXEC" = 1 || exit 0
test -x /sbin/kexec || exit 0
test "x`cat /sys/kernel/kexec_loaded`y" == "x1y" && exit 0
REAL_APPEND="$APPEND"
test -z "$REAL_APPEND" && REAL_APPEND="`cat /proc/cmdline`"
log_action_begin_msg "Loading new kernel image into memory"
if [ -z "$INITRD" ]
then
kexec -l "$KERNEL_IMAGE" --append="$REAL_APPEND"
else
kexec -l "$KERNEL_IMAGE" --initrd="$INITRD"
--append="$REAL_APPEND"
fi
log_action_end_msg $?
}
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
exit 0