/boot/kexec: Added tftp method to fetch kernel to boot, added notes on
authorMike Westerhof <mwester@dls.net>
Tue, 3 Jul 2007 16:43:23 +0000 (16:43 +0000)
committerMike Westerhof <mwester@dls.net>
Tue, 3 Jul 2007 16:43:23 +0000 (16:43 +0000)
usage to the comments section.

packages/slugos-init/files/boot/kexec

index c5b428c..7c02a14 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # Loads the specified kernel and kexecs it.
-# 
+
 # The access method and path from which to fetch the kernel
 # is specified in "$1" and "$2":
 #
 # wget       ftp://ftpserv/pub/zImage
 # /dev/sda1  /kernels/zImage-test
 # UUID       /kernels/zImage-test
+# tftp       server:/pub/kernels/vmlinuz
 #
 # Command-line options for the new kernel are in "$3".
 
+
+# In order to use this, you must exec this script from the /linuxrc file.
+#
+# This sample linuxrc script boots from external disk.  The last line of
+# this example (exec /boot/flash) is a fallback; it will not normally be
+# executed unless /boot/kexec is missing or damaged.
+#--------------------
+#  #!/bin/sh
+#  sleep=8 exec /boot/kexec /dev/sda1 /boot/zImage-ixp4xxbe \
+#  "console=ttyS0,115200n8 root=/dev/sda1 rootfstype=ext3 rw init=/linuxrc"
+#  exec /boot/flash
+#--------------------
+#
+# This one boots from flash in the normal fashion, except the kernel is
+# loaded using wget.  This is common for kernel debugging.
+#--------------------
+#  #!/bin/sh
+#  exec /boot/kexec wget http://myserver/boot/zImage-ixp4xxbe \
+#  "console=ttyS0,115200n8 root=/dev/mtdblock4 rootfstype=jffs2 rw \
+#    init=/boot/flash noirqdebug"
+#  exec /boot/flash
+#--------------------
+
+
 # Use the standard init path (see /etc/init.d/rcS)
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
@@ -26,6 +51,11 @@ fi
 . /etc/default/functions
 . /etc/default/modulefunctions
 
+# Print a distinctive banner to make it easy to separate the in-flash
+# kernel boot from the kexec'd kernel boot when looking at logs, etc.
+echo '###########################################################'
+echo '######################     KEXEC     ######################'
+
 leds boot system
 
 if [ -n "$1" -a -n "$2" ] ; then
@@ -100,6 +130,19 @@ if [ -n "$1" -a -n "$2" ] ; then
                fi
                ;;
 
+           tftp )
+               if /boot/network ; then
+                   echo "mounting tmpfs partition..."
+                   if mount -t tmpfs tmpfs /mnt ; then
+                       need_umount=1
+                       t=`basename "$kpath"`
+                       kexec_image="/mnt/$t"
+                       echo "Loading kexec kernel using tftp \"$kpath\"..."
+                       tftp -g -l "$kexec_image" -r "${kpath#*:}" "${kpath%%:*}"
+                   fi
+               fi
+               ;;
+
            * )
                echo "Unrecognized method: \"$method\""
                ;;