Skip to content

Commit

Permalink
WiP ISO boot add debugging to fix #1374.
Browse files Browse the repository at this point in the history
Shows isolinux paths to kernel and initrd invalid:
+++ Scanning for unsigned boot options
DEBUG: kexec-parse-boot /boot /boot/boot/isolinux/isolinux.cfg
TRACE: Under /bin/kexec-parse-boot
DEBUG: filedir= /boot/boot/isolinux
DEBUG: bootdir= /boot
DEBUG: bootlen= 5
DEBUG: appenddir= /boot/isolinux
TRACE:  search_entry: syslinux label: line= LABEL plus
TRACE:  search_entry: syslinux label: name=  plus
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL jwm
TRACE:  search_entry: syslinux label: name=  jwm
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL icewm
TRACE:  search_entry: syslinux label: name=  icewm
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL fluxbox
TRACE:  search_entry: syslinux label: name=  fluxbox
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL hackedbox
TRACE:  search_entry: syslinux label: name=  hackedbox
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL openbox
TRACE:  search_entry: syslinux label: name=  openbox
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL flwm
TRACE:  search_entry: syslinux label: name=  flwm
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL tiny
TRACE:  search_entry: syslinux label: name=  tiny
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL cxi
TRACE:  search_entry: syslinux label: name=  cxi
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL cxw
TRACE:  search_entry: syslinux label: name=  cxw
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL cxf
TRACE:  search_entry: syslinux label: name=  cxf
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL core
TRACE:  search_entry: syslinux label: name=  core
DEBUG: /boot/vmlinuz doesn't exist
TRACE:  search_entry: syslinux label: line= LABEL nocde
TRACE:  search_entry: syslinux label: name=  nocde
DEBUG: /boot/vmlinuz doesn't exist
Failed to parse any boot options
  • Loading branch information
tlaurion committed Apr 14, 2023
1 parent 8ff4b9a commit b862db9
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 26 deletions.
41 changes: 41 additions & 0 deletions initrd/bin/kexec-boot
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ adjust_cmd_line() {
adjusted_cmd_line="y"
}

if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
kexeccmd="$kexeccmd -d"
fi

module_number="1"
while read line
do
Expand All @@ -76,7 +80,39 @@ do
elif [ "$kexectype" = "multiboot" ]; then
kexeccmd="$kexeccmd -l $filepath"
kexeccmd="$kexeccmd --command-line \"$restval\""
elif [ "$kexectype" = "elf" ]; then
DEBUG "kexectype= $kexectype"
DEBUG "restval= $restval"
DEBUG "filepath= $filepath"
#kexeccmd="$kexeccmd -l $filepath --reset-vga --console-vga"
#kexeccmd="$kexeccmd --noefi --entry-32bit --reset-vga -l $filepath"
#kexeccmd="$kexeccmd --command-line \"$restval vga=current\""
#kexeccmd="$kexeccmd --noefi --reset-vga -l $filepath"
#kexeccmd="$kexeccmd --noefi --console-vga --reuse-video-type -l $filepath"
#kexeccmd="$kexeccmd --noefi --real-mode --console-vga --reuse-video-type -l $filepath"
#kexeccmd="$kexeccmd -l $filepath --command-line \"$restval vga=current\""
#kexeccmd="$kexeccmd -l $filepath"
#
#noefi: to skip second kernel efi setup. Let's say we wanted to kexec into ReactOS: https://www.phoronix.com/news/MTUzNDk
#reset-vga: to reset vga adapter prior of execing next kernel. Useful when no vga output or corrupted: http://www.solemnwarning.net/kexec-loader/readme.html
#reuse-video-type: force reuse screen_info unconditionally https://git.centos.org/rpms/kexec-tools/blob/8c3ceb714dbce12cc7c72e2ed728465e9a296314/f/SOURCES/kexec-tools-2.0.19-x86-Introduce-a-new-option-reuse-video-type.patch
#Qemu seems to have its own subset of problems, which also affect real hardware on kexec.
# https://bugzilla.redhat.com/show_bug.cgi?id=1335830#c11
# Solution here is to ask second kernel to set nomodeset so DRM is responsible to setup console.
# As this sounds, this might work but would not give us working console on real hardware
#acpi_rdsp problems?

#retry attempts:
#kexeccmd="$kexeccmd --entry-32bit --reset-vga -l $filepath"
#kexeccmd="$kexeccmd --entry-32bit --reuse-video-type -l $filepath"
#kexeccmd="$kexeccmd --noefi --reuse-video-type -l $filepath" #nomodeset added to board
# nomodeset just gives a warning on kernel init that no gpu will be initialized...
#kexeccmd="$kexeccmd --entry-32bit -l $filepath"
#TODO: how to dynamically setup noefi? Linuxboot can use u-root as EFI payload. Maybe not needed once resolved
kexeccmd="$kexeccmd --noefi --entry-32bit --console-vga -l $filepath"
DEBUG "kexeccmd= $kexeccmd"
else
DEBUG "unknown kexectype!!!!"
kexeccmd="$kexeccmd -l $filepath"
fi
fi
Expand Down Expand Up @@ -139,4 +175,9 @@ if [ "$CONFIG_TPM" = "y" ]; then
fi

echo "Starting the new kernel"
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
DEBUG "kexeccmd= $kexeccmd"
DO_WITH_DEBUG exec kexec -e
fi

exec kexec -e
10 changes: 6 additions & 4 deletions initrd/bin/kexec-iso-init
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ fi

ISO_PATH="${ISO_PATH##/}"

gpgv --homedir=/etc/distro/ "$ISOSIG" "$MOUNTED_ISO_PATH" \
|| die 'ISO signature failed'
#TODO: REMOVE PRIOR OF MERGING
#gpgv --homedir=/etc/distro/ "$ISOSIG" "$MOUNTED_ISO_PATH" \
# || die 'ISO signature failed'

echo '+++ Mounting ISO and booting'
mount -t iso9660 -o loop $MOUNTED_ISO_PATH /boot \
|| die '$MOUNTED_ISO_PATH: Unable to mount /boot'

DEV_UUID=`blkid $DEV | tail -1 | tr " " "\n" | grep UUID | cut -d\" -f2`
ADD="fromiso=/dev/disk/by-uuid/$DEV_UUID/$ISO_PATH img_dev=/dev/disk/by-uuid/$DEV_UUID iso-scan/filename=/${ISO_PATH} img_loop=$ISO_PATH"
#TODO: Added requirements for booting from Tinycore ISO from https://github.com/u-root/webboot/
ADD="fromiso=/dev/disk/by-uuid/$DEV_UUID/$ISO_PATH img_dev=/dev/disk/by-uuid/$DEV_UUID iso-scan/filename=/${ISO_PATH} img_loop=$ISO_PATH iso=$DEV_UUID/$ISO_PATH"
REMOVE=""

paramsdir="/media/kexec_iso/$ISO_PATH"
Expand All @@ -47,7 +49,7 @@ if [ -r $REMOVE_FILE ]; then
fi

# Call kexec and indicate that hashes have been verified
kexec-select-boot -b /boot -d /media -p "$paramsdir" \
DO_WITH_DEBUG kexec-select-boot -b /boot -d /media -p "$paramsdir" \
-a "$ADD" -r "$REMOVE" -c "*.cfg" -u -i

die "Something failed in selecting boot"
56 changes: 39 additions & 17 deletions initrd/bin/kexec-parse-boot
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ reset_entry() {
append=""
}

filedir=`dirname $file`
filedir="$(dirname $file)"
DEBUG "filedir= $filedir"
bootdir="${bootdir%%/}"
DEBUG "bootdir= $bootdir"
bootlen="${#bootdir}"
DEBUG "bootlen= $bootlen"
appenddir="${filedir:$bootlen}"
DEBUG "appenddir= $appenddir"

fix_path() {
path="$@"
if [ "${path:0:1}" != "/" ]; then
DEBUG "fix_path: path was $@"
path="$appenddir/$path"
DEBUG "fix_path: path is now $path"
fi
}

Expand All @@ -38,7 +44,10 @@ check_path() {
local checkpath firstval
checkpath="$1"
firstval="$(echo "$checkpath" | cut -d\ -f1)"
if ! [ -r "$bootdir$firstval" ]; then return 1; fi
if ! [ -r "$bootdir$firstval" ]; then
DEBUG "$bootdir$firstval doesn't exist"
return 1;
fi
return 0
}

Expand Down Expand Up @@ -85,13 +94,15 @@ search_entry() {
menuentry* | MENUENTRY* )
state="grub"
reset_entry
name=`echo $line | tr "'" "\"" | cut -d\" -f 2`
name=$(echo $line | tr "'" "\"" | cut -d\" -f 2)
;;

label* | LABEL* )
state="syslinux"
reset_entry
name=`echo $line | cut -c6- `
name=$(echo $line | cut -c6- )
TRACE " search_entry: syslinux label: line= $line"
TRACE " search_entry: syslinux label: name= $name"
esac
}

Expand All @@ -103,34 +114,38 @@ grub_entry() {
fi

# add info to menuentry
trimcmd=`echo $line | tr '\t ' ' ' | tr -s ' '`
cmd=`echo $trimcmd | cut -d\ -f1`
val=`echo $trimcmd | cut -d\ -f2-`
trimcmd=$(echo $line | tr '\t ' ' ' | tr -s ' ')
cmd=$(echo $trimcmd | cut -d\ -f1)
val=$(echo $trimcmd | cut -d\ -f2-)
case $cmd in
multiboot*)
# TODO: differentiate between Xen and other multiboot kernels
kexectype="xen"
kernel="$val"
DEBUG " grub_entry multiboot kernel= $kernel"
;;
module*)
case $val in
--nounzip*) val=`echo $val | cut -d\ -f2-` ;;
--nounzip*) val=$(echo $val | cut -d\ -f2-) ;;
esac
fix_path $val
modules="$modules|module $path"
DEBUG " grub_entry linux modules= $modules"
;;
linux*)
# Some configs have a device specification in the kernel
# or initrd path. Assume this would be /boot and remove
# it. Keep the '/' following the device, since this
# path is relative to the device root, not the config
# location.
kernel=`echo $trimcmd | sed "s/([^)]*)//g" | cut -d\ -f2`
append=`echo $trimcmd | cut -d\ -f3-`
DEBUG " grub_entry : linux trimcmd prior of kernel/append parsing: $trimcmd"
kernel=$(echo $trimcmd | sed "s/([^)]*)//g" | cut -d\ -f2)
append=$(echo $trimcmd | cut -d\ -f3-)
;;
initrd*)
# Trim off device specification as above
initrd="$(echo "$val" | sed "s/([^)]*)//g")"
DEBUG " grub_entry: linux initrd= $initrd"
;;
esac
}
Expand All @@ -144,7 +159,7 @@ syslinux_end() {
for param in $append; do
case $param in
initrd=*)
initrd=`echo $param | cut -d\= -f2`
initrd=$(echo $param | cut -d\= -f2)
;;
*) newappend="$newappend $param" ;;
esac
Expand All @@ -158,7 +173,7 @@ syslinux_end() {
}

syslinux_multiboot_append() {
splitval=`echo "${val// --- /|}" | tr '|' '\n'`
splitval=$(echo "${val// --- /|}" | tr '|' '\n')
while read line
do
if [ -z "$kernel" ]; then
Expand Down Expand Up @@ -186,14 +201,18 @@ syslinux_entry() {
esac

# add info to menuentry
trimcmd=`echo $line | tr '\t ' ' ' | tr -s ' '`
cmd=`echo $trimcmd | cut -d\ -f1`
val=`echo $trimcmd | cut -d\ -f2-`
DEBUG "line= $line"
trimcmd=$(echo $line | tr '\t ' ' ' | tr -s ' ')
DEBUG "trimcmd= $trimcmd"
cmd=$(echo $trimcmd | cut -d\ -f1)
DEBUG "cmd= $cmd"
val=$(echo $trimcmd | cut -d\ -f2-)
DEBUG "val= $val"
case $trimcmd in
menu* | MENU* )
cmd2=`echo $trimcmd | cut -d \ -f2`
cmd2=$(echo $trimcmd | cut -d \ -f2)
if [ "$cmd2" = "label" -o "$cmd2" = "LABEL" ]; then
name=`echo $trimcmd | cut -c11- | tr -d '^'`
name=$(echo $trimcmd | cut -c11- | tr -d '^')
fi
;;
linux* | LINUX* | kernel* | KERNEL* )
Expand All @@ -206,16 +225,19 @@ syslinux_entry() {
;;
*)
kernel="${val#"$bootdir"}"
DEBUG "kernel= $kernel"
esac
;;
initrd* | INITRD* )
initrd="${val#"$bootdir"}"
DEBUG "initrd= $initrd"
;;
append* | APPEND* )
if [ "$kexectype" = "multiboot" -o "$kexectype" = "xen" ]; then
syslinux_multiboot_append
else
append="$val"
DEBUG "append= $append"
fi
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/kexec-select-boot
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ scan_options() {
option_file="/tmp/kexec_options.txt"
if [ -r $option_file ]; then rm $option_file; fi
for i in `find $bootdir -name "$config"`; do
kexec-parse-boot "$bootdir" "$i" >> $option_file
DO_WITH_DEBUG kexec-parse-boot "$bootdir" "$i" >> $option_file
done
# FC29/30+ may use BLS format grub config files
# https://fedoraproject.org/wiki/Changes/BootLoaderSpecByDefault
Expand Down
6 changes: 3 additions & 3 deletions initrd/bin/media-scan
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if [ `cat /tmp/iso_menu.txt | wc -l` -gt 0 ]; then
if [ -n "$option" ]; then
MOUNTED_ISO=$option
ISO=${option:7} # remove /media/ to get device relative path
kexec-iso-init $MOUNTED_ISO $ISO $USB_BOOT_DEV
DO_WITH_DEBUG kexec-iso-init $MOUNTED_ISO $ISO $USB_BOOT_DEV

die "Something failed in iso init"
fi
Expand All @@ -95,9 +95,9 @@ fi
echo "!!! Could not find any ISO, trying bootable USB"
# Attempt to pull verified config from device
if [ -x /bin/whiptail ]; then
kexec-select-boot -b /media -c "*.cfg" -u -g -s
DO_WITH_DEBUG kexec-select-boot -b /media -c "*.cfg" -u -g -s
else
kexec-select-boot -b /media -c "*.cfg" -u -s
DO_WITH_DEBUG kexec-select-boot -b /media -c "*.cfg" -u -s
fi

die "Something failed in selecting boot"
2 changes: 1 addition & 1 deletion initrd/bin/usb-init
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ if [ "$CONFIG_TPM" = "y" ]; then
tpmr extend -ix 4 -ic usb
fi

media-scan usb
DO_WITH_DEBUG media-scan usb
recovery "Something failed during USB boot"

0 comments on commit b862db9

Please sign in to comment.