Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iso boot debugging and fixes #1377

Merged
merged 3 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions initrd/bin/kexec-boot
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ adjust_cmd_line() {
adjusted_cmd_line="y"
}

if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
#If expecting debug output, have kexec load (-l) output debug info
kexeccmd="$kexeccmd -d"
fi

module_number="1"
while read line
do
Expand All @@ -76,7 +81,14 @@ 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"
DEBUG "kexeccmd= $kexeccmd"
else
DEBUG "unknown kexectype!!!!"
kexeccmd="$kexeccmd -l $filepath"
fi
fi
Expand Down
4 changes: 2 additions & 2 deletions initrd/bin/kexec-iso-init
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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"
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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wish there was a bit more of a standard here so we didn't have to spray all the variants we know about 😓 But it looks fine for our purposes

Copy link
Collaborator Author

@tlaurion tlaurion Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add reference to webboot as comment prior of section. Since this is passed as kernel options down to user land init, passing all iso boot hacks for all linux distributions would be pretty harmless and probably should be done preventively prior if users opening issues... but that would require us to test them all individually :/

REMOVE=""

paramsdir="/media/kexec_iso/$ISO_PATH"
Expand All @@ -47,7 +47,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"
22 changes: 19 additions & 3 deletions initrd/bin/kexec-parse-boot
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ reset_entry() {
}

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 @@ -111,26 +120,30 @@ grub_entry() {
# 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-` ;;
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.
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 Down Expand Up @@ -205,17 +218,20 @@ syslinux_entry() {
state="search"
;;
*)
kernel="${val#"$bootdir"}"
kernel="$val"
DEBUG "kernel= $kernel"
esac
;;
initrd* | INITRD* )
initrd="${val#"$bootdir"}"
initrd="$val"
Comment on lines 220 to +226
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're undoing part of a075347 - the concern in the commit was fixed right, kexec-boot now handles absolute paths correctly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will review that part.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, a075347 was supposed to be grub related. Without hack in my debugging PR to merge isolinux and grub entries to not have duplicate entries, Debian isolinux entries are exposed without "..." in labels.

Will test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JonathonHall-Purism I haven't found a case where this PR caused issue following past comment

Copy link
Collaborator Author

@tlaurion tlaurion Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current issue in master is that when isos are mounted under /boot, the actual bootdir is /boot/boot/ and that is getting stripped otherwise. I think a075347 was relevant until caller scripts fixed it themselves if needed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tlaurion Sorry this sat in my inbox for a few days. Makes sense, agree it looks like the root issue was fixed. I see what you mean that stripping /boot from /boot/boot/... would cause this issue.

Is this ready to merge then?

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"