Moved network init to a separate bootscript

Enabled recovery serial console (tested on kgpe-d16)
Minor fix to kexec-boot to correct xen boot
Remove busybox power utils
This commit is contained in:
Francis Lam 2018-03-10 15:40:07 -08:00
parent 9c9b5bcd2b
commit e86123769b
No known key found for this signature in database
GPG Key ID: 0A59C698920806EB
7 changed files with 85 additions and 44 deletions

View File

@ -18,15 +18,15 @@ CONFIG_DROPBEAR=y
CONFIG_LINUX_USB=y
CONFIG_LINUX_E1000E=y
CONFIG_LINUX_PTY=y
CONFIG_BOOTSCRIPT=/bin/generic-init
export CONFIG_BOOTSCRIPT=/bin/generic-init
#export CONFIG_BOOTSCRIPT_NETWORK=/bin/network-init-recovery
CONFIG_BOOT_REQ_HASH=n
CONFIG_BOOT_REQ_ROLLBACK=n
CONFIG_BOOT_KERNEL_ADD="nohz=on console=ttyS1,115200n8 "
CONFIG_BOOT_KERNEL_REMOVE=""
CONFIG_BOOT_DEV="/dev/sda1"
CONFIG_USB_BOOT_DEV="/dev/sdb1"
CONFIG_BOOT_RECOVERY_SERIAL="/dev/ttyS0"
CONFIG_BOOT_LOCAL=y
export CONFIG_BOOT_REQ_HASH=n
export CONFIG_BOOT_REQ_ROLLBACK=n
export CONFIG_BOOT_KERNEL_ADD="nohz=on console=ttyS1,115200n8 "
export CONFIG_BOOT_KERNEL_REMOVE=""
export CONFIG_BOOT_DEV="/dev/sda1"
export CONFIG_USB_BOOT_DEV="/dev/sdb1"
export CONFIG_BOOT_RECOVERY_SERIAL="/dev/ttyS0"
#export CONFIG_BOOT_STATIC_IP=192.168.1.2

View File

@ -30,11 +30,13 @@ CONFIG_LINUX_ATA=y
CONFIG_LINUX_AHCI=y
export CONFIG_BOOTSCRIPT=/bin/generic-init
export CONFIG_BOOTSCRIPT_NETWORK=/bin/network-init-recovery
export CONFIG_BOOT_REQ_HASH=n
export CONFIG_BOOT_REQ_ROLLBACK=n
export CONFIG_BOOT_DEV="/dev/sda1"
export CONFIG_USB_BOOT_DEV="/dev/sdb1"
export CONFIG_BOOT_STATIC_IP=10.0.2.15
# You can ssh into the qemu instance by running
# ssh -p 5555 root@localhost

View File

@ -470,9 +470,9 @@ CONFIG_FEATURE_XARGS_SUPPORT_ARGS_FILE=y
# CONFIG_BOOTCHARTD is not set
# CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set
# CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set
CONFIG_HALT=y
CONFIG_POWEROFF=y
CONFIG_REBOOT=y
# CONFIG_HALT is not set
# CONFIG_POWEROFF is not set
# CONFIG_REBOOT is not set
# CONFIG_FEATURE_CALL_TELINIT is not set
CONFIG_TELINIT_PATH=""
# CONFIG_INIT is not set

View File

@ -66,16 +66,15 @@ do
firstval=`echo $line | cut -d\ -f2`
restval=`echo $line | cut -d\ -f3-`
if [ "$key" = "kernel" ]; then
fix_file_path
if [ "$kexectype" = "xen" ]; then
# always overload xen and with custom arguments
kexeccmd="$kexeccmd -l $bootdir$firstval"
# always use xen with custom arguments
kexeccmd="$kexeccmd -l $filepath"
kexeccmd="$kexeccmd --command-line \"no-real-mode reboot=no vga=current\""
elif [ "$kexectype" = "multiboot" ]; then
fix_file_path
kexeccmd="$kexeccmd -l $filepath"
kexeccmd="$kexeccmd --command-line \"$restval\""
else
fix_file_path
kexeccmd="$kexeccmd -l $filepath"
fi
fi

View File

@ -0,0 +1,29 @@
#!/bin/ash
# bring up the ethernet; maybe should do DHCP?
ifconfig lo 127.0.0.1
if [ -f /lib/modules/e1000.ko ]; then
insmod /lib/modules/e1000.ko
fi
if [ -f /lib/modules/e1000e.ko ]; then
insmod /lib/modules/e1000e.ko
fi
if [ -e /sys/class/net/eth0 ]; then
# Setup static IP
if [ ! -z "$CONFIG_BOOT_STATIC_IP" ]; then
ifconfig eth0 $CONFIG_BOOT_STATIC_IP
fi
# TODO: setup DHCP if available
ifconfig eth0 > /dev/ttyprintk
# Setup the ssh server, allow root logins and log to stderr
if [ ! -d /etc/dropbear ]; then
mkdir /etc/dropbear
fi
dropbear -B -R 2>/dev/ttyprintk
ifconfig eth0 | head -1 > /dev/tty0
fi

View File

@ -25,6 +25,10 @@ recovery() {
exec /bin/ash
}
pause_recovery() {
read -p 'Hit enter to proceed to recovery shell:'
recovery $*
}
pcrs() {
head -7 /sys/class/tpm/tpm0/pcrs

View File

@ -26,22 +26,6 @@ if [ ! -r /dev/ptmx ]; then
ln -s /dev/pts/ptmx /dev/ptmx
fi
# bring up the ethernet; maybe should do DHCP?
ifconfig lo 127.0.0.1
if [ -f /lib/modules/e1000.ko ]; then
insmod /lib/modules/e1000.ko
ifconfig eth0 10.0.2.15 # qemu
ifconfig eth0 > /dev/ttyprintk
# Setup the ssh server, allow root logins and log to stderr
if [ ! -d /etc/dropbear ]; then
mkdir /etc/dropbear
fi
dropbear -B -R 2>/dev/ttyprintk
ifconfig eth0 | head -1 > /dev/tty0
fi
# Recovery shells will erase anything from here
mkdir -p /tmp/secret
@ -67,11 +51,12 @@ if [ ! -z "$CONFIG_USB_BOOT_DEV" ]; then
echo >> /etc/fstab "$CONFIG_USB_BOOT_DEV /media auto defaults,ro 0 0"
fi
if [ ! -x "$CONFIG_BOOTSCRIPT" ]; then
recovery 'Boot script missing? Entering recovery shell'
# just in case...
tpm extend -ix 4 -ic recovery
exec /bin/ash
# Setup recovery serial shell
if [ ! -z "$CONFIG_BOOT_RECOVERY_SERIAL" ]; then
stty -F "$CONFIG_BOOT_RECOVERY_SERIAL" 115200
pause_recovery 'Console recovery shell' \
< "$CONFIG_BOOT_RECOVERY_SERIAL" \
> "$CONFIG_BOOT_RECOVERY_SERIAL" 2>&1 &
fi
# If the user has been holding down r, enter a recovery shell
@ -87,15 +72,37 @@ if [ "$boot_option" = "r" ]; then
# Start an interactive shell
recovery 'User requested recovery shell'
# just in case...
tpm extend -ix 4 -ic recovery
if [ "$CONFIG_TPM" = y ]; then
tpm extend -ix 4 -ic recovery
fi
exec /bin/ash
exit
fi
echo '***** Normal boot:' $CONFIG_BOOTSCRIPT
exec "$CONFIG_BOOTSCRIPT"
if [ ! -x "$CONFIG_BOOTSCRIPT" -a ! -x "$CONFIG_BOOTSCRIPT_NETWORK" ]; then
recovery 'Boot script missing? Entering recovery shell'
else
if [ -x "$CONFIG_BOOTSCRIPT_NETWORK" ]; then
echo '***** Network Boot:' $CONFIG_BOOTSCRIPT_NETWORK
$CONFIG_BOOTSCRIPT_NETWORK
echo '***** Network Boot Completed:' $CONFIG_BOOTSCRIPT_NETWORK
# not blocking
fi
if [ -x "$CONFIG_BOOTSCRIPT" ]; then
echo '***** Normal boot:' $CONFIG_BOOTSCRIPT
exec "$CONFIG_BOOTSCRIPT"
# We should never reach here, but just in case...
recovery 'Boot script failure? Entering recovery shell'
else
# wait for boot via network to occur
pause_recovery 'Override network boot. Entering recovery shell'
fi
fi
# We should never reach here, but just in case...
recovery 'Boot script failure? Entering recovery shell'
# belts and suspenders, just in case...
tpm extend -ix 4 -ic recovery
if [ "$CONFIG_TPM" = y ]; then
tpm extend -ix 4 -ic recovery
fi
exec /bin/ash