Skip to content

Commit b862db9

Browse files
committed
WiP ISO boot add debugging to fix #1374.
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
1 parent 8ff4b9a commit b862db9

File tree

6 files changed

+91
-26
lines changed

6 files changed

+91
-26
lines changed

initrd/bin/kexec-boot

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ adjust_cmd_line() {
6161
adjusted_cmd_line="y"
6262
}
6363

64+
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
65+
kexeccmd="$kexeccmd -d"
66+
fi
67+
6468
module_number="1"
6569
while read line
6670
do
@@ -76,7 +80,39 @@ do
7680
elif [ "$kexectype" = "multiboot" ]; then
7781
kexeccmd="$kexeccmd -l $filepath"
7882
kexeccmd="$kexeccmd --command-line \"$restval\""
83+
elif [ "$kexectype" = "elf" ]; then
84+
DEBUG "kexectype= $kexectype"
85+
DEBUG "restval= $restval"
86+
DEBUG "filepath= $filepath"
87+
#kexeccmd="$kexeccmd -l $filepath --reset-vga --console-vga"
88+
#kexeccmd="$kexeccmd --noefi --entry-32bit --reset-vga -l $filepath"
89+
#kexeccmd="$kexeccmd --command-line \"$restval vga=current\""
90+
#kexeccmd="$kexeccmd --noefi --reset-vga -l $filepath"
91+
#kexeccmd="$kexeccmd --noefi --console-vga --reuse-video-type -l $filepath"
92+
#kexeccmd="$kexeccmd --noefi --real-mode --console-vga --reuse-video-type -l $filepath"
93+
#kexeccmd="$kexeccmd -l $filepath --command-line \"$restval vga=current\""
94+
#kexeccmd="$kexeccmd -l $filepath"
95+
#
96+
#noefi: to skip second kernel efi setup. Let's say we wanted to kexec into ReactOS: https://www.phoronix.com/news/MTUzNDk
97+
#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
98+
#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
99+
#Qemu seems to have its own subset of problems, which also affect real hardware on kexec.
100+
# https://bugzilla.redhat.com/show_bug.cgi?id=1335830#c11
101+
# Solution here is to ask second kernel to set nomodeset so DRM is responsible to setup console.
102+
# As this sounds, this might work but would not give us working console on real hardware
103+
#acpi_rdsp problems?
104+
105+
#retry attempts:
106+
#kexeccmd="$kexeccmd --entry-32bit --reset-vga -l $filepath"
107+
#kexeccmd="$kexeccmd --entry-32bit --reuse-video-type -l $filepath"
108+
#kexeccmd="$kexeccmd --noefi --reuse-video-type -l $filepath" #nomodeset added to board
109+
# nomodeset just gives a warning on kernel init that no gpu will be initialized...
110+
#kexeccmd="$kexeccmd --entry-32bit -l $filepath"
111+
#TODO: how to dynamically setup noefi? Linuxboot can use u-root as EFI payload. Maybe not needed once resolved
112+
kexeccmd="$kexeccmd --noefi --entry-32bit --console-vga -l $filepath"
113+
DEBUG "kexeccmd= $kexeccmd"
79114
else
115+
DEBUG "unknown kexectype!!!!"
80116
kexeccmd="$kexeccmd -l $filepath"
81117
fi
82118
fi
@@ -139,4 +175,9 @@ if [ "$CONFIG_TPM" = "y" ]; then
139175
fi
140176

141177
echo "Starting the new kernel"
178+
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
179+
DEBUG "kexeccmd= $kexeccmd"
180+
DO_WITH_DEBUG exec kexec -e
181+
fi
182+
142183
exec kexec -e

initrd/bin/kexec-iso-init

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ fi
1919

2020
ISO_PATH="${ISO_PATH##/}"
2121

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

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

2930
DEV_UUID=`blkid $DEV | tail -1 | tr " " "\n" | grep UUID | cut -d\" -f2`
30-
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"
31+
#TODO: Added requirements for booting from Tinycore ISO from https://github.com/u-root/webboot/
32+
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"
3133
REMOVE=""
3234

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

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

5355
die "Something failed in selecting boot"

initrd/bin/kexec-parse-boot

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ reset_entry() {
2020
append=""
2121
}
2222

23-
filedir=`dirname $file`
23+
filedir="$(dirname $file)"
24+
DEBUG "filedir= $filedir"
2425
bootdir="${bootdir%%/}"
26+
DEBUG "bootdir= $bootdir"
2527
bootlen="${#bootdir}"
28+
DEBUG "bootlen= $bootlen"
2629
appenddir="${filedir:$bootlen}"
30+
DEBUG "appenddir= $appenddir"
2731

2832
fix_path() {
2933
path="$@"
3034
if [ "${path:0:1}" != "/" ]; then
35+
DEBUG "fix_path: path was $@"
3136
path="$appenddir/$path"
37+
DEBUG "fix_path: path is now $path"
3238
fi
3339
}
3440

@@ -38,7 +44,10 @@ check_path() {
3844
local checkpath firstval
3945
checkpath="$1"
4046
firstval="$(echo "$checkpath" | cut -d\ -f1)"
41-
if ! [ -r "$bootdir$firstval" ]; then return 1; fi
47+
if ! [ -r "$bootdir$firstval" ]; then
48+
DEBUG "$bootdir$firstval doesn't exist"
49+
return 1;
50+
fi
4251
return 0
4352
}
4453

@@ -85,13 +94,15 @@ search_entry() {
8594
menuentry* | MENUENTRY* )
8695
state="grub"
8796
reset_entry
88-
name=`echo $line | tr "'" "\"" | cut -d\" -f 2`
97+
name=$(echo $line | tr "'" "\"" | cut -d\" -f 2)
8998
;;
9099

91100
label* | LABEL* )
92101
state="syslinux"
93102
reset_entry
94-
name=`echo $line | cut -c6- `
103+
name=$(echo $line | cut -c6- )
104+
TRACE " search_entry: syslinux label: line= $line"
105+
TRACE " search_entry: syslinux label: name= $name"
95106
esac
96107
}
97108

@@ -103,34 +114,38 @@ grub_entry() {
103114
fi
104115

105116
# add info to menuentry
106-
trimcmd=`echo $line | tr '\t ' ' ' | tr -s ' '`
107-
cmd=`echo $trimcmd | cut -d\ -f1`
108-
val=`echo $trimcmd | cut -d\ -f2-`
117+
trimcmd=$(echo $line | tr '\t ' ' ' | tr -s ' ')
118+
cmd=$(echo $trimcmd | cut -d\ -f1)
119+
val=$(echo $trimcmd | cut -d\ -f2-)
109120
case $cmd in
110121
multiboot*)
111122
# TODO: differentiate between Xen and other multiboot kernels
112123
kexectype="xen"
113124
kernel="$val"
125+
DEBUG " grub_entry multiboot kernel= $kernel"
114126
;;
115127
module*)
116128
case $val in
117-
--nounzip*) val=`echo $val | cut -d\ -f2-` ;;
129+
--nounzip*) val=$(echo $val | cut -d\ -f2-) ;;
118130
esac
119131
fix_path $val
120132
modules="$modules|module $path"
133+
DEBUG " grub_entry linux modules= $modules"
121134
;;
122135
linux*)
123136
# Some configs have a device specification in the kernel
124137
# or initrd path. Assume this would be /boot and remove
125138
# it. Keep the '/' following the device, since this
126139
# path is relative to the device root, not the config
127140
# location.
128-
kernel=`echo $trimcmd | sed "s/([^)]*)//g" | cut -d\ -f2`
129-
append=`echo $trimcmd | cut -d\ -f3-`
141+
DEBUG " grub_entry : linux trimcmd prior of kernel/append parsing: $trimcmd"
142+
kernel=$(echo $trimcmd | sed "s/([^)]*)//g" | cut -d\ -f2)
143+
append=$(echo $trimcmd | cut -d\ -f3-)
130144
;;
131145
initrd*)
132146
# Trim off device specification as above
133147
initrd="$(echo "$val" | sed "s/([^)]*)//g")"
148+
DEBUG " grub_entry: linux initrd= $initrd"
134149
;;
135150
esac
136151
}
@@ -144,7 +159,7 @@ syslinux_end() {
144159
for param in $append; do
145160
case $param in
146161
initrd=*)
147-
initrd=`echo $param | cut -d\= -f2`
162+
initrd=$(echo $param | cut -d\= -f2)
148163
;;
149164
*) newappend="$newappend $param" ;;
150165
esac
@@ -158,7 +173,7 @@ syslinux_end() {
158173
}
159174

160175
syslinux_multiboot_append() {
161-
splitval=`echo "${val// --- /|}" | tr '|' '\n'`
176+
splitval=$(echo "${val// --- /|}" | tr '|' '\n')
162177
while read line
163178
do
164179
if [ -z "$kernel" ]; then
@@ -186,14 +201,18 @@ syslinux_entry() {
186201
esac
187202

188203
# add info to menuentry
189-
trimcmd=`echo $line | tr '\t ' ' ' | tr -s ' '`
190-
cmd=`echo $trimcmd | cut -d\ -f1`
191-
val=`echo $trimcmd | cut -d\ -f2-`
204+
DEBUG "line= $line"
205+
trimcmd=$(echo $line | tr '\t ' ' ' | tr -s ' ')
206+
DEBUG "trimcmd= $trimcmd"
207+
cmd=$(echo $trimcmd | cut -d\ -f1)
208+
DEBUG "cmd= $cmd"
209+
val=$(echo $trimcmd | cut -d\ -f2-)
210+
DEBUG "val= $val"
192211
case $trimcmd in
193212
menu* | MENU* )
194-
cmd2=`echo $trimcmd | cut -d \ -f2`
213+
cmd2=$(echo $trimcmd | cut -d \ -f2)
195214
if [ "$cmd2" = "label" -o "$cmd2" = "LABEL" ]; then
196-
name=`echo $trimcmd | cut -c11- | tr -d '^'`
215+
name=$(echo $trimcmd | cut -c11- | tr -d '^')
197216
fi
198217
;;
199218
linux* | LINUX* | kernel* | KERNEL* )
@@ -206,16 +225,19 @@ syslinux_entry() {
206225
;;
207226
*)
208227
kernel="${val#"$bootdir"}"
228+
DEBUG "kernel= $kernel"
209229
esac
210230
;;
211231
initrd* | INITRD* )
212232
initrd="${val#"$bootdir"}"
233+
DEBUG "initrd= $initrd"
213234
;;
214235
append* | APPEND* )
215236
if [ "$kexectype" = "multiboot" -o "$kexectype" = "xen" ]; then
216237
syslinux_multiboot_append
217238
else
218239
append="$val"
240+
DEBUG "append= $append"
219241
fi
220242
;;
221243
esac

initrd/bin/kexec-select-boot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ scan_options() {
182182
option_file="/tmp/kexec_options.txt"
183183
if [ -r $option_file ]; then rm $option_file; fi
184184
for i in `find $bootdir -name "$config"`; do
185-
kexec-parse-boot "$bootdir" "$i" >> $option_file
185+
DO_WITH_DEBUG kexec-parse-boot "$bootdir" "$i" >> $option_file
186186
done
187187
# FC29/30+ may use BLS format grub config files
188188
# https://fedoraproject.org/wiki/Changes/BootLoaderSpecByDefault

initrd/bin/media-scan

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ if [ `cat /tmp/iso_menu.txt | wc -l` -gt 0 ]; then
8686
if [ -n "$option" ]; then
8787
MOUNTED_ISO=$option
8888
ISO=${option:7} # remove /media/ to get device relative path
89-
kexec-iso-init $MOUNTED_ISO $ISO $USB_BOOT_DEV
89+
DO_WITH_DEBUG kexec-iso-init $MOUNTED_ISO $ISO $USB_BOOT_DEV
9090

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

103103
die "Something failed in selecting boot"

initrd/bin/usb-init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ if [ "$CONFIG_TPM" = "y" ]; then
1111
tpmr extend -ix 4 -ic usb
1212
fi
1313

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

0 commit comments

Comments
 (0)