diff --git a/build.sh b/build.sh index 3bf9036..3d4a6df 100755 --- a/build.sh +++ b/build.sh @@ -341,6 +341,7 @@ make_efi() { s|%DEFAULT_KERNEL_PARAM%|${default_kernel_param}|g; s|%INSTALL_DIR%|${install_dir}|g" \ ${script_path}/efiboot/grub/grubsrcd.cfg > ${work_dir}/iso/boot/grub/grubsrcd.cfg + cp ${script_path}/efiboot/grub/loopback.cfg ${work_dir}/iso/boot/grub/ cp -a /usr/share/edk2-shell/${edk2arch}/Shell_Full.efi ${work_dir}/iso/EFI/shell.efi cp ${work_dir}/${arch}/airootfs/boot/memtest86+/memtest.efi ${work_dir}/iso/EFI/memtest.efi } diff --git a/efiboot/grub/grubsrcd.cfg b/efiboot/grub/grubsrcd.cfg index b44964c..9636241 100644 --- a/efiboot/grub/grubsrcd.cfg +++ b/efiboot/grub/grubsrcd.cfg @@ -1,100 +1,115 @@ -# Global options -set timeout=30 -set default=0 -set fallback=1 -set pager=1 +# SystemRescue main GRUB config file -# Display settings -if loadfont /boot/grub/font.pf2 ; then - set gfxmode=640x480 - set color_normal=black/cyan - set color_highlight=black/light-gray - set menu_color_normal=black/cyan - set menu_color_highlight=black/light-gray - insmod efi_gop - insmod efi_uga - insmod gfxterm - insmod all_video - insmod videotest - insmod videoinfo - terminal_output gfxterm +# Note: This is set when we are loaded from loopback.cfg +if [ -z "$srcd_skip_init" ]; then + # Global options + set timeout=30 + set default=0 + set fallback=1 + set pager=1 + + # Display settings + if loadfont /boot/grub/font.pf2 ; then + set gfxmode=640x480 + set color_normal=black/cyan + set color_highlight=black/light-gray + set menu_color_normal=black/cyan + set menu_color_highlight=black/light-gray + insmod efi_gop + insmod efi_uga + insmod gfxterm + insmod all_video + insmod videotest + insmod videoinfo + terminal_output gfxterm + fi + + # enable serial console with common settings (ttyS0, 115200 Baud, 8n1) + # this works in parallel to regular console + serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 + terminal_input --append serial + terminal_output --append serial fi -# enable serial console with common settings (ttyS0, 115200 Baud, 8n1) -# this works in parallel to regular console -serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 -terminal_input --append serial -terminal_output --append serial +if [ -z "$archiso_param" ]; then + archiso_param="archisolabel=%ARCHISO_LABEL%" +fi -menuentry "Boot SystemRescue using default options" { +# Placing menuentry commands inside an eval allows the value of variables +# like $archiso_param to be visible in the GRUB editor +eval " + +menuentry 'Boot SystemRescue using default options' { set gfxpayload=keep - linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% %DEFAULT_KERNEL_PARAM% + linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% $archiso_param %DEFAULT_KERNEL_PARAM% initrd /%INSTALL_DIR%/boot/intel_ucode.img /%INSTALL_DIR%/boot/amd_ucode.img /%INSTALL_DIR%/boot/%ISO_ARCH%/sysresccd.img } -menuentry "Boot SystemRescue and copy system to RAM (copytoram)" { +menuentry 'Boot SystemRescue and copy system to RAM (copytoram)' { set gfxpayload=keep - linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% %DEFAULT_KERNEL_PARAM% copytoram + linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% $archiso_param %DEFAULT_KERNEL_PARAM% copytoram initrd /%INSTALL_DIR%/boot/intel_ucode.img /%INSTALL_DIR%/boot/amd_ucode.img /%INSTALL_DIR%/boot/%ISO_ARCH%/sysresccd.img } -menuentry "Boot SystemRescue and verify integrity of the medium (checksum)" { +menuentry 'Boot SystemRescue and verify integrity of the medium (checksum)' { set gfxpayload=keep - linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% %DEFAULT_KERNEL_PARAM% checksum + linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% $archiso_param %DEFAULT_KERNEL_PARAM% checksum initrd /%INSTALL_DIR%/boot/intel_ucode.img /%INSTALL_DIR%/boot/amd_ucode.img /%INSTALL_DIR%/boot/%ISO_ARCH%/sysresccd.img } -menuentry "Boot SystemRescue using basic display drivers (nomodeset)" { +menuentry 'Boot SystemRescue using basic display drivers (nomodeset)' { set gfxpayload=keep - linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% %DEFAULT_KERNEL_PARAM% nomodeset + linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% $archiso_param %DEFAULT_KERNEL_PARAM% nomodeset initrd /%INSTALL_DIR%/boot/intel_ucode.img /%INSTALL_DIR%/boot/amd_ucode.img /%INSTALL_DIR%/boot/%ISO_ARCH%/sysresccd.img } -menuentry "Boot SystemRescue with serial console (ttyS0,115200n8)" { +menuentry 'Boot SystemRescue with serial console (ttyS0,115200n8)' { set gfxpayload=keep - linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% %DEFAULT_KERNEL_PARAM% console=tty0 console=ttyS0,115200n8 + linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% $archiso_param %DEFAULT_KERNEL_PARAM% console=tty0 console=ttyS0,115200n8 initrd /%INSTALL_DIR%/boot/intel_ucode.img /%INSTALL_DIR%/boot/amd_ucode.img /%INSTALL_DIR%/boot/%ISO_ARCH%/sysresccd.img } -menuentry "Boot SystemRescue, do not activate md raid or lvm (nomdlvm)" { +menuentry 'Boot SystemRescue, do not activate md raid or lvm (nomdlvm)' { set gfxpayload=keep - linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% %DEFAULT_KERNEL_PARAM% nomdlvm + linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% $archiso_param %DEFAULT_KERNEL_PARAM% nomdlvm initrd /%INSTALL_DIR%/boot/intel_ucode.img /%INSTALL_DIR%/boot/amd_ucode.img /%INSTALL_DIR%/boot/%ISO_ARCH%/sysresccd.img } -menuentry "Boot a Linux operating system installed on the disk (findroot)" { +menuentry 'Boot a Linux operating system installed on the disk (findroot)' { set gfxpayload=keep - linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% %DEFAULT_KERNEL_PARAM% findroot + linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% $archiso_param %DEFAULT_KERNEL_PARAM% findroot initrd /%INSTALL_DIR%/boot/intel_ucode.img /%INSTALL_DIR%/boot/amd_ucode.img /%INSTALL_DIR%/boot/%ISO_ARCH%/sysresccd.img } -menuentry "Stop during the boot process before mounting the root filesystem" { +menuentry 'Stop during the boot process before mounting the root filesystem' { set gfxpayload=keep - linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% %DEFAULT_KERNEL_PARAM% break + linux /%INSTALL_DIR%/boot/%ISO_ARCH%/vmlinuz archisobasedir=%INSTALL_DIR% $archiso_param %DEFAULT_KERNEL_PARAM% break initrd /%INSTALL_DIR%/boot/intel_ucode.img /%INSTALL_DIR%/boot/amd_ucode.img /%INSTALL_DIR%/boot/%ISO_ARCH%/sysresccd.img } -menuentry "Memtest86+ memory tester for UEFI" { +menuentry 'Memtest86+ memory tester for UEFI' { insmod fat set gfxpayload=800x600,1024x768 linux /EFI/memtest.efi keyboard=both } -menuentry "Start EFI Shell" { +menuentry 'Start EFI Shell' { insmod fat insmod chain terminal_output console chainloader /EFI/shell.efi } -menuentry "EFI Firmware setup" { +menuentry 'EFI Firmware setup' { fwsetup } -menuentry "Reboot" { +menuentry 'Reboot' { reboot } -menuentry "Power off" { +menuentry 'Power off' { halt } + +" # end eval diff --git a/efiboot/grub/loopback.cfg b/efiboot/grub/loopback.cfg new file mode 100644 index 0000000..afb3644 --- /dev/null +++ b/efiboot/grub/loopback.cfg @@ -0,0 +1,37 @@ +# SystemRescue loopback-mount GRUB config file + +# Per loopback.cfg convention, 'iso_path' should have been set to the +# filesystem location of the SystemRescue ISO-image file. +# (Reference: https://www.supergrubdisk.org/wiki/Loopback.cfg) + +if [ -z "$iso_path" ] +then + echo "Warning: 'iso_path' is not set." + +elif search --file --set=archiso_grub_dev --no-floppy $iso_path +then + echo "Found '$iso_path' on ($archiso_grub_dev)" + + if probe --fs-uuid --set=archiso_fs_uuid $archiso_grub_dev + then + echo "($archiso_grub_dev) filesystem UUID: $archiso_fs_uuid" + archiso_param="img_dev=/dev/disk/by-uuid/$archiso_fs_uuid img_loop=$iso_path" + else + echo + echo "Warning: Could not get filesystem UUID for ($archiso_grub_dev)." + fi +else + echo + echo "Warning: Could not find the SystemRescue ISO-image file." +fi + +if [ -z "$archiso_param" ] +then + echo "The following GRUB menu is unlikely to boot SystemRescue successfully." + echo + echo -n "Press Enter to continue ... " + read +fi + +srcd_skip_init=yes +source /boot/grub/grubsrcd.cfg