summaryrefslogtreecommitdiff
path: root/packages/altboot
diff options
context:
space:
mode:
authorMatthias Hentges <oe@hentges.net>2007-03-27 22:22:45 +0000
committerMatthias Hentges <oe@hentges.net>2007-03-27 22:22:45 +0000
commite55d052b8fe7279f2fc23944fd5dd75e743d1a4b (patch)
treeb84cfe224db5d5956437b9efcd73271d60961174 /packages/altboot
parent1944b83357f5afec7e0560124ddfcf81b8fc07a5 (diff)
altboot: Update to latest version
Diffstat (limited to 'packages/altboot')
-rw-r--r--packages/altboot/files/altboot-menu/Advanced/55-bin-sh4
-rw-r--r--packages/altboot/files/altboot.func2
-rw-r--r--packages/altboot/files/init.altboot13
-rw-r--r--packages/altboot/files/nslu2le/.mtn2git_empty0
-rw-r--r--packages/altboot/files/nslu2le/altboot-2.6.cfg55
-rw-r--r--packages/altboot/files/nslu2le/altboot-handlers/.mtn2git_empty0
-rw-r--r--packages/altboot/files/nslu2le/altboot-handlers/05-USB-Storage90
-rw-r--r--packages/altboot/files/nslu2le/altboot-handlers/10-Onboard-Flash18
-rw-r--r--packages/altboot/files/nslu2le/altboot-menu/.mtn2git_empty0
-rw-r--r--packages/altboot/files/nslu2le/altboot-menu/00-Default17
-rw-r--r--packages/altboot/files/nslu2le/altboot-menu/30-bootUSB-Stick174
-rw-r--r--packages/altboot/files/nslu2le/altboot-menu/55-bin-sh27
-rw-r--r--packages/altboot/files/nslu2le/altboot.rc/.mtn2git_empty0
-rwxr-xr-xpackages/altboot/files/set-bootdev150
14 files changed, 546 insertions, 4 deletions
diff --git a/packages/altboot/files/altboot-menu/Advanced/55-bin-sh b/packages/altboot/files/altboot-menu/Advanced/55-bin-sh
index 6c9aef3f3e..e4fe99ebae 100644
--- a/packages/altboot/files/altboot-menu/Advanced/55-bin-sh
+++ b/packages/altboot/files/altboot-menu/Advanced/55-bin-sh
@@ -7,7 +7,7 @@ run_module() {
test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
- test "$ASK_PW_ON_BOOT" != "yes" && verify_master_pw >/dev/tty0
+ test "$ASK_PW_ON_BOOT" != "yes" && verify_master_pw >/dev/$OUT_TTY
# Mount /proc, etc
init_rootfs
@@ -15,7 +15,7 @@ run_module() {
echo -e "\nBoot system with 'exec /sbin/init 5'\n"
while true
do
- exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+ exec $SH_SHELL </dev/$OUT_TTY >/dev/$OUT_TTY 2>&1
echo "WARNING: Shell was killed!"
done
}
diff --git a/packages/altboot/files/altboot.func b/packages/altboot/files/altboot.func
index e990a06862..ae38c5b437 100644
--- a/packages/altboot/files/altboot.func
+++ b/packages/altboot/files/altboot.func
@@ -392,7 +392,7 @@ verify_master_pw() {
test -e /etc/altboot.pwd && . /etc/altboot.pwd
- if ! test -z "$MASTER_PASSWORD"
+ if test -n "$MASTER_PASSWORD" -a "$MASTER_PASSWORD" != "[none]"
then
auth_timeout="3"
diff --git a/packages/altboot/files/init.altboot b/packages/altboot/files/init.altboot
index 30868024b8..74200d1ec9 100644
--- a/packages/altboot/files/init.altboot
+++ b/packages/altboot/files/init.altboot
@@ -90,7 +90,7 @@ show_menu() {
if ! test -d "$1/$file"
then
# NOTE: It is important to use "." here so that the script inherits
- # the shell environment / all set variables!
+ # the shell environment / all set variables!
M_TITLE="`. $1/$file title`"
FLAGS="`$1/$file flags`"
@@ -109,6 +109,8 @@ show_menu() {
fi
done
+# debug_echo "FILES READ"
+
# Display directories below /etc/altboot-menu as menu-item
# and add all scripts inside the directory to m_entry
for dir in `ls -1`
@@ -159,6 +161,8 @@ show_menu() {
fi
done
+# debug_echo "DIRS READ"
+
echo ""
}
@@ -491,6 +495,7 @@ fi
# The NSLU2 is an exception as it uses the way-ugly busybox "ps"
#
+mount | grep -q "^/proc" || mount -t proc proc /proc
MACHINE="`cat /proc/cpuinfo | sed -n "/^Hardware/s/.*\:\ \(.*\)/\1/p"`"
case "$MACHINE" in
@@ -507,6 +512,12 @@ case "$MACHINE" in
;;
esac
+if test "`basename "$0"`" = "altboot"
+then
+ show_menu /etc/altboot-menu
+ exit 0
+fi
+
if test "$user_called" = "1"
then
echo "altboot: Using real init [$REAL_INIT] [$*] [`ps |wc -l|tr -d " "`] *" >"$OUT_TTY"
diff --git a/packages/altboot/files/nslu2le/.mtn2git_empty b/packages/altboot/files/nslu2le/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/altboot/files/nslu2le/.mtn2git_empty
diff --git a/packages/altboot/files/nslu2le/altboot-2.6.cfg b/packages/altboot/files/nslu2le/altboot-2.6.cfg
new file mode 100644
index 0000000000..626c543085
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot-2.6.cfg
@@ -0,0 +1,55 @@
+#
+# Altboot machine configuration for: NSLU2 / Kernel 2.6
+#
+
+# Handled by /sbin/init.altboot
+# Allow booting images from SD or CF instead of booting
+# the ROM.
+ENABLE_ALTBOOT="yes"
+
+# If set to "0" the menu will always be shown, if set to
+# "[none]" there will be no menu and no delay
+TIMEOUT="[none]"
+
+REAL_INIT="/sbin/init.sysvinit"
+SH_SHELL="/bin/sh"
+
+ENABLE_SOUND="no"
+
+IMAGE_PATH="boot-images"
+IMAGE_TYPE="ext2"
+FSCK_IMAGES="yes"
+
+
+# Can't do that due to missing console
+ENABLE_IMAGECONF="no"
+
+SD_DEVICE=""
+SD_KERNEL_MODULE=""
+
+
+USB_HOST_AVAILABLE="yes"
+USB_STORAGE_MODULES="ohci_hcd usb_storage sd_mod"
+USB_STORAGE_PARTITION="/dev/sda1"
+USB_STORAGE_WAIT="4"
+
+USB_NETWORKING_AVAILABLE="no"
+USB_NW_MODULES="usbcore pxa27x_udc ohci-hcd g_ether"
+USB_NW_DEVICE="usb0"
+
+INIT_RUNLEVEL="3"
+NO_GUI_RL=""
+
+# The if set to "", altboot will force you to set a master password on
+# first-boot
+MASTER_PASSWORD="[none]"
+ASK_PW_ON_BOOT="no"
+
+SD_MOUNTPOINT="/media/card"
+CF_MOUNTPOINT="/media/cf"
+
+DISABLE_SD_BOOT="yes"
+DISABLE_CF_BOOT="yes"
+DISABLE_NOGUI_BOOT="yes"
+DISABLE_BINSH_BOOT="yes"
+DISABLE_INSTTGZ_BOOT="yes"
diff --git a/packages/altboot/files/nslu2le/altboot-handlers/.mtn2git_empty b/packages/altboot/files/nslu2le/altboot-handlers/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot-handlers/.mtn2git_empty
diff --git a/packages/altboot/files/nslu2le/altboot-handlers/05-USB-Storage b/packages/altboot/files/nslu2le/altboot-handlers/05-USB-Storage
new file mode 100644
index 0000000000..50d35ed542
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot-handlers/05-USB-Storage
@@ -0,0 +1,90 @@
+#!/bin/sh
+# NOTE: Ported to altboot by CoreDump <oe@hentges.net>
+# Based on the original turnup helper script.
+#
+# All parts by Matthias 'CoreDump' Hentges are hereby placed
+# under the terms of the GPL
+#
+# boot from the hard disk partition "$1" (which
+# must be given) using options from the rest of
+# the command line.
+#
+
+M_TITLE="Boot USB Storage"
+test "$USB_HOST_AVAILABLE" = "yes" || exit 0
+
+run_module() {
+ x=x
+}
+
+case "$1" in
+title) echo "$M_TITLE" ; exit 0 ;;
+run) run_module "$2";;
+esac
+
+nslu2_feeback heartbeat
+
+bootdev_data="$*"
+bootdev_mode="`echo "$bootdev_data" | awk '{print $1}'`"
+bootdev_name="`echo "$bootdev_data" | awk '{print $2}'`"
+bootdev_uuid="`echo "$bootdev_data" | awk '{print $3}'`"
+
+
+# Use the standard init path (see /etc/init.d/rcS)
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+#
+# Load the helper functions
+. /etc/default/functions
+. /etc/default/modulefunctions
+#
+leds boot system
+#
+if test -n "$1"
+then
+ device="$bootdev_name"
+ UUID="$bootdev_uuid"
+
+ shift
+ # proc is needed for UUID mount and module load
+ mount -t proc proc /proc
+ # load USB & SCSI storage modules (/proc required!)
+ echo "boot: loading modules required for disk boot"
+ loaddiskmods
+ # waiting for disk (FIXME)
+ sleep=6
+ test "$sleep" -gt 0 && sleep "$sleep"
+ #
+ # fire the boot
+ echo "boot: rootfs: mount $* $device [$UUID]"
+ #
+ # Mount read-write because before exec'ing init
+ # If a UUID is given (in the environment) this
+ # is used in preference to the device, but if
+ # the UUID mount fails a standard device mount
+ # is attempted.
+ if test -n "$UUID" &&
+ mount "$@" -U "$UUID" /mnt ||
+ mount "$@" "$device" /mnt
+ then
+ # checkmount checks for sh, chroot, init
+ # and /mnt (i.e. /mnt/mnt in this case)
+ if checkmount /mnt
+ then
+ # pivot to /initrd if available, else /mnt
+ cd /
+ if test -d /mnt/initrd
+ then
+ swivel mnt initrd
+ else
+ swivel mnt mnt
+ fi
+ # swivel failed
+ fi
+ # Failure: unmount the partition
+ umount /mnt
+ fi
+fi
+
+# fallback - use the flash boot
+nslu2_feeback failure
+exec /boot/flash
diff --git a/packages/altboot/files/nslu2le/altboot-handlers/10-Onboard-Flash b/packages/altboot/files/nslu2le/altboot-handlers/10-Onboard-Flash
new file mode 100644
index 0000000000..394279c2af
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot-handlers/10-Onboard-Flash
@@ -0,0 +1,18 @@
+#! /bin/sh
+#
+# Copyright Matthias Hentges <devel@hentges.net> (c) 2007
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the license)
+#
+# Filename: 10-Onboard-Flash
+# Date: 20070218 (YMD)
+
+leds beep
+. /etc/default/functions
+leds boot system
+test -x /sbin/init && exec /sbin/init
+# fallback if /sbin/init has been deleted (bad!)
+leds boot system panic
+exec <>/dev/console >&0 2>&0
+test -x /sbin/sulogin && exec /sbin/sulogin
+test -x /bin/sh && exec /bin/sh
+exit 1
diff --git a/packages/altboot/files/nslu2le/altboot-menu/.mtn2git_empty b/packages/altboot/files/nslu2le/altboot-menu/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot-menu/.mtn2git_empty
diff --git a/packages/altboot/files/nslu2le/altboot-menu/00-Default b/packages/altboot/files/nslu2le/altboot-menu/00-Default
new file mode 100644
index 0000000000..cb06661d72
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot-menu/00-Default
@@ -0,0 +1,17 @@
+# !/bin/sh
+M_TITLE="Flash"
+
+
+run_module() {
+ leds beep
+ leds boot system
+ exec $REAL_INIT "$INIT_RUNLEVEL"
+ exit 0
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run) run_module;;
+*) echo "Unknown parameter [$1]";;
+esac
+
diff --git a/packages/altboot/files/nslu2le/altboot-menu/30-bootUSB-Stick b/packages/altboot/files/nslu2le/altboot-menu/30-bootUSB-Stick
new file mode 100644
index 0000000000..c6c215ecc4
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot-menu/30-bootUSB-Stick
@@ -0,0 +1,174 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+
+M_TITLE="USB Attached Storage"
+
+test "$USB_HOST_AVAILABLE" = "yes" || exit 0
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+
+ test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+
+ # Mount /proc, etc
+ init_rootfs
+
+ echo -e "\nStarting USB..."
+
+ for module in $USB_STORAGE_MODULES
+ do
+ echo -en "\t - $module: "
+ modprobe "$module" >/dev/null 2>&1 && echo ok || die "Failed to modprobe [$module]"
+ done
+
+ echo ""
+ scan_devices
+ usb_show_menu
+
+# echo -n "Mounting $USB_STORAGE_PARTITION..." >/dev/tty0
+#
+# mkdir -p /media/usb-storage >/dev/null 2>&1
+#
+# sleep "$USB_STORAGE_WAIT"
+#
+# /bin/mount -t auto -o defaults,noatime $USB_STORAGE_PARTITION /media/usb-storage >/dev/null 2>&1 && echo ok >/dev/tty0|| die "/bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT failed"
+#
+# echo ""
+#
+# # Check for a real fs and loop-images.
+# check_target "/media/usb-storage" >/dev/tty0
+}
+
+scan_devices() {
+ reset_pref "available_devices"
+
+ cnt=1
+
+ for scsi_disk in `ls -1 /sys/block/ | grep ^sd`
+ do
+ scsi_disk_name="`echo "$scsi_disk" | awk '{printf("%s\n",toupper($0))}'`"
+ test -e /sys/block/$scsi_disk/device/vendor && HDD_VENDOR="`cat /sys/block/$scsi_disk/device/vendor | sed "s/\ $//"`"
+ test -z "$HDD_VENDOR" && HDD_VENDOR="Unknown Vendor"
+
+ test -e /sys/block/$scsi_disk/device/model && HDD_MODEL="`cat /sys/block/$scsi_disk/device/model`"
+ test -z "$HDD_MODEL" && HDD_MODEL="Unknown Model"
+
+ scsi_disk_partition_cnt="`ls -1 /sys/block/$scsi_disk | grep ^$scsi_disk | wc -l | tr -d " "`"
+ test "$scsi_disk_partition_cnt" -gt 1 && scsi_disk_partition_cnt="$scsi_disk_partition_cnt partitions" || scsi_disk_partition_cnt="$scsi_disk_partition_cnt partition"
+
+ set_pref "available_devices" "$cnt" "$scsi_disk_name ( $HDD_VENDOR $HDD_MODEL with $scsi_disk_partition_cnt)"
+ set_pref "available_devices_short" "$cnt" "$scsi_disk"
+ set_pref "available_devices_type" "$cnt" "usb"
+
+ let cnt=$cnt+1
+ done
+
+}
+
+usb_show_menu() {
+
+ cnt2=0 ; let cnt=$cnt-1
+ while test "$cnt" != "$cnt2"
+ do
+ let cnt2=$cnt2+1
+ get_pref "available_devices" "$cnt2" dev
+
+ echo -e "\t[$cnt2] - $dev"
+ done
+
+ while test -z "$selected_dev"
+ do
+ echo -en "\nYour choice: "
+ read junk
+ get_pref "available_devices" "$junk" selected_dev
+ get_pref "available_devices_type" "$junk" part_mode
+
+# debug_echo "show_menu(): selected: [$selected_dev]"
+ done
+
+ if ( echo "$selected_dev" | grep -q "^Flash" )
+ then
+ boot_from flash
+ else
+ get_pref "available_devices_short" "$junk" selected_dev
+# debug_echo "show_menu(): selected_devices_short: [$selected_dev]"
+
+ partitions="`ls -1 /sys/block/$selected_dev|grep ^$selected_dev`"
+ test -z "$partitions" && die "No partitions found on /dev/$selected_dev!"
+
+
+ echo -e "\nPlease select a partition on $selected_dev to boot from:\n"
+
+ cnt=1
+ for partition in $partitions
+ do
+ # We assume that partitions with a "size" < 10 are extended partitions
+ # and should not be listed. TYPE=swap is blacklisted as well.
+ part_size="`cat /sys/block/$selected_dev/$partition/size`"
+ part_type="`blkid -s TYPE -o value /dev/$partition`"
+
+ if test "$part_size" -gt 10 -a "$part_type" != "swap"
+ then
+ let part_size="($part_size/2)/1000"
+ echo -e "\t[$cnt] $partition (~ ${part_size}Mb, $part_type)"
+ set_pref "available_partitions" "$cnt" "$partition"
+
+ let cnt=$cnt+1
+ fi
+ done
+
+ while test -z "$selected_partition"
+ do
+ echo -en "\nYour choice: "
+ read junk
+ get_pref "available_partitions" "$junk" selected_partition
+ done
+
+ part_uuid="`blkid -c /dev/null -s UUID -o value /dev/$selected_partition`"
+
+ boot_from "$part_mode" "$selected_partition" "$part_uuid"
+ fi
+}
+
+boot_from() {
+ debug_echo "boot_from() [$*]"
+
+ part_mode="$1"
+ part_name="$2"
+ part_uuid="$3"
+
+ case "$part_mode" in
+ usb) umount /tmp/mnt.set-bootdev >/dev/null 2>&1
+ rm -rf /tmp/mnt.set-bootdev ; mkdir -p /tmp/mnt.set-bootdev
+
+ if ! ( mount -U "$part_uuid" /tmp/mnt.set-bootdev )
+ then
+ echo "** Note: UUID mount for $part_name failed"
+ mount /dev/$part_name /tmp/mnt.set-bootdev && echo "** Note: Normal mount for $part_name successful"
+ fi
+
+ if ! test -e /tmp/mnt.set-bootdev/sbin/init.sysvinit
+ then
+ copy_rootfs /tmp/mnt.set-bootdev/
+ else
+ umount /tmp/mnt.set-bootdev
+ echo -e "\nSetting /dev/$part_name as boot-partition"
+ echo "3 $part_name $part_uuid" > /etc/altboot.last
+ fi
+ ;;
+ esac
+}
+
+copy_rootfs() {
+ debug_echo "copy_rootfs() [$*]"
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run) run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/nslu2le/altboot-menu/55-bin-sh b/packages/altboot/files/nslu2le/altboot-menu/55-bin-sh
new file mode 100644
index 0000000000..1c3fccd9d9
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot-menu/55-bin-sh
@@ -0,0 +1,27 @@
+# !/bin/sh
+M_TITLE="init=/bin/sh"
+
+test "$DISABLE_BINSH_BOOT" = yes && exit 0
+
+run_module() {
+
+ test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+
+ test "$ASK_PW_ON_BOOT" != "yes" && verify_master_pw >$OUT_TTY
+
+ # Mount /proc, etc
+ init_rootfs
+
+ echo -e "\nBoot system with 'exec /sbin/init 5'\n"
+ while true
+ do
+ exec $SH_SHELL <$OUT_TTY >$OUT_TTY 2>&1
+ echo "WARNING: Shell was killed!"
+ done
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run) run_module;;
+esac
+
diff --git a/packages/altboot/files/nslu2le/altboot.rc/.mtn2git_empty b/packages/altboot/files/nslu2le/altboot.rc/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/altboot/files/nslu2le/altboot.rc/.mtn2git_empty
diff --git a/packages/altboot/files/set-bootdev b/packages/altboot/files/set-bootdev
new file mode 100755
index 0000000000..60d0283dc4
--- /dev/null
+++ b/packages/altboot/files/set-bootdev
@@ -0,0 +1,150 @@
+#!/bin/sh
+
+VERSION="0.0.1"
+ENABLE_DEBUG="yes"
+
+die() {
+ echo -e "ERROR: $1"
+ exit 1
+}
+
+. /etc/altboot.func || die "/etc/altboot.func is missing!"
+test -d /sys/block || die "Sysfs problem? (/sys/block not found)"
+
+debug_echo() {
+ test "$ENABLE_DEBUG" = "yes" && echo -e "${C_YELLOW}DEBUG:${C_RESET}${C_WHITE} $1 ${C_RESET}"
+}
+
+scan_devices() {
+ reset_pref "available_devices"
+
+ cnt=1
+ set_pref "available_devices" "$cnt" "Flash" ; let cnt=$cnt+1
+
+ for scsi_disk in `ls -1 /sys/block/ | grep ^sd`
+ do
+ scsi_disk_name="`echo "$scsi_disk" | awk '{printf("%s\n",toupper($0))}'`"
+ test -e /sys/block/$scsi_disk/device/vendor && HDD_VENDOR="`cat /sys/block/$scsi_disk/device/vendor | sed "s/\ $//"`"
+ test -z "$HDD_VENDOR" && HDD_VENDOR="Unknown Vendor"
+
+ test -e /sys/block/$scsi_disk/device/model && HDD_MODEL="`cat /sys/block/$scsi_disk/device/model`"
+ test -z "$HDD_MODEL" && HDD_MODEL="Unknown Model"
+
+ scsi_disk_partition_cnt="`ls -1 /sys/block/$scsi_disk | grep ^$scsi_disk | wc -l | tr -d " "`"
+ test "$scsi_disk_partition_cnt" -gt 1 && scsi_disk_partition_cnt="$scsi_disk_partition_cnt partitions" || scsi_disk_partition_cnt="$scsi_disk_partition_cnt partition"
+
+ set_pref "available_devices" "$cnt" "$scsi_disk_name ( $HDD_VENDOR $HDD_MODEL with $scsi_disk_partition_cnt)"
+ set_pref "available_devices_short" "$cnt" "$scsi_disk"
+ set_pref "available_devices_type" "$cnt" "usb"
+
+ let cnt=$cnt+1
+ done
+
+}
+
+show_menu() {
+ echo -e "\nset-bootdev v$VERSION\n"
+
+ echo -e "Please select the device you wish to boot from:\n"
+
+ cnt2=0 ; let cnt=$cnt-1
+ while test "$cnt" != "$cnt2"
+ do
+ let cnt2=$cnt2+1
+ get_pref "available_devices" "$cnt2" dev
+
+ echo -e "\t[$cnt2] - $dev"
+ done
+
+ while test -z "$selected_dev"
+ do
+ echo -en "\nYour choice: "
+ read junk
+ get_pref "available_devices" "$junk" selected_dev
+ get_pref "available_devices_type" "$junk" part_mode
+
+# debug_echo "show_menu(): selected: [$selected_dev]"
+ done
+
+ if ( echo "$selected_dev" | grep -q "^Flash" )
+ then
+ boot_from flash
+ else
+ get_pref "available_devices_short" "$junk" selected_dev
+# debug_echo "show_menu(): selected_devices_short: [$selected_dev]"
+
+ partitions="`ls -1 /sys/block/$selected_dev|grep ^$selected_dev`"
+ test -z "$partitions" && die "No partitions found on /dev/$selected_dev!"
+
+
+ echo -e "\nPlease select a partition on $selected_dev to boot from:\n"
+
+ cnt=1
+ for partition in $partitions
+ do
+ # We assume that partitions with a "size" < 10 are extended partitions
+ # and should not be listed. TYPE=swap is blacklisted as well.
+ part_size="`cat /sys/block/$selected_dev/$partition/size`"
+ part_type="`blkid -s TYPE -o value /dev/$partition`"
+
+ if test "$part_size" -gt 10 -a "$part_type" != "swap"
+ then
+ let part_size="($part_size/2)/1000"
+ echo -e "\t[$cnt] $partition (~ ${part_size}Mb, $part_type)"
+ set_pref "available_partitions" "$cnt" "$partition"
+
+ let cnt=$cnt+1
+ fi
+ done
+
+ while test -z "$selected_partition"
+ do
+ echo -en "\nYour choice: "
+ read junk
+ get_pref "available_partitions" "$junk" selected_partition
+ done
+
+ part_uuid="`blkid -c /dev/null -s UUID -o value /dev/$selected_partition`"
+
+ boot_from "$part_mode" "$selected_partition" "$part_uuid"
+ fi
+}
+
+boot_from() {
+ debug_echo "boot_from() [$*]"
+
+ part_mode="$1"
+ part_name="$2"
+ part_uuid="$3"
+
+ case "$part_mode" in
+ usb) umount /tmp/mnt.set-bootdev >/dev/null 2>&1
+ rm -rf /tmp/mnt.set-bootdev ; mkdir -p /tmp/mnt.set-bootdev
+
+ if ! ( mount -U "$part_uuid" /tmp/mnt.set-bootdev )
+ then
+ echo "** Note: UUID mount for $part_name failed"
+ mount /dev/$part_name /tmp/mnt.set-bootdev && echo "** Note: Normal mount for $part_name successful"
+ fi
+
+ if ! test -e /tmp/mnt.set-bootdev/sbin/init.sysvinit
+ then
+ copy_rootfs /tmp/mnt.set-bootdev/
+ else
+ umount /tmp/mnt.set-bootdev
+ echo -e "\nSetting /dev/$part_name as boot-partition"
+ echo "$part_mode $part_name $part_uuid" > /etc/set-bootdev.conf
+ fi
+ ;;
+ flash) echo "Setting the onboard flash as boot-partition"
+ echo "$part_mode $part_name $part_uuid" > /etc/set-bootdev.conf
+ ;;
+ esac
+}
+
+copy_rootfs() {
+ debug_echo "copy_rootfs() [$*]"
+}
+
+scan_devices
+show_menu