From 92b4017cd741e56d5a5f72016b18100dea0235d7 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Tue, 18 Jan 2022 07:56:40 +0100 Subject: [PATCH] unify grub.cfg to use one file for all image types --- usr/bin/archboot-aarch64-iso.sh | 154 +++------------- usr/bin/archboot-setup.sh | 1 - usr/bin/archboot-x86_64-iso.sh | 289 +++++-------------------------- usr/share/archboot/grub/grub.cfg | 137 +++++++++++++++ 4 files changed, 204 insertions(+), 377 deletions(-) create mode 100644 usr/share/archboot/grub/grub.cfg diff --git a/usr/bin/archboot-aarch64-iso.sh b/usr/bin/archboot-aarch64-iso.sh index 9aebad02b..07b677769 100755 --- a/usr/bin/archboot-aarch64-iso.sh +++ b/usr/bin/archboot-aarch64-iso.sh @@ -120,22 +120,20 @@ if ! [[ "${_GENERATE}" == "1" ]]; then fi if ! [[ "${_TARBALL_NAME}" == "" ]]; then - tar xf ${_TARBALL_NAME} -C "${_CORE64}" || exit 1 - else - echo "Please enter a tarball name with parameter -T=tarball" - exit 1 + tar xf ${_TARBALL_NAME} -C "${_CORE64}" || exit 1 +else + echo "Please enter a tarball name with parameter -T=tarball" + exit 1 fi mkdir -p "${_AARCH64}/EFI/BOOT" _prepare_kernel_initramfs_files() { - - mkdir -p "${_AARCH64}/boot" - mv "${_CORE64}"/*/boot/vmlinuz "${_AARCH64}/boot/vmlinuz_aarch64" - mv "${_CORE64}"/*/boot/initrd.img "${_AARCH64}/boot/initramfs_aarch64.img" - mv "${_CORE64}"/*/boot/amd-ucode.img "${_AARCH64}/boot/" - mv "${_CORE64}"/*/boot/dtbs "${_AARCH64}/boot/" - + mkdir -p "${_AARCH64}/boot" + mv "${_CORE64}"/*/boot/vmlinuz "${_AARCH64}/boot/vmlinuz_aarch64" + mv "${_CORE64}"/*/boot/initrd.img "${_AARCH64}/boot/initramfs_aarch64.img" + mv "${_CORE64}"/*/boot/amd-ucode.img "${_AARCH64}/boot/" + mv "${_CORE64}"/*/boot/dtbs "${_AARCH64}/boot/" } _prepare_efitools_uefi () { @@ -153,132 +151,28 @@ _prepare_fedora_shim_bootloaders () { } _prepare_uefi_image() { - - ## get size of boot x86_64 files - BOOTSIZE=$(du -bc ${_AARCH64}/EFI | grep total | cut -f1) - IMGSZ=$(( (${BOOTSIZE}*102)/100/1024 + 1)) # image size in sectors - - ## Create cdefiboot.img - dd if=/dev/zero of="${_AARCH64}"/efi.img bs="${IMGSZ}" count=1024 - VFAT_IMAGE="${_AARCH64}/efi.img" - mkfs.vfat "${VFAT_IMAGE}" - - ## Copy all files to UEFI vfat image - mcopy -i "${VFAT_IMAGE}" -s "${_AARCH64}"/EFI ::/ - + ## get size of boot x86_64 files + BOOTSIZE=$(du -bc ${_AARCH64}/EFI | grep total | cut -f1) + IMGSZ=$(( (${BOOTSIZE}*102)/100/1024 + 1)) # image size in sectors + ## Create cdefiboot.img + dd if=/dev/zero of="${_AARCH64}"/efi.img bs="${IMGSZ}" count=1024 + VFAT_IMAGE="${_AARCH64}/efi.img" + mkfs.vfat "${VFAT_IMAGE}" + ## Copy all files to UEFI vfat image + mcopy -i "${VFAT_IMAGE}" -s "${_AARCH64}"/EFI ::/ } # build grubXXX with all modules: http://bugs.archlinux.org/task/71382 # If you don't use shim use --disable-shim-lock _prepare_uefi_AA64_GRUB_USB_files() { - - mkdir -p "${_AARCH64}/EFI/BOOT" - cat << GRUBEOF > "${_AARCH64}/EFI/BOOT/grubaa64.cfg" -insmod part_gpt -insmod part_msdos -insmod fat - -insmod efi_gop -insmod video_bochs -insmod video_cirrus - -insmod font - -if loadfont "${prefix}/fonts/unicode.pf2" ; then - insmod gfxterm - set gfxmode="1366x768x32;1280x800x32;1024x768x32;auto" - terminal_input console - terminal_output gfxterm -fi - -set default="Arch Linux AA64 Archboot" -set timeout="10" - -menuentry "Arch Linux AA64 Archboot" { - set gfxpayload=keep - search --no-floppy --set=root --file /boot/vmlinuz_aarch64 - linux /boot/vmlinuz_aarch64 cgroup_disable=memory add_efi_memmap rootfstype=ramfs audit=0 nr_cpus=1 - initrd /boot/amd-ucode.img /boot/initramfs_aarch64.img + ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 + grub-mkstandalone -d /usr/lib/grub/arm64-efi -O arm64-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd chain tpm" --fonts="unicode" --locales="" --themes="" -o "${_AARCH64}/EFI/BOOT/grubaa64.efi" } -menuentry "Secure Boot KeyTool" { - search --no-floppy --set=root --file /EFI/tools/KeyTool.efi - chainloader /EFI/tools/KeyTool.efi -} - -menuentry "Secure Boot HashTool" { - search --no-floppy --set=root --file /EFI/tools/HashTool.efi - chainloader /EFI/tools/HashTool.efi -} - -menuentry "Enter Firmware Setup" { - fwsetup -} - -menuentry "System restart" { - echo "System rebooting..." - reboot -} - -menuentry "System shutdown" { - echo "System shutting down..." - halt -} - -menuentry "Exit GRUB" { - exit -} -GRUBEOF - ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 - grub-mkstandalone -d /usr/lib/grub/arm64-efi -O arm64-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd chain tpm" --fonts="unicode" --locales="" --themes="" -o "${_AARCH64}/EFI/BOOT/grubaa64.efi" "boot/grub/grub.cfg=${_AARCH64}/EFI/BOOT/grubaa64.cfg" -} - -_prepare_bios_GRUB_USB_files() { - - mkdir -p "${_AARCH64}/boot/grub" - - cat << GRUBEOF > "${_AARCH64}/boot/grub/grub.cfg" -insmod part_gpt -insmod part_msdos -insmod fat - -insmod video_bochs -insmod video_cirrus - -insmod font - -if loadfont "${prefix}/fonts/unicode.pf2" ; then - insmod gfxterm - set gfxmode="1366x768x32;1280x800x32;1024x768x32;auto" - terminal_input console - terminal_output gfxterm -fi - -set default="Arch Linux aarch64 Archboot - BIOS Mode" -set timeout="10" - -menuentry "Arch Linux aarch64 Archboot - BIOS Mode" { - set gfxpayload=keep - search --no-floppy --set=root --file /boot/vmlinuz_aarch64 - linux /boot/vmlinuz_aarch64 cgroup_disable=memory rootfstype=ramfs - initrd /boot/amd-ucode.img /boot/initramfs_x86_64.img -} - -menuentry "System restart" { - echo "System rebooting..." - reboot -} - -menuentry "System shutdown" { - echo "System shutting down..." - halt -} - -menuentry "Exit GRUB" { - exit -} -GRUBEOF +_prepare_GRUB_config_file() { + [[ -d "${_AARCH64}/boot/grub" ]] || mkdir -p "${_AARCH64}/boot/grub" + cp /usr/share/archboot/grub.cfg "${_AARCH64}/boot/grub/grub.cfg" } echo "Starting ISO creation ..." @@ -295,7 +189,7 @@ echo "Prepare AA64 Grub ..." _prepare_uefi_AA64_GRUB_USB_files >/dev/null 2>&1 echo "Prepare BIOS Grub ..." -_prepare_bios_GRUB_USB_files >/dev/null 2>&1 +_prepare_GRUB_config_file >/dev/null 2>&1 echo "Prepare UEFI image ..." _prepare_uefi_image >/dev/null 2>&1 diff --git a/usr/bin/archboot-setup.sh b/usr/bin/archboot-setup.sh index 2f3333f73..1e5ae4057 100755 --- a/usr/bin/archboot-setup.sh +++ b/usr/bin/archboot-setup.sh @@ -2995,7 +2995,6 @@ bootloader_kernel_parameters() { _KERNEL_PARAMS_COMMON_UNMOD="root=${_rootpart} rootfstype=${ROOTFS} rw ${ROOTFLAGS} ${RAIDARRAYS} ${CRYPTSETUP} cgroup_disable=memory" _KERNEL_PARAMS_BIOS_UNMOD="${_KERNEL_PARAMS_COMMON_UNMOD}" - _KERNEL_PARAMS_UEFI_UNMOD="${_KERNEL_PARAMS_COMMON_UNMOD} add_efi_memmap" _KERNEL_PARAMS_BIOS_MOD="$(echo "${_KERNEL_PARAMS_BIOS_UNMOD}" | sed -e 's# # #g' | sed -e 's# # #g')" _KERNEL_PARAMS_UEFI_MOD="$(echo "${_KERNEL_PARAMS_UEFI_UNMOD}" | sed -e 's# # #g' | sed -e 's# # #g')" diff --git a/usr/bin/archboot-x86_64-iso.sh b/usr/bin/archboot-x86_64-iso.sh index f57be9160..1e41e131d 100755 --- a/usr/bin/archboot-x86_64-iso.sh +++ b/usr/bin/archboot-x86_64-iso.sh @@ -108,14 +108,14 @@ kver() { [[ -z "${_IMAGENAME}" ]] && _IMAGENAME="archlinux-archboot-${_RELEASENAME}-x86_64" if [[ "${_TARBALL}" == "1" ]]; then - # fix for mkinitcpio 31 - # https://bugs.archlinux.org/task/72882 - # remove on mkinitcpio 32 release - cp "/usr/lib/initcpio/functions" "/usr/lib/initcpio/functions.old" - [[ -f "/usr/share/archboot/patches/31-initcpio.functions.fixed" ]] && cp "/usr/share/archboot/patches/31-initcpio.functions.fixed" "/usr/lib/initcpio/functions" - "${_TARBALL_HELPER}" -c="${_PRESET}" -t="${_IMAGENAME}.tar" - mv "/usr/lib/initcpio/functions.old" "/usr/lib/initcpio/functions" - exit 0 + # fix for mkinitcpio 31 + # https://bugs.archlinux.org/task/72882 + # remove on mkinitcpio 32 release + cp "/usr/lib/initcpio/functions" "/usr/lib/initcpio/functions.old" + [[ -f "/usr/share/archboot/patches/31-initcpio.functions.fixed" ]] && cp "/usr/share/archboot/patches/31-initcpio.functions.fixed" "/usr/lib/initcpio/functions" + "${_TARBALL_HELPER}" -c="${_PRESET}" -t="${_IMAGENAME}.tar" + mv "/usr/lib/initcpio/functions.old" "/usr/lib/initcpio/functions" + exit 0 fi if ! [[ "${_GENERATE}" == "1" ]]; then @@ -123,22 +123,20 @@ if ! [[ "${_GENERATE}" == "1" ]]; then fi if ! [[ "${_TARBALL_NAME}" == "" ]]; then - tar xf ${_TARBALL_NAME} -C "${_CORE64}" || exit 1 - else - echo "Please enter a tarball name with parameter -T=tarball" - exit 1 + tar xf ${_TARBALL_NAME} -C "${_CORE64}" || exit 1 +else + echo "Please enter a tarball name with parameter -T=tarball" + exit 1 fi mkdir -p "${_X86_64}/EFI/BOOT" _prepare_kernel_initramfs_files() { - - mkdir -p "${_X86_64}/boot" - mv "${_CORE64}"/*/boot/vmlinuz "${_X86_64}/boot/vmlinuz_x86_64" - mv "${_CORE64}"/*/boot/initrd.img "${_X86_64}/boot/initramfs_x86_64.img" - mv "${_CORE64}"/*/boot/{intel-ucode.img,amd-ucode.img} "${_X86_64}/boot/" - [[ -f "${_CORE64}/*/boot/memtest" ]] && mv "${_CORE64}"/*/boot/memtest "${_X86_64}/boot/" - + mkdir -p "${_X86_64}/boot" + mv "${_CORE64}"/*/boot/vmlinuz "${_X86_64}/boot/vmlinuz_x86_64" + mv "${_CORE64}"/*/boot/initrd.img "${_X86_64}/boot/initramfs_x86_64.img" + mv "${_CORE64}"/*/boot/{intel-ucode.img,amd-ucode.img} "${_X86_64}/boot/" + [[ -f "${_CORE64}/*/boot/memtest" ]] && mv "${_CORE64}"/*/boot/memtest "${_X86_64}/boot/" } _prepare_efitools_uefi () { @@ -163,245 +161,44 @@ _prepare_fedora_shim_bootloaders () { } _prepare_uefi_image() { - - ## get size of boot x86_64 files - BOOTSIZE=$(du -bc ${_X86_64}/EFI | grep total | cut -f1) - IMGSZ=$(( (${BOOTSIZE}*102)/100/1024 + 1)) # image size in sectors - - ## Create cdefiboot.img - dd if=/dev/zero of="${_X86_64}"/efi.img bs="${IMGSZ}" count=1024 - VFAT_IMAGE="${_X86_64}/efi.img" - mkfs.vfat "${VFAT_IMAGE}" - - ## Copy all files to UEFI vfat image - mcopy -i "${VFAT_IMAGE}" -s "${_X86_64}"/EFI ::/ - + ## get size of boot x86_64 files + BOOTSIZE=$(du -bc ${_X86_64}/EFI | grep total | cut -f1) + IMGSZ=$(( (${BOOTSIZE}*102)/100/1024 + 1)) # image size in sectors + ## Create cdefiboot.img + dd if=/dev/zero of="${_X86_64}"/efi.img bs="${IMGSZ}" count=1024 + VFAT_IMAGE="${_X86_64}/efi.img" + mkfs.vfat "${VFAT_IMAGE}" + ## Copy all files to UEFI vfat image + mcopy -i "${VFAT_IMAGE}" -s "${_X86_64}"/EFI ::/ } _download_uefi_shell_tianocore() { - - mkdir -p "${_X86_64}/EFI/tools/" - - ## Install Tianocore UDK/EDK2 ShellBinPkg UEFI X64 "Full Shell" - For UEFI Spec. >=2.3 systems - cp /usr/share/edk2-shell/x64/Shell.efi "${_X86_64}/EFI/tools/shellx64_v2.efi" - - ## Install Tianocore UDK/EDK2 EdkShellBinPkg UEFI X64 "Full Shell" - For UEFI Spec. <2.3 systems - cp /usr/share/edk2-shell/x64/Shell_Full.efi "${_X86_64}/EFI/tools/shellx64_v1.efi" - - ## Install Tianocore UDK/EDK2 ShellBinPkg UEFI IA32 "Full Shell" - For UEFI Spec. >=2.3 systems - cp /usr/share/edk2-shell/ia32/Shell.efi "${_X86_64}/EFI/tools/shellia32_v2.efi" - - ## InstallTianocore UDK/EDK2 EdkShellBinPkg UEFI IA32 "Full Shell" - For UEFI Spec. <2.3 systems - cp /usr/share/edk2-shell/ia32/Shell_Full.efi "${_X86_64}/EFI/tools/shellia32_v1.efi" + mkdir -p "${_X86_64}/EFI/tools/" + ## Install Tianocore UDK/EDK2 ShellBinPkg UEFI X64 "Full Shell" - For UEFI Spec. >=2.3 systems + cp /usr/share/edk2-shell/x64/Shell.efi "${_X86_64}/EFI/tools/shellx64_v2.efi" + ## Install Tianocore UDK/EDK2 EdkShellBinPkg UEFI X64 "Full Shell" - For UEFI Spec. <2.3 systems + cp /usr/share/edk2-shell/x64/Shell_Full.efi "${_X86_64}/EFI/tools/shellx64_v1.efi" + ## Install Tianocore UDK/EDK2 ShellBinPkg UEFI IA32 "Full Shell" - For UEFI Spec. >=2.3 systems + cp /usr/share/edk2-shell/ia32/Shell.efi "${_X86_64}/EFI/tools/shellia32_v2.efi" + ## InstallTianocore UDK/EDK2 EdkShellBinPkg UEFI IA32 "Full Shell" - For UEFI Spec. <2.3 systems + cp /usr/share/edk2-shell/ia32/Shell_Full.efi "${_X86_64}/EFI/tools/shellia32_v1.efi" } # build grubXXX with all modules: http://bugs.archlinux.org/task/71382 # If you don't use shim use --disable-shim-lock _prepare_uefi_X64_GRUB_USB_files() { - - mkdir -p "${_X86_64}/EFI/BOOT" - cat << GRUBEOF > "${_X86_64}/EFI/BOOT/grubx64.cfg" -insmod part_gpt -insmod part_msdos -insmod fat - -insmod efi_gop -insmod efi_uga -insmod video_bochs -insmod video_cirrus - -insmod font - -if loadfont "${prefix}/fonts/unicode.pf2" ; then - insmod gfxterm - set gfxmode="1366x768x32;1280x800x32;1024x768x32;auto" - terminal_input console - terminal_output gfxterm -fi - -set default="Arch Linux x86_64 Archboot" -set timeout="10" - -menuentry "Arch Linux x86_64 Archboot" { - set gfxpayload=keep - search --no-floppy --set=root --file /boot/vmlinuz_x86_64 - linux /boot/vmlinuz_x86_64 cgroup_disable=memory add_efi_memmap rootfstype=ramfs - initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs_x86_64.img -} - -menuentry "Secure Boot KeyTool" { - search --no-floppy --set=root --file /EFI/tools/KeyTool.efi - chainloader /EFI/tools/KeyTool.efi -} - -menuentry "Secure Boot HashTool" { - search --no-floppy --set=root --file /EFI/tools/HashTool.efi - chainloader /EFI/tools/HashTool.efi -} - -menuentry "UEFI Shell X64 v2" { - search --no-floppy --set=root --file /EFI/tools/shellx64_v2.efi - chainloader /EFI/tools/shellx64_v2.efi -} - -menuentry "UEFI Shell X64 v1" { - search --no-floppy --set=root --file /EFI/tools/shellx64_v1.efi - chainloader /EFI/tools/shellx64_v1.efi -} - -if [ "${grub_platform}" == "efi" ]; then - menuentry "Microsoft Windows" { - insmod part_gpt - insmod fat - insmod chain - search --no-floppy --fs-uuid --set=root $hints_string $fs_uuid - chainloader /EFI/Microsoft/Boot/bootmgfw.efi - } -fi - -menuentry "Enter Firmware Setup" { - fwsetup -} - -menuentry "System restart" { - echo "System rebooting..." - reboot -} - -menuentry "System shutdown" { - echo "System shutting down..." - halt -} - -menuentry "Exit GRUB" { - exit -} -GRUBEOF - ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 - grub-mkstandalone -d /usr/lib/grub/x86_64-efi -O x86_64-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efi_uga efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard" --fonts="unicode" --locales="" --themes="" -o "${_X86_64}/EFI/BOOT/grubx64.efi" "boot/grub/grub.cfg=${_X86_64}/EFI/BOOT/grubx64.cfg" + ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 + grub-mkstandalone -d /usr/lib/grub/x86_64-efi -O x86_64-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efi_uga efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard" --fonts="unicode" --locales="" --themes="" -o "${_X86_64}/EFI/BOOT/grubx64.efi" } _prepare_uefi_IA32_GRUB_USB_files() { - - mkdir -p "${_X86_64}/EFI/BOOT" - - cat << GRUBEOF > "${_X86_64}/EFI/BOOT/grubia32.cfg" -insmod part_gpt -insmod part_msdos -insmod fat - -insmod efi_gop -insmod efi_uga -insmod video_bochs -insmod video_cirrus - -insmod font - -if loadfont "${prefix}/fonts/unicode.pf2" ; then - insmod gfxterm - set gfxmode="1366x768x32;1280x800x32;1024x768x32;auto" - terminal_input console - terminal_output gfxterm -fi - -set default="Arch Linux x86_64 Archboot - EFI MIXED MODE" -set timeout="10" - -menuentry "Arch Linux x86_64 Archboot - EFI MIXED MODE" { - set gfxpayload=keep - search --no-floppy --set=root --file /boot/vmlinuz_x86_64 - linux /boot/vmlinuz_x86_64 cgroup_disable=memory add_efi_memmap _IA32_UEFI=1 rootfstype=ramfs - initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs_x86_64.img + ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 + grub-mkstandalone -d /usr/lib/grub/i386-efi -O i386-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efi_uga efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard" --fonts="unicode" --locales="" --themes="" -o "${_X86_64}/EFI/BOOT/grubia32.efi" } -menuentry "UEFI Shell IA32 v2" { - search --no-floppy --set=root --file /EFI/tools/shellia32_v2.efi - chainloader /EFI/tools/shellia32_v2.efi -} - -menuentry "UEFI Shell IA32 v1" { - search --no-floppy --set=root --file /EFI/tools/shellia32_v1.efi - chainloader /EFI/tools/shellia32_v1.efi -} - -if [ "${grub_platform}" == "efi" ]; then - menuentry "Microsoft Windows" { - insmod part_gpt - insmod fat - insmod chain - search --no-floppy --fs-uuid --set=root $hints_string $fs_uuid - chainloader /EFI/Microsoft/Boot/bootmgfw.efi - } -fi - -menuentry "Enter Firmware Setup" { - fwsetup -} - -menuentry "System restart" { - echo "System rebooting..." - reboot -} - -menuentry "System shutdown" { - echo "System shutting down..." - halt -} - -menuentry "Exit GRUB" { - exit -} -GRUBEOF - ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 - grub-mkstandalone -d /usr/lib/grub/i386-efi -O i386-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efi_uga efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard" --fonts="unicode" --locales="" --themes="" -o "${_X86_64}/EFI/BOOT/grubia32.efi" "boot/grub/grub.cfg=${_X86_64}/EFI/BOOT/grubia32.cfg" - -} - -_prepare_bios_GRUB_USB_files() { - - mkdir -p "${_X86_64}/boot/grub" - - cat << GRUBEOF > "${_X86_64}/boot/grub/grub.cfg" -insmod part_gpt -insmod part_msdos -insmod fat - -insmod video_bochs -insmod video_cirrus - -insmod font - -if loadfont "${prefix}/fonts/unicode.pf2" ; then - insmod gfxterm - set gfxmode="1366x768x32;1280x800x32;1024x768x32;auto" - terminal_input console - terminal_output gfxterm -fi - -set default="Arch Linux x86_64 Archboot - BIOS Mode" -set timeout="10" - -menuentry "Arch Linux x86_64 Archboot - BIOS Mode" { - set gfxpayload=keep - search --no-floppy --set=root --file /boot/vmlinuz_x86_64 - linux /boot/vmlinuz_x86_64 cgroup_disable=memory rootfstype=ramfs - initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs_x86_64.img -} - -menuentry "System restart" { - echo "System rebooting..." - reboot -} - -menuentry "System shutdown" { - echo "System shutting down..." - halt -} - -menuentry "Exit GRUB" { - exit -} -GRUBEOF +_prepare_GRUB_config_file() { + [[ -d "${_X86_64}/boot/grub" ]] || mkdir -p "${_X86_64}/boot/grub" + cp /usr/share/archboot/grub.cfg "${_X86_64}/boot/grub/grub.cfg" } echo "Starting ISO creation ..." @@ -424,7 +221,7 @@ echo "Prepare IA32 Grub ..." _prepare_uefi_IA32_GRUB_USB_files >/dev/null 2>&1 echo "Prepare BIOS Grub ..." -_prepare_bios_GRUB_USB_files >/dev/null 2>&1 +_prepare_GRUB_config_file >/dev/null 2>&1 echo "Prepare UEFI image ..." _prepare_uefi_image >/dev/null 2>&1 diff --git a/usr/share/archboot/grub/grub.cfg b/usr/share/archboot/grub/grub.cfg new file mode 100644 index 000000000..2ff41b349 --- /dev/null +++ b/usr/share/archboot/grub/grub.cfg @@ -0,0 +1,137 @@ +insmod part_gpt +insmod part_msdos +insmod fat + +if [ ${grub_platform} == "efi" ]; then + insmod efi_gop + if [ ${grub_cpu} == "x86_64" || ${grub_cpu} == "i386"]; then + insmod efi_uga + fi +fi + +insmod video_bochs +insmod video_cirrus + +insmod font + +if loadfont "${prefix}/fonts/unicode.pf2" ; then + insmod gfxterm + set gfxmode="1366x768x32;1280x800x32;1024x768x32;auto" + terminal_input console + terminal_output gfxterm +fi + +if [ ${grub_platform} == "efi" ]; then + if [ ${grub_cpu} == "i386" ]; then + set default="Arch Linux x86_64 Archboot - EFI MIXED MODE" + fi + if [ ${grub_cpu} == "x86_64" ]; then + set default="Arch Linux x86_64 Archboot" + fi + if [ ${grub_cpu} == "arm64" ]; then + set default="Arch Linux AA64 Archboot" + fi +fi + +if [ ${grub_platform} == "pc" ]; then + set default="Arch Linux X86_64 Archboot - BIOS Mode" +fi + +set timeout="10" + +if [ ${grub_platform} == "efi" ]; then + if [ ${grub_cpu} == "arm64" ]; then + menuentry "Arch Linux AA64 Archboot" { + set gfxpayload=keep + search --no-floppy --set=root --file /boot/vmlinuz_aarch64 + linux /boot/vmlinuz_aarch64 cgroup_disable=memory rootfstype=ramfs audit=0 nr_cpus=1 + initrd /boot/amd-ucode.img /boot/initramfs_aarch64.img + } + fi + if [ ${grub_cpu} == "x86_64" ]; then + menuentry "Arch Linux x86_64 Archboot" { + set gfxpayload=keep + search --no-floppy --set=root --file /boot/vmlinuz_x86_64 + linux /boot/vmlinuz_x86_64 cgroup_disable=memory rootfstype=ramfs + initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs_x86_64.img + } + fi + if [ ${grub_cpu} == "i386" ]; then + menuentry "Arch Linux x86_64 Archboot - EFI MIXED MODE" { + set gfxpayload=keep + search --no-floppy --set=root --file /boot/vmlinuz_x86_64 + linux /boot/vmlinuz_x86_64 cgroup_disable=memory _IA32_UEFI=1 rootfstype=ramfs + initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs_x86_64.img + } + fi +fi + +if [ ${grub_platform} == "pc" ]; then + menuentry "Arch Linux x86_64 Archboot - BIOS Mode" { + set gfxpayload=keep + search --no-floppy --set=root --file /boot/vmlinuz_x86_64 + linux /boot/vmlinuz_x86_64 cgroup_disable=memory rootfstype=ramfs + initrd /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs_x86_64.img + } +fi + +if [ ${grub_platform} == "efi" ]; then + if [ ${grub_cpu} == "x86_64" || ${grub_cpu} == "arm64" ]; then + menuentry "Secure Boot KeyTool" { + search --no-floppy --set=root --file /EFI/tools/KeyTool.efi + chainloader /EFI/tools/KeyTool.efi + } + + menuentry "Secure Boot HashTool" { + search --no-floppy --set=root --file /EFI/tools/HashTool.efi + chainloader /EFI/tools/HashTool.efi + } + fi + if [ ${grub_cpu} == "i386" ]; then + menuentry "UEFI Shell IA32 v2" { + search --no-floppy --set=root --file /EFI/tools/shellia32_v2.efi + chainloader /EFI/tools/shellia32_v2.efi + } + + menuentry "UEFI Shell IA32 v1" { + search --no-floppy --set=root --file /EFI/tools/shellia32_v1.efi + chainloader /EFI/tools/shellia32_v1.efi + } + fi + if [ ${grub_cpu} == "x86_64" ]; then + menuentry "UEFI Shell X64 v2" { + search --no-floppy --set=root --file /EFI/tools/shellx64_v2.efi + chainloader /EFI/tools/shellx64_v2.efi + } + + menuentry "UEFI Shell X64 v1" { + search --no-floppy --set=root --file /EFI/tools/shellx64_v1.efi + chainloader /EFI/tools/shellx64_v1.efi + } + fi + menuentry "Enter Firmware Setup" { + fwsetup + } +fi + +if [ "${grub_platform}" == "efi" ]; then + menuentry "Microsoft Windows" { + insmod chain + search --no-floppy --fs-uuid --set=root $hints_string $fs_uuid + chainloader /EFI/Microsoft/Boot/bootmgfw.efi + } +fi + +menuentry "System restart" { + echo "System rebooting..." + reboot +} + +menuentry "System shutdown" { + echo "System shutting down..." + halt +} + +menuentry "Exit GRUB" { + exit +}