2009-03-18 13:02:53 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2011-01-09 18:44:37 +01:00
|
|
|
################################################################################
|
|
|
|
|
# This file is part of OpenELEC - http://www.openelec.tv
|
2013-12-21 21:51:48 +01:00
|
|
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
2014-04-25 11:15:19 +02:00
|
|
|
# Copyright (C) 2010-2011 Roman Weber (roman@openelec.tv)
|
2012-03-03 13:43:37 +01:00
|
|
|
# Copyright (C) 2012 Yann Cézard (eesprit@free.fr)
|
2011-01-09 18:44:37 +01:00
|
|
|
#
|
2013-12-21 21:51:48 +01:00
|
|
|
# OpenELEC is free software: you can redistribute it and/or modify
|
2011-01-09 18:44:37 +01:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2013-12-21 21:51:48 +01:00
|
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
2011-01-09 18:44:37 +01:00
|
|
|
#
|
2013-12-21 21:51:48 +01:00
|
|
|
# OpenELEC is distributed in the hope that it will be useful,
|
2011-01-09 18:44:37 +01:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2013-12-21 21:51:48 +01:00
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-09 18:44:37 +01:00
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2013-12-21 21:51:48 +01:00
|
|
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
2011-01-09 18:44:37 +01:00
|
|
|
################################################################################
|
|
|
|
|
|
2013-12-18 17:25:18 +01:00
|
|
|
# create directories
|
|
|
|
|
/bin/busybox mkdir -p /dev
|
|
|
|
|
/bin/busybox mkdir -p /proc
|
|
|
|
|
/bin/busybox mkdir -p /sys
|
|
|
|
|
/bin/busybox mkdir -p /flash
|
|
|
|
|
/bin/busybox mkdir -p /sysroot
|
|
|
|
|
/bin/busybox mkdir -p /storage
|
|
|
|
|
|
2013-11-02 16:11:09 +02:00
|
|
|
# mount all needed special filesystems
|
2013-03-27 23:15:54 +01:00
|
|
|
/bin/busybox mount -t devtmpfs devtmpfs /dev
|
|
|
|
|
/bin/busybox mount -t proc proc /proc
|
|
|
|
|
/bin/busybox mount -t sysfs sysfs /sys
|
2009-03-18 13:02:53 +01:00
|
|
|
|
2013-11-02 16:11:09 +02:00
|
|
|
# set needed variables
|
2013-01-11 14:05:20 +01:00
|
|
|
MODULE_DIR=/lib/modules
|
|
|
|
|
|
|
|
|
|
UPDATE_DIR=/storage/.update
|
|
|
|
|
UPDATE_KERNEL="KERNEL"
|
|
|
|
|
UPDATE_SYSTEM="SYSTEM"
|
|
|
|
|
IMAGE_KERNEL="KERNEL"
|
|
|
|
|
IMAGE_SYSTEM="SYSTEM"
|
|
|
|
|
|
2013-03-17 17:20:25 +01:00
|
|
|
BOOT_STEP="start"
|
2013-01-11 14:05:20 +01:00
|
|
|
MD5_FAILED="0"
|
|
|
|
|
MD5_NOCHECK="0"
|
2013-03-05 12:49:50 +01:00
|
|
|
SIZE_FAILED="0"
|
2014-06-07 00:35:20 +02:00
|
|
|
RUN_FSCK="yes"
|
|
|
|
|
RUN_FSCK_DISKS=""
|
2013-01-11 14:05:20 +01:00
|
|
|
|
|
|
|
|
NBD_DEVS="0"
|
2013-03-05 12:49:50 +01:00
|
|
|
FLASH_FREE_MIN="5"
|
2013-01-11 14:05:20 +01:00
|
|
|
|
2014-07-25 07:28:13 +02:00
|
|
|
INSTALLED_MEMORY=`cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}'`
|
|
|
|
|
SYSTEM_TORAM_LIMIT=1024000
|
|
|
|
|
|
2015-04-05 18:41:40 +03:00
|
|
|
LIVE="no"
|
|
|
|
|
|
2013-11-02 16:11:09 +02:00
|
|
|
# hide kernel log messages on console
|
2010-12-11 15:02:03 +01:00
|
|
|
echo '1 4 1 7' > /proc/sys/kernel/printk
|
|
|
|
|
|
2015-06-17 10:46:11 +03:00
|
|
|
# set ondemand up_threshold
|
|
|
|
|
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ] ; then
|
|
|
|
|
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
|
|
|
|
fi
|
|
|
|
|
|
2014-12-17 05:05:20 +01:00
|
|
|
# run platform_init script if exists
|
|
|
|
|
if [ -f "./platform_init" ]; then
|
|
|
|
|
./platform_init
|
|
|
|
|
fi
|
|
|
|
|
|
2013-11-02 16:11:09 +02:00
|
|
|
# clear screen and hide cursor
|
2013-05-25 19:03:12 +03:00
|
|
|
clear
|
2015-01-12 13:24:58 +02:00
|
|
|
if [ -f /sys/devices/virtual/graphics/fbcon/cursor_blink ] ; then
|
|
|
|
|
echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
|
|
|
|
|
fi
|
2012-02-23 21:36:21 +01:00
|
|
|
|
2013-11-02 16:11:09 +02:00
|
|
|
# parse command line arguments
|
2009-09-22 07:07:58 +02:00
|
|
|
for arg in $(cat /proc/cmdline); do
|
|
|
|
|
case $arg in
|
2012-05-04 07:17:07 +02:00
|
|
|
BOOT_IMAGE=*)
|
|
|
|
|
IMAGE_KERNEL="${arg#*=}"
|
|
|
|
|
;;
|
|
|
|
|
SYSTEM_IMAGE=*)
|
|
|
|
|
IMAGE_SYSTEM="${arg#*=}"
|
|
|
|
|
;;
|
2012-04-12 15:01:57 +02:00
|
|
|
boot=*)
|
|
|
|
|
boot="${arg#*=}"
|
2013-09-23 22:46:08 +03:00
|
|
|
case $boot in
|
2014-08-17 15:54:20 +02:00
|
|
|
ISCSI=*|NBD=*|NFS=*)
|
2013-09-23 22:46:08 +03:00
|
|
|
UPDATE_DISABLED=yes
|
2014-04-30 09:16:56 +02:00
|
|
|
FLASH_NETBOOT=yes
|
2013-09-23 22:46:08 +03:00
|
|
|
;;
|
2014-06-07 00:35:20 +02:00
|
|
|
/dev/*|LABEL=*|UUID=*)
|
|
|
|
|
RUN_FSCK_DISKS="$RUN_FSCK_DISKS $boot"
|
|
|
|
|
;;
|
2013-09-23 22:46:08 +03:00
|
|
|
esac
|
2012-04-12 15:01:57 +02:00
|
|
|
;;
|
|
|
|
|
disk=*)
|
|
|
|
|
disk="${arg#*=}"
|
2013-10-18 19:43:12 +03:00
|
|
|
case $disk in
|
2014-08-17 15:54:20 +02:00
|
|
|
ISCSI=*|NBD=*|NFS=*)
|
2013-10-18 19:43:12 +03:00
|
|
|
STORAGE_NETBOOT=yes
|
|
|
|
|
;;
|
2014-06-07 00:35:20 +02:00
|
|
|
/dev/*|LABEL=*|UUID=*)
|
|
|
|
|
RUN_FSCK_DISKS="$RUN_FSCK_DISKS $disk"
|
|
|
|
|
;;
|
2013-10-18 19:43:12 +03:00
|
|
|
esac
|
2012-04-12 15:01:57 +02:00
|
|
|
;;
|
2014-04-25 11:15:19 +02:00
|
|
|
wol_mac=*)
|
|
|
|
|
wol_mac="${arg#*=}"
|
|
|
|
|
;;
|
|
|
|
|
wol_wait=*)
|
|
|
|
|
wol_wait="${arg#*=}"
|
|
|
|
|
;;
|
2013-08-18 19:41:24 +02:00
|
|
|
textmode)
|
2015-01-19 11:53:58 +02:00
|
|
|
INIT_UNIT="--unit=textmode.target"
|
2013-08-18 19:41:24 +02:00
|
|
|
;;
|
2013-08-04 14:33:02 +02:00
|
|
|
installer)
|
2015-01-19 11:53:58 +02:00
|
|
|
INIT_UNIT="--unit=installer.target"
|
2013-08-04 14:33:02 +02:00
|
|
|
;;
|
2009-09-22 07:07:58 +02:00
|
|
|
debugging)
|
|
|
|
|
DEBUG=yes
|
|
|
|
|
;;
|
2011-12-22 20:38:15 +01:00
|
|
|
progress)
|
|
|
|
|
PROGRESS=yes
|
2013-08-04 14:33:02 +02:00
|
|
|
INIT_ARGS="$INIT_ARGS --show-status=1"
|
2011-12-22 20:38:15 +01:00
|
|
|
;;
|
2014-06-07 00:35:20 +02:00
|
|
|
nofsck)
|
|
|
|
|
RUN_FSCK=no
|
|
|
|
|
;;
|
2012-05-03 13:03:33 +02:00
|
|
|
nosplash)
|
|
|
|
|
SPLASH=no
|
|
|
|
|
;;
|
2014-07-25 07:28:13 +02:00
|
|
|
noram)
|
|
|
|
|
SYSTEM_TORAM=no
|
|
|
|
|
;;
|
2015-04-05 18:41:40 +03:00
|
|
|
live)
|
|
|
|
|
LIVE=yes
|
|
|
|
|
;;
|
2012-03-19 18:55:38 +01:00
|
|
|
overlay)
|
|
|
|
|
OVERLAY=yes
|
|
|
|
|
;;
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
break=*)
|
|
|
|
|
BREAK="${arg#*=}"
|
2011-04-05 01:21:26 +02:00
|
|
|
;;
|
2009-09-22 07:07:58 +02:00
|
|
|
esac
|
|
|
|
|
done
|
2009-03-18 13:02:53 +01:00
|
|
|
|
2012-03-20 17:55:48 +01:00
|
|
|
if test "$DEBUG" = "yes"; then
|
|
|
|
|
exec 3>&1
|
|
|
|
|
else
|
|
|
|
|
exec 3>/dev/null
|
|
|
|
|
fi
|
|
|
|
|
SILENT_OUT=3
|
|
|
|
|
|
2009-09-22 07:07:58 +02:00
|
|
|
progress() {
|
2011-12-22 20:38:15 +01:00
|
|
|
if test "$PROGRESS" = "yes"; then
|
2009-09-22 07:07:58 +02:00
|
|
|
echo "### $1 ###"
|
2009-03-18 13:02:53 +01:00
|
|
|
fi
|
2009-09-22 07:07:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
debug_shell() {
|
|
|
|
|
echo "### Starting debugging shell... type exit to quit ###"
|
2012-02-23 21:36:21 +01:00
|
|
|
|
|
|
|
|
# show cursor
|
2013-11-02 16:11:09 +02:00
|
|
|
echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
|
2012-02-23 21:36:21 +01:00
|
|
|
|
2013-05-25 19:03:12 +03:00
|
|
|
sh </dev/tty1 >/dev/tty1 2>&1
|
2009-09-22 07:07:58 +02:00
|
|
|
}
|
|
|
|
|
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
error() {
|
2013-11-02 16:11:09 +02:00
|
|
|
# Display fatal error message
|
|
|
|
|
# $1:action which caused error, $2:message
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
echo "*** Error in $BOOT_STEP: $1: $2 ***"
|
2013-08-15 21:12:07 +03:00
|
|
|
debug_shell
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break_after() {
|
2013-11-02 16:11:09 +02:00
|
|
|
# Start debug shell after boot step $1
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
case $BREAK in
|
|
|
|
|
all|*$1*)
|
|
|
|
|
debug_shell
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Mount handlers
|
|
|
|
|
# All handlers take the following parameters:
|
|
|
|
|
# $1:target, $2:mountpoint, $3:mount options, [$4:fs type]
|
|
|
|
|
|
|
|
|
|
mount_common() {
|
2013-11-02 16:11:09 +02:00
|
|
|
# Common mount handler, handles block devices and filesystem images
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
MOUNT_OPTIONS="-o $3"
|
|
|
|
|
[ -n "$4" ] && MOUNT_OPTIONS="-t $4 $MOUNT_OPTIONS"
|
|
|
|
|
|
2012-05-02 07:35:30 +02:00
|
|
|
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
ERR_ENV=1
|
|
|
|
|
|
2013-05-25 19:03:12 +03:00
|
|
|
mount $MOUNT_OPTIONS $1 $2 >&$SILENT_OUT 2>&1
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
[ "$?" -eq "0" ] && ERR_ENV=0 && break
|
|
|
|
|
|
2013-05-25 19:03:12 +03:00
|
|
|
usleep 1000000
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
done
|
|
|
|
|
[ "$ERR_ENV" -ne "0" ] && error "mount_common" "Could not mount $1"
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-26 02:27:35 +02:00
|
|
|
get_iscsistart_options() {
|
2013-11-02 16:11:09 +02:00
|
|
|
# Convert kernel commandline ISCSI= options to iscsistart options
|
2012-03-26 02:27:35 +02:00
|
|
|
IFS_SAVE="$IFS"
|
|
|
|
|
IFS=,
|
|
|
|
|
|
|
|
|
|
for arg in $1; do
|
|
|
|
|
val="${arg#*=}"
|
|
|
|
|
case "$arg" in
|
|
|
|
|
iscsi_initiator=*)
|
|
|
|
|
option="-i"
|
|
|
|
|
;;
|
|
|
|
|
iscsi_target_name=*)
|
|
|
|
|
option="-t"
|
|
|
|
|
;;
|
|
|
|
|
iscsi_target_ip=*)
|
|
|
|
|
option="-a"
|
|
|
|
|
;;
|
|
|
|
|
iscsi_target_port=*)
|
|
|
|
|
option="-p"
|
|
|
|
|
;;
|
|
|
|
|
iscsi_target_group=*)
|
|
|
|
|
option="-g"
|
|
|
|
|
;;
|
|
|
|
|
iscsi_username=*)
|
|
|
|
|
option="-u"
|
|
|
|
|
;;
|
|
|
|
|
iscsi_password=*)
|
|
|
|
|
option="-w"
|
|
|
|
|
;;
|
|
|
|
|
iscsi_in_username=*)
|
|
|
|
|
option="-U"
|
|
|
|
|
;;
|
|
|
|
|
iscsi_in_password=*)
|
|
|
|
|
option="-W"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
echo "$option $val"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
IFS="$IFS_SAVE"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mount_iscsi() {
|
2013-11-02 16:11:09 +02:00
|
|
|
# Mount iSCSI target
|
2012-03-26 02:27:35 +02:00
|
|
|
ISCSI_DEV="${1##*,}"
|
|
|
|
|
ISCSI_OPTIONS="${1%,*}"
|
|
|
|
|
|
|
|
|
|
if [ ! -f "/sbin/iscsistart" ]; then
|
|
|
|
|
error "iscsistart" "iSCSI support not available"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$ISCSI_OPTIONS" = "auto" ]; then
|
|
|
|
|
progress "Network configuration based on iBFT"
|
|
|
|
|
/sbin/iscsistart -N >&$SILENT_OUT 2>&1 || \
|
|
|
|
|
error "iscsistart" "Unable to configure network"
|
|
|
|
|
progress "iSCSI auto connect based on iBFT"
|
|
|
|
|
/sbin/iscsistart -b >&$SILENT_OUT 2>&1 || \
|
|
|
|
|
error "iscsistart" "Unable to auto connect"
|
|
|
|
|
else
|
|
|
|
|
/sbin/iscsistart $(get_iscsistart_options "$ISCSI_OPTIONS") >&$SILENT_OUT 2>&1 || \
|
|
|
|
|
error "iscsistart" "Unable to connect to ISCSI target"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
mount_common "$ISCSI_DEV" "$2" "$3" "$4"
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-19 17:51:26 +01:00
|
|
|
mount_nbd() {
|
|
|
|
|
# Mount NBD device
|
|
|
|
|
NBD_SERVER="${1%%:*}"
|
|
|
|
|
NBD_PORT="${1#*:}"
|
|
|
|
|
NBD_DEV="/dev/nbd$NBD_DEVS"
|
|
|
|
|
|
2013-05-25 19:03:12 +03:00
|
|
|
nbd-client $NBD_SERVER $NBD_PORT $NBD_DEV >&$SILENT_OUT 2>&1 || \
|
2012-03-19 17:51:26 +01:00
|
|
|
error "nbd-client" "Could not connect to NBD server $1"
|
|
|
|
|
|
|
|
|
|
mount_common "$NBD_DEV" "$2" "$3" "$4"
|
|
|
|
|
|
|
|
|
|
NBD_DEVS=$(( ${NBD_DEVS} + 1 ))
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-19 17:54:48 +01:00
|
|
|
mount_nfs() {
|
2013-11-02 16:11:09 +02:00
|
|
|
# Mount NFS export
|
2012-03-25 14:28:11 +02:00
|
|
|
NFS_EXPORT="${1%%,*}"
|
|
|
|
|
NFS_OPTIONS="${1#*,}"
|
2012-03-19 17:54:48 +01:00
|
|
|
|
2012-03-25 14:28:11 +02:00
|
|
|
[ "$NFS_OPTIONS" = "$1" ] && NFS_OPTIONS=
|
|
|
|
|
|
2014-03-05 15:59:40 +02:00
|
|
|
mount_common "$NFS_EXPORT" "$2" "$3,nolock,soft,timeo=3,retrans=2,rsize=32768,wsize=32768,$NFS_OPTIONS" "nfs"
|
2012-03-19 17:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-27 01:47:47 +01:00
|
|
|
mount_ubifs() {
|
|
|
|
|
mount_common "$1" "$2" "$3" "ubifs"
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-22 07:07:58 +02:00
|
|
|
mount_part() {
|
2013-11-02 16:11:09 +02:00
|
|
|
# Mount a local or network filesystem
|
|
|
|
|
# $1:[TYPE=]target, $2:mountpoint, $3:mount options, [$4:fs type]
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
progress "mount filesystem $1 ..."
|
2012-03-20 21:46:58 +01:00
|
|
|
|
|
|
|
|
MOUNT_TARGET="${1#*=}"
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
case $1 in
|
2015-02-27 01:47:47 +01:00
|
|
|
/dev/ubi*)
|
|
|
|
|
MOUNT_CMD="mount_ubifs"
|
|
|
|
|
MOUNT_TARGET="$1"
|
|
|
|
|
RUN_FSCK="no"
|
|
|
|
|
;;
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
LABEL=*|UUID=*|/*)
|
|
|
|
|
MOUNT_CMD="mount_common"
|
|
|
|
|
MOUNT_TARGET="$1"
|
|
|
|
|
;;
|
2012-03-26 02:27:35 +02:00
|
|
|
ISCSI=*)
|
|
|
|
|
MOUNT_CMD="mount_iscsi"
|
|
|
|
|
;;
|
2012-03-19 17:51:26 +01:00
|
|
|
NBD=*)
|
|
|
|
|
MOUNT_CMD="mount_nbd"
|
|
|
|
|
;;
|
2012-03-19 17:54:48 +01:00
|
|
|
NFS=*)
|
|
|
|
|
MOUNT_CMD="mount_nfs"
|
|
|
|
|
;;
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
*)
|
|
|
|
|
error "mount_part" "Unknown filesystem $1"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
$MOUNT_CMD "$MOUNT_TARGET" "$2" "$3" "$4"
|
2009-09-22 07:07:58 +02:00
|
|
|
}
|
|
|
|
|
|
2015-05-28 18:18:21 +02:00
|
|
|
update_file() {
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
if [ -f "$UPDATE_DIR/$2" -a -f "$3" ]; then
|
2009-09-28 14:10:32 +02:00
|
|
|
echo "updating $1..."
|
2013-11-02 16:11:09 +02:00
|
|
|
mount -o remount,rw /flash
|
2013-11-03 00:49:29 +02:00
|
|
|
mv $UPDATE_DIR/$2 $3 2>/dev/null
|
2013-11-02 16:11:09 +02:00
|
|
|
# loopback file needs writable /flash all the time
|
|
|
|
|
if [ "${disk%%=*}" != "FILE" ]; then
|
|
|
|
|
mount -o remount,ro /flash
|
|
|
|
|
fi
|
|
|
|
|
sync
|
2009-09-22 07:07:58 +02:00
|
|
|
fi
|
|
|
|
|
}
|
2009-09-28 14:10:32 +02:00
|
|
|
|
2015-05-28 18:18:21 +02:00
|
|
|
update_partition() {
|
|
|
|
|
if [ -f "$UPDATE_DIR/$2" -a -b "$3" ]; then
|
|
|
|
|
echo "updating $1..."
|
|
|
|
|
dd if="$UPDATE_DIR/$2" of="$3"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-07 01:52:39 +02:00
|
|
|
update_bootloader() {
|
2013-05-25 19:01:31 +03:00
|
|
|
export BOOT_ROOT="/flash"
|
|
|
|
|
export SYSTEM_ROOT="/sysroot"
|
2012-08-07 01:52:39 +02:00
|
|
|
|
2013-05-25 19:01:31 +03:00
|
|
|
mount_part "/flash/$IMAGE_SYSTEM" "/sysroot" "ro,loop"
|
2012-08-07 01:52:39 +02:00
|
|
|
|
2013-05-25 19:01:31 +03:00
|
|
|
if [ -f $SYSTEM_ROOT/usr/share/bootloader/update.sh ]; then
|
|
|
|
|
echo "updating Bootloader..."
|
2013-11-02 16:11:09 +02:00
|
|
|
sh $SYSTEM_ROOT/usr/share/bootloader/update.sh
|
|
|
|
|
sync
|
2012-08-07 01:52:39 +02:00
|
|
|
fi
|
2013-05-25 19:01:31 +03:00
|
|
|
|
|
|
|
|
umount /sysroot
|
2012-08-07 01:52:39 +02:00
|
|
|
}
|
|
|
|
|
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
load_modules() {
|
|
|
|
|
progress "Loading kernel modules"
|
2012-03-20 21:46:58 +01:00
|
|
|
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
[ ! -f "/etc/modules" ] && return
|
|
|
|
|
for module in $(cat /etc/modules); do
|
|
|
|
|
progress "Loading kernel module $module"
|
2013-05-25 19:03:12 +03:00
|
|
|
insmod "$MODULE_DIR/$module.ko" || \
|
2012-05-15 00:12:38 +02:00
|
|
|
progress "... Failed to load kernel module $module, skipping"
|
2011-04-05 01:21:26 +02:00
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-03 13:03:33 +02:00
|
|
|
load_splash() {
|
2013-09-30 03:23:11 +02:00
|
|
|
if [ ! "$SPLASH" = "no" ]; then
|
2014-02-22 14:47:17 +02:00
|
|
|
progress "Loading bootsplash"
|
|
|
|
|
|
2013-09-30 03:23:11 +02:00
|
|
|
SPLASHIMAGE="/splash/splash-full.png"
|
2012-05-03 22:58:23 +02:00
|
|
|
|
2013-09-30 03:23:11 +02:00
|
|
|
# load uvesafb module if needed
|
|
|
|
|
if [ -f "$MODULE_DIR/uvesafb.ko" -a ! -e /dev/fb0 ]; then
|
|
|
|
|
progress "Loading kernel module uvesafb.ko"
|
2013-11-02 16:11:09 +02:00
|
|
|
insmod "$MODULE_DIR/uvesafb.ko" || \
|
|
|
|
|
progress "... Failed to load kernel module uvesafb, skipping"
|
2013-09-30 03:23:11 +02:00
|
|
|
|
|
|
|
|
# set framebuffer to a default resolution (1024x768-32)
|
2013-01-02 22:55:01 +01:00
|
|
|
if [ ! "$SWITCH_FRAMEBUFFER" = "no" ]; then
|
|
|
|
|
fbset -g 1024 768 1024 768 32
|
2013-09-30 03:23:11 +02:00
|
|
|
SPLASHIMAGE="/splash/splash-1024.png"
|
2013-01-02 22:55:01 +01:00
|
|
|
fi
|
2013-09-30 03:23:11 +02:00
|
|
|
fi
|
2012-05-03 13:03:33 +02:00
|
|
|
|
2013-09-30 03:23:11 +02:00
|
|
|
if [ -e /dev/fb0 ]; then
|
|
|
|
|
# load splash
|
2012-05-03 22:58:23 +02:00
|
|
|
if [ -f /flash/oemsplash.png ]; then
|
|
|
|
|
SPLASHIMAGE="/flash/oemsplash.png"
|
|
|
|
|
elif [ -f /splash/splash.conf ]; then
|
|
|
|
|
. /splash/splash.conf
|
|
|
|
|
fi
|
|
|
|
|
|
2013-02-03 01:36:27 +01:00
|
|
|
ply-image $SPLASHIMAGE > /dev/null 2>&1
|
2013-09-30 03:23:11 +02:00
|
|
|
fi
|
2012-05-03 13:03:33 +02:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-07 17:10:42 +02:00
|
|
|
do_reboot() {
|
|
|
|
|
echo "System reboots now..."
|
|
|
|
|
|
|
|
|
|
# syncing filesystem
|
|
|
|
|
sync
|
|
|
|
|
|
|
|
|
|
# unmount filesystems
|
|
|
|
|
if /bin/busybox mountpoint -q /flash ; then
|
|
|
|
|
/bin/busybox umount /flash
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if /bin/busybox mountpoint -q /storage ; then
|
|
|
|
|
/bin/busybox umount /storage
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
usleep 2000000
|
|
|
|
|
/bin/busybox reboot
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-08 13:48:46 +02:00
|
|
|
force_fsck() {
|
|
|
|
|
echo "Filesystem corruption has been detected"
|
|
|
|
|
echo "To prevent an automatic repair attempt continuing"
|
|
|
|
|
echo "press any key or power off your system within the next 120 seconds"
|
|
|
|
|
echo ""
|
|
|
|
|
read -t120 -n1
|
|
|
|
|
# The exit status is 0 if input is available
|
|
|
|
|
# The exit status is greater than 128 if the timeout is exceeded
|
|
|
|
|
if [ "$?" -ne "0" -o "$?" -gt "128" ] ; then
|
|
|
|
|
echo "repairing filesystem.."
|
|
|
|
|
echo ""
|
|
|
|
|
/sbin/fsck -T -M -y $RUN_FSCK_DISKS
|
|
|
|
|
FSCK_RET="$?"
|
|
|
|
|
if [ "$(( $FSCK_RET & 8 ))" = 8 ] ; then
|
|
|
|
|
# fubar
|
|
|
|
|
echo "Forced fsck failed. Your system is broken beyond repair"
|
|
|
|
|
echo "Please re-install OpenELEC"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Press enter to shutdown now"
|
|
|
|
|
echo ""
|
|
|
|
|
read fubar
|
|
|
|
|
poweroff
|
|
|
|
|
fi
|
|
|
|
|
do_reboot
|
|
|
|
|
else
|
|
|
|
|
echo "shutting down..."
|
|
|
|
|
sleep 5
|
|
|
|
|
sync
|
|
|
|
|
poweroff
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-07 02:27:42 +02:00
|
|
|
check_disks() {
|
2014-06-07 00:35:20 +02:00
|
|
|
if [ "$RUN_FSCK" = "yes" -a -n "$RUN_FSCK_DISKS" ]; then
|
|
|
|
|
progress "Checking disk(s): $RUN_FSCK_DISKS"
|
|
|
|
|
/sbin/fsck -T -M -p -a $RUN_FSCK_DISKS > /dev/null 2>&1
|
|
|
|
|
FSCK_RET="$?"
|
2013-10-07 02:27:42 +02:00
|
|
|
|
2015-02-08 13:48:46 +02:00
|
|
|
# FSCK_RET is the bit-wise OR of the exit codes for each filesystem that is checked.
|
2015-02-22 23:57:36 +02:00
|
|
|
if [ "$(( $FSCK_RET & 4 ))" = 4 ] ; then
|
2015-02-08 13:48:46 +02:00
|
|
|
# errors left
|
|
|
|
|
force_fsck
|
|
|
|
|
elif [ "$(( $FSCK_RET & 2 ))" = 2 ] ; then
|
|
|
|
|
# reboot needed
|
|
|
|
|
echo "filesystem repaired, reboot needed..."
|
|
|
|
|
do_reboot
|
|
|
|
|
elif [ "$(( $FSCK_RET & 1 ))" = 1 ] ; then
|
|
|
|
|
# filesystem errors corrected
|
|
|
|
|
progress "filesystem errors corrected , continuing..."
|
|
|
|
|
elif [ "$(( $FSCK_RET & 0 ))" = 0 ] ; then
|
|
|
|
|
# no errors found
|
|
|
|
|
progress "no filesystem errors found, continuing..."
|
|
|
|
|
fi
|
2013-10-07 02:27:42 +02:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-30 09:16:56 +02:00
|
|
|
wakeonlan() {
|
|
|
|
|
if [ "$STORAGE_NETBOOT" = "yes" ]; then
|
|
|
|
|
wol_ip=${disk%:*}
|
|
|
|
|
wol_ip=${wol_ip#*=}
|
|
|
|
|
elif [ "$FLASH_NETBOOT" = "yes" ]; then
|
|
|
|
|
wol_ip=${boot%:*}
|
|
|
|
|
wol_ip=${wol_ip#*=}
|
|
|
|
|
else
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
2014-06-07 00:38:33 +02:00
|
|
|
|
2014-04-30 09:16:56 +02:00
|
|
|
if [ -n "$wol_ip" -a -n "$wol_mac" -a -n "$wol_wait" ]; then
|
|
|
|
|
progress "Sending Magic Packet (WOL) if needed"
|
|
|
|
|
|
|
|
|
|
if ! ping -q -c 2 "$wol_ip" &>/dev/null; then
|
|
|
|
|
ether-wake "$wol_mac"
|
|
|
|
|
sleep "$wol_wait"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-06 18:28:28 +02:00
|
|
|
mount_flash() {
|
|
|
|
|
progress "Mounting flash"
|
2012-03-20 21:46:58 +01:00
|
|
|
|
2014-04-30 09:16:56 +02:00
|
|
|
wakeonlan
|
|
|
|
|
|
2012-06-19 07:48:40 +02:00
|
|
|
mount_part "$boot" "/flash" "ro,noatime"
|
2012-08-06 18:28:28 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-07 00:38:33 +02:00
|
|
|
mount_storage() {
|
2012-08-06 18:28:28 +02:00
|
|
|
progress "Mounting storage"
|
2012-03-19 18:55:38 +01:00
|
|
|
|
2015-04-05 18:41:40 +03:00
|
|
|
if [ "$LIVE" = "yes" ]; then
|
|
|
|
|
# mount tmpfs and exit early. disk=xx is not allowed in live mode
|
|
|
|
|
mount -t tmpfs none /storage
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
2014-04-30 09:16:56 +02:00
|
|
|
wakeonlan
|
|
|
|
|
|
2012-03-20 21:46:58 +01:00
|
|
|
if [ -n "$disk" ]; then
|
|
|
|
|
if [ -n "$OVERLAY" ]; then
|
2013-05-25 19:03:12 +03:00
|
|
|
OVERLAY_DIR=`cat /sys/class/net/eth0/address | tr -d :`
|
2012-03-20 19:57:09 +01:00
|
|
|
|
2012-06-19 07:48:40 +02:00
|
|
|
mount_part "$disk" "/storage" "rw,noatime"
|
2012-03-20 21:46:58 +01:00
|
|
|
mkdir -p /storage/$OVERLAY_DIR
|
2013-05-25 19:03:12 +03:00
|
|
|
umount /storage
|
2012-03-20 21:46:58 +01:00
|
|
|
|
2013-11-02 16:11:09 +02:00
|
|
|
# split $disk into $target,$options so we can append $OVERLAY_DIR
|
2012-03-20 21:46:58 +01:00
|
|
|
options="${disk#*,}"
|
|
|
|
|
target="${disk%%,*}"
|
|
|
|
|
if [ "$options" = "$disk" ]; then
|
|
|
|
|
disk="$target/$OVERLAY_DIR"
|
|
|
|
|
else
|
|
|
|
|
disk="$target/$OVERLAY_DIR,$options"
|
|
|
|
|
fi
|
2012-03-20 19:57:09 +01:00
|
|
|
fi
|
2012-06-19 07:48:40 +02:00
|
|
|
mount_part "$disk" "/storage" "rw,noatime"
|
2015-04-05 20:30:52 +03:00
|
|
|
else
|
|
|
|
|
# /storage should always be writable
|
|
|
|
|
mount -t tmpfs none /storage
|
2012-03-20 21:46:58 +01:00
|
|
|
fi
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
}
|
2011-05-09 12:00:24 +02:00
|
|
|
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
check_update() {
|
|
|
|
|
progress "Checking for updates"
|
2012-03-20 21:46:58 +01:00
|
|
|
|
2013-11-02 16:02:19 +02:00
|
|
|
UPDATE_TAR=`ls -1 "$UPDATE_DIR"/*.tar 2>/dev/null | head -n 1`
|
|
|
|
|
if [ -f "$UPDATE_DIR/$UPDATE_KERNEL" -a -f "$UPDATE_DIR/$UPDATE_SYSTEM" -o -f "$UPDATE_TAR" ] ; then
|
2013-09-23 21:56:54 +03:00
|
|
|
if [ "$UPDATE_DISABLED" = "yes" ] ; then
|
|
|
|
|
rm -rf $UPDATE_DIR/[0-9a-zA-Z]* &>/dev/null
|
|
|
|
|
echo "Updating not supported on netboot. normal startup in 10s..."
|
|
|
|
|
sync
|
|
|
|
|
usleep 10000000
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
2013-11-02 16:02:19 +02:00
|
|
|
|
|
|
|
|
# check for .tar
|
|
|
|
|
if [ -f "$UPDATE_TAR" ] ; then
|
|
|
|
|
echo "Found new .tar archive. extracting..."
|
|
|
|
|
mkdir -p $UPDATE_DIR/.tmp &>/dev/null
|
|
|
|
|
tar -xf "$UPDATE_TAR" -C $UPDATE_DIR/.tmp &>/dev/null
|
|
|
|
|
mv $UPDATE_DIR/.tmp/*/target/* $UPDATE_DIR &>/dev/null
|
|
|
|
|
rm -f "$UPDATE_TAR" &>/dev/null
|
|
|
|
|
rm -rf $UPDATE_DIR/.tmp &>/dev/null
|
|
|
|
|
sync
|
|
|
|
|
if [ ! -f "$UPDATE_DIR/$UPDATE_KERNEL" -o ! -f "$UPDATE_DIR/$UPDATE_SYSTEM" ] ; then
|
|
|
|
|
echo "missing ${UPDATE_KERNEL} or ${UPDATE_SYSTEM}... normal startup in 10s"
|
|
|
|
|
sync
|
|
|
|
|
usleep 10000000
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2012-05-03 14:50:34 +03:00
|
|
|
if [ -f "$UPDATE_DIR/.nocheck" ] ; then
|
|
|
|
|
MD5_NOCHECK="1"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# check md5 sums if .nocheck doesn't exist
|
2013-11-02 16:11:09 +02:00
|
|
|
if [ "$MD5_NOCHECK" -eq "0" ] ; then
|
|
|
|
|
if [ -f "$UPDATE_DIR/${UPDATE_KERNEL}.md5" -a -f "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" ] ; then
|
2013-11-30 18:19:16 +02:00
|
|
|
# *.md5 size-check
|
2013-12-01 18:47:43 +02:00
|
|
|
if [ ! -s "$UPDATE_DIR/${UPDATE_KERNEL}.md5" -o ! -s "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" ] ; then
|
2013-11-30 18:19:16 +02:00
|
|
|
echo "zero-sized .md5 file..."
|
|
|
|
|
MD5_FAILED="1"
|
|
|
|
|
else
|
|
|
|
|
sed -i 's#target#/storage/.update#g' "$UPDATE_DIR/${UPDATE_KERNEL}.md5"
|
|
|
|
|
sed -i 's#target#/storage/.update#g' "$UPDATE_DIR/${UPDATE_SYSTEM}.md5"
|
2012-05-03 14:50:34 +03:00
|
|
|
|
2013-11-30 18:19:16 +02:00
|
|
|
echo "Checking ${UPDATE_KERNEL}.md5..."
|
|
|
|
|
md5sum -c "$UPDATE_DIR/${UPDATE_KERNEL}.md5" || MD5_FAILED="1"
|
2012-05-03 14:50:34 +03:00
|
|
|
|
2013-11-30 18:19:16 +02:00
|
|
|
echo "Checking ${UPDATE_SYSTEM}.md5..."
|
|
|
|
|
md5sum -c "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" || MD5_FAILED="1"
|
|
|
|
|
fi
|
2013-11-02 16:11:09 +02:00
|
|
|
else
|
|
|
|
|
echo "missing ${UPDATE_KERNEL}.md5 or ${UPDATE_SYSTEM}.md5..."
|
|
|
|
|
MD5_FAILED="1"
|
|
|
|
|
fi
|
2012-05-03 14:50:34 +03:00
|
|
|
fi
|
|
|
|
|
|
2013-03-05 12:49:50 +01:00
|
|
|
# get sizes
|
2013-05-25 19:03:12 +03:00
|
|
|
FLASH_FREE=$(df /flash/ | awk '/[0-9]%/{print $4}')
|
2013-03-05 12:49:50 +01:00
|
|
|
FLASH_FREE=$(( $FLASH_FREE * 1024 ))
|
2015-05-28 18:18:21 +02:00
|
|
|
|
|
|
|
|
OLD_KERNEL="0"
|
|
|
|
|
if [ ! -b $IMAGE_KERNEL ]; then
|
|
|
|
|
OLD_KERNEL=$(stat -t "/flash/$IMAGE_KERNEL" | awk '{print $2}')
|
|
|
|
|
fi
|
|
|
|
|
|
2013-05-25 19:03:12 +03:00
|
|
|
OLD_SYSTEM=$(stat -t "/flash/$IMAGE_SYSTEM" | awk '{print $2}')
|
|
|
|
|
NEW_KERNEL=$(stat -t "$UPDATE_DIR/$UPDATE_KERNEL" | awk '{print $2}')
|
|
|
|
|
NEW_SYSTEM=$(stat -t "$UPDATE_DIR/$UPDATE_SYSTEM" | awk '{print $2}')
|
2013-03-05 12:49:50 +01:00
|
|
|
|
|
|
|
|
# old KERNEL+SYSTEM+free space - new KERNEL+SYSTEM must be higher then 5MB
|
|
|
|
|
# at least 5MB free after update
|
|
|
|
|
|
|
|
|
|
TMP_SIZE=$(($OLD_KERNEL+$OLD_SYSTEM+$FLASH_FREE-$NEW_KERNEL-$NEW_SYSTEM))
|
|
|
|
|
FLASH_FREE_MIN=$(($FLASH_FREE_MIN*1024*1024))
|
|
|
|
|
|
|
|
|
|
if [ $TMP_SIZE -ge $FLASH_FREE_MIN ]; then
|
|
|
|
|
echo "Checking size: OK"
|
|
|
|
|
else
|
|
|
|
|
echo "Checking size: FAILED"
|
|
|
|
|
SIZE_FAILED="1"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# update if size check is ok
|
|
|
|
|
if [ "$SIZE_FAILED" -eq "0" ] ; then
|
|
|
|
|
# update if md5 check is ok or .nocheck exists
|
|
|
|
|
if [ "$MD5_FAILED" -eq "0" -o "$MD5_NOCHECK" -eq "1" ] ; then
|
2015-05-28 18:18:21 +02:00
|
|
|
if [ -b $IMAGE_KERNEL ]; then
|
|
|
|
|
update_partition "Kernel" "$UPDATE_KERNEL" "$IMAGE_KERNEL"
|
|
|
|
|
else
|
|
|
|
|
update_file "Kernel" "$UPDATE_KERNEL" "/flash/$IMAGE_KERNEL"
|
|
|
|
|
fi
|
|
|
|
|
update_file "System" "$UPDATE_SYSTEM" "/flash/$IMAGE_SYSTEM"
|
2013-03-05 12:49:50 +01:00
|
|
|
update_bootloader
|
2014-06-28 21:43:35 +02:00
|
|
|
rm -rf $UPDATE_DIR/[0-9a-zA-Z]* &>/dev/null
|
2014-06-07 17:10:42 +02:00
|
|
|
do_reboot
|
2013-03-05 12:49:50 +01:00
|
|
|
else
|
2013-05-25 19:03:12 +03:00
|
|
|
rm -rf $UPDATE_DIR/[0-9a-zA-Z]* &>/dev/null
|
2013-03-05 12:49:50 +01:00
|
|
|
echo "md5 check failed. normal startup in 30s..."
|
2013-05-25 19:03:12 +03:00
|
|
|
sync
|
|
|
|
|
usleep 30000000
|
2013-03-05 12:49:50 +01:00
|
|
|
fi
|
2012-05-03 14:50:34 +03:00
|
|
|
else
|
2013-05-25 19:03:12 +03:00
|
|
|
rm -rf $UPDATE_DIR/[0-9a-zA-Z]* &>/dev/null
|
2013-03-05 12:49:50 +01:00
|
|
|
echo "size check failed. normal startup in 30s..."
|
2013-05-25 19:03:12 +03:00
|
|
|
sync
|
|
|
|
|
usleep 30000000
|
2012-05-03 14:50:34 +03:00
|
|
|
fi
|
|
|
|
|
fi
|
2011-04-05 01:21:26 +02:00
|
|
|
}
|
|
|
|
|
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
prepare_sysroot() {
|
|
|
|
|
progress "Preparing system"
|
|
|
|
|
|
2014-07-25 07:28:13 +02:00
|
|
|
if [ "$SYSTEM_TORAM" = "no" -o "$INSTALLED_MEMORY" -lt "$SYSTEM_TORAM_LIMIT" ]; then
|
|
|
|
|
mount_part "/flash/$IMAGE_SYSTEM" "/sysroot" "ro,loop"
|
|
|
|
|
else
|
|
|
|
|
cp /flash/$IMAGE_SYSTEM /dev/$IMAGE_SYSTEM
|
|
|
|
|
mount_part "/dev/$IMAGE_SYSTEM" "/sysroot" "ro,loop"
|
|
|
|
|
fi
|
|
|
|
|
|
2013-05-25 19:03:12 +03:00
|
|
|
mount --move /flash /sysroot/flash
|
2015-04-05 20:30:52 +03:00
|
|
|
mount --move /storage /sysroot/storage
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
|
2014-11-23 19:06:08 +02:00
|
|
|
if [ ! -d "/sysroot/lib/modules/$(uname -r)/" -a -f "/sysroot/usr/lib/systemd/systemd" ]; then
|
|
|
|
|
echo ""
|
|
|
|
|
echo "NEVER TOUCH boot= in extlinux.conf / cmdline.txt"
|
|
|
|
|
echo "if you dont know what you are doing"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "your installation is now broken"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "normal boot in 60s..."
|
|
|
|
|
usleep 60000000
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
2014-02-20 17:05:22 +01:00
|
|
|
[ -f "/sysroot/usr/lib/systemd/systemd" ] || error "final_check" "Could not find system."
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-17 17:20:25 +01:00
|
|
|
if [ "${boot%%=*}" = "FILE" ]; then
|
|
|
|
|
error "check arguments" "boot argument can't be FILE type..."
|
|
|
|
|
fi
|
|
|
|
|
|
2013-11-02 16:11:09 +02:00
|
|
|
# main boot sequence
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
for BOOT_STEP in \
|
|
|
|
|
load_modules \
|
2013-10-07 02:27:42 +02:00
|
|
|
check_disks \
|
2012-08-06 18:28:28 +02:00
|
|
|
mount_flash \
|
|
|
|
|
load_splash \
|
|
|
|
|
mount_storage \
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
check_update \
|
|
|
|
|
prepare_sysroot; do
|
|
|
|
|
$BOOT_STEP
|
|
|
|
|
[ -n "$DEBUG" ] && break_after $BOOT_STEP
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
BOOT_STEP=final
|
2009-03-18 13:02:53 +01:00
|
|
|
|
2015-01-12 21:55:58 +02:00
|
|
|
# log if booting from usb / removable storage
|
|
|
|
|
STORAGE=$(cat /proc/mounts | grep " /sysroot/storage " | awk '{print $1}' | awk -F '/' '{print $3}')
|
|
|
|
|
FLASH=$(cat /proc/mounts | grep " /sysroot/flash " | awk '{print $1}' | awk -F '/' '{print $3}')
|
|
|
|
|
for i in $STORAGE $FLASH ; do
|
|
|
|
|
if [ -n "$i" ] ; then
|
|
|
|
|
removable="/sys/class/block/*/$i/../removable"
|
|
|
|
|
if [ -e $removable ] ; then
|
|
|
|
|
if [ "$(cat $removable 2>/dev/null)" = "1" ] ; then
|
|
|
|
|
echo "### BIG FAT WARNING" > /dev/kmsg
|
|
|
|
|
echo "### $i is removable. suspend/resume may not work" > /dev/kmsg
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
2013-11-02 16:11:09 +02:00
|
|
|
# move some special filesystems
|
2011-09-19 11:37:38 +02:00
|
|
|
/bin/busybox mount --move /dev /sysroot/dev
|
|
|
|
|
/bin/busybox mount --move /proc /sysroot/proc
|
2011-09-19 16:34:14 +02:00
|
|
|
/bin/busybox mount --move /sys /sysroot/sys
|
2010-05-17 13:11:40 +02:00
|
|
|
|
2013-11-02 16:11:09 +02:00
|
|
|
# tell OE settings addon to disable updates
|
2013-09-23 21:56:54 +03:00
|
|
|
if [ "$UPDATE_DISABLED" = "yes" ] ; then
|
|
|
|
|
echo "" > /sysroot/dev/.update_disabled
|
|
|
|
|
fi
|
2013-11-02 16:11:09 +02:00
|
|
|
# swap can not be used over nfs.(see scripts/mount-swap)
|
2013-10-18 19:43:12 +03:00
|
|
|
if [ "$STORAGE_NETBOOT" = "yes" ] ; then
|
|
|
|
|
echo "" > /sysroot/dev/.storage_netboot
|
|
|
|
|
fi
|
2015-01-19 02:24:51 +02:00
|
|
|
|
|
|
|
|
if [ -f /sysroot/storage/.please_resize_me ] ; then
|
2015-01-19 20:09:22 +02:00
|
|
|
INIT_UNIT="--unit=fs-resize.target"
|
2015-01-19 02:24:51 +02:00
|
|
|
fi
|
2015-01-19 11:43:04 +02:00
|
|
|
|
|
|
|
|
BACKUP_FILE=`ls -1 /sysroot/storage/.restore/??????????????.tar 2>/dev/null | head -n 1`
|
|
|
|
|
if [ -f "$BACKUP_FILE" ] ; then
|
2015-01-19 11:53:58 +02:00
|
|
|
INIT_UNIT="--unit=backup-restore.target"
|
2015-01-19 11:43:04 +02:00
|
|
|
fi
|
2015-01-19 11:50:35 +02:00
|
|
|
|
|
|
|
|
if [ -f /sysroot/storage/.cache/reset_oe -o -f /sysroot/storage/.cache/reset_xbmc ] ; then
|
2015-01-19 11:53:58 +02:00
|
|
|
INIT_UNIT="--unit=factory-reset.target"
|
2015-01-19 11:50:35 +02:00
|
|
|
fi
|
2013-11-02 16:11:09 +02:00
|
|
|
# switch to new sysroot and start real init
|
2015-01-19 11:53:58 +02:00
|
|
|
exec /bin/busybox switch_root /sysroot /usr/lib/systemd/systemd $INIT_ARGS $INIT_UNIT
|
2009-11-06 15:29:05 +01:00
|
|
|
|
busybox-initramfs: reorganize init script in preparation for boot type handlers
Changes to kernel commandline parameters:
Remove legacy parameters, to be added back later if desired.
Add a new parameter: break=<all|step,step,...> which will cause a debugging
shell to be started after each or the specified boot steps.
Functions:
mount_part, mount_disk, mount_nbd: reorganize to use mount type handlers, which
will support specifying kernel parameters like boot=TYPE=target and
disk=TYPE=target. This initial commit only has mount_default, which supports
LABEL=label and UUID=uuid, as well as block devices /dev/* and image files.
error: show more meaningful error messages, containing the boot step and action
which caused the error.
If not debugging, halt the system. This prevents the error from causing more
damage further on in the boot sequence. If debugging, start a debugging shell.
update: make sure the file to update already exists at the destination, to
prevent clobbering a rootfs mounted on /flash, which can be the case when
mounting a mtd or NBD device.
load_modules: enable loading of kernel modules in early boot, e.g. xhci-hcd
to enable mount of USB3 devices on boot.
Add a simple boot step sequencer, which allows for starting a debugging shell
after each step.
Signed-off-by: Alain Kalker <a.c.kalker@gmail.com>
2012-03-19 17:22:23 +01:00
|
|
|
error "switch_root" "Error in initramfs. Could not switch to new root"
|