From 8d7ad3c629e1a2d0cb2f2008e62ea979639230e7 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Sun, 22 Jan 2023 12:02:35 +0200 Subject: mkarchiso: write a .uuid file to /.disk/ on ISO 9660 to allow GRUB to search for it Create a `/.disk/INSERT_UUID_HERE.uuid` file to implement something called "file system transposition". See https://www.mail-archive.com/grub-devel@gnu.org/msg34346.html for the proposal of it for grub-mkrescue. This will allow GRUB to search for the volume containing the file instead of hardcoding the ISO volume label or another file system or partition attribute in GRUB configuration. By only relying on the directory structure simplifies supporting medium preparation methods with manual partitioning such as https://wiki.archlinux.org/title/USB_flash_installation_medium#In_GNU/Linux_4 --- archiso/mkarchiso | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 7331bb0..f8a3df1 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -569,7 +569,13 @@ _make_common_bootmode_grub_copy_to_isofs() { # Prepare GRUB configuration files _make_common_bootmode_grub_cfg(){ - local _cfg + local _cfg uuid_search_filename + + # Create a .uuid file and place it in /.disk/ on ISO 9660 to provide a way for GRUB to search for the volume + uuid_search_filename="$(uuidgen --sha1 --namespace 93a870ff-8565-4cf3-a67b-f47299271a96 \ + --name "${SOURCE_DATE_EPOCH} disk search UUID")" + install -d -m 0755 -- "${isofs_dir}/.disk" + : > "${isofs_dir}/.disk/${uuid_search_filename}.uuid" install -d -- "${work_dir}/grub" @@ -577,7 +583,8 @@ _make_common_bootmode_grub_cfg(){ for _cfg in "${profile}/grub/"*'.cfg'; do sed "s|%ARCHISO_LABEL%|${iso_label}|g; s|%INSTALL_DIR%|${install_dir}|g; - s|%ARCH%|${arch}|g" \ + s|%ARCH%|${arch}|g; + s|%UUID_SEARCH_FILENAME%|${uuid_search_filename}|g" \ "${_cfg}" > "${work_dir}/grub/${_cfg##*/}" done # Add all GRUB files to the list of files used to calculate the required FAT image size. -- cgit v1.2.3-70-g09d2 From 5587e031f34d7cd1828012596453bc9b2c8be26b Mon Sep 17 00:00:00 2001 From: nl6720 Date: Sun, 22 Jan 2023 13:32:54 +0200 Subject: Preload GRUB's NTFS, exFAT and UDF modules There are claims that some UEFI allegedly natively support NTFS. Preload the required GRUB modules to support booting from NTFS on such systems. Additionally preload the exFAT and UEF modules, because, why not? --- CHANGELOG.rst | 2 ++ archiso/mkarchiso | 16 ++++++++-------- configs/baseline/grub/grub.cfg | 4 ++++ configs/releng/grub/grub.cfg | 4 ++++ 4 files changed, 18 insertions(+), 8 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f6a6f25..e2dfa9e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,8 @@ Added - Support *file system transposition* to simplify boot medium preparation for UEFI boot via extracting the ISO image contents to a drive. ``grub.cfg`` does not hardcode the ISO volume label anymore, instead GRUB will search for volume with a ``/.disk/%UUID_SEARCH_FILENAME%.uuid`` file on it. +- Preload GRUB's NTFS modules for UEFI that allegedly have native NTFS support. GRUB's exFAT and UDF modules are also + preloaded in case someone finds them useful. Changed ------- diff --git a/archiso/mkarchiso b/archiso/mkarchiso index f8a3df1..c1a8c22 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -612,11 +612,11 @@ _make_bootmode_uefi-ia32.grub.esp() { # Create EFI binary # Module list from https://bugs.archlinux.org/task/71382#comment202911 - grubmodules=(all_video at_keyboard boot btrfs cat chain configfile echo efifwsetup efinet ext2 f2fs fat font \ + grubmodules=(all_video at_keyboard boot btrfs cat chain configfile echo efifwsetup efinet exfat ext2 f2fs fat font \ gfxmenu gfxterm gzio halt hfsplus iso9660 jpeg keylayouts linux loadenv loopback lsefi lsefimmap \ - minicmd normal part_apple part_gpt part_msdos png read reboot regexp search search_fs_file \ - search_fs_uuid search_label serial sleep tpm usb usbserial_common usbserial_ftdi usbserial_pl2303 \ - usbserial_usbdebug video xfs zstd) + minicmd normal ntfs ntfscomp part_apple part_gpt part_msdos png read reboot regexp search \ + search_fs_file search_fs_uuid search_label serial sleep tpm udf usb usbserial_common usbserial_ftdi \ + usbserial_pl2303 usbserial_usbdebug video xfs zstd) grub-mkstandalone -O i386-efi \ --modules="${grubmodules[*]}" \ --locales="en@quot" \ @@ -689,11 +689,11 @@ _make_bootmode_uefi-x64.grub.esp() { # Create EFI binary # Module list from https://bugs.archlinux.org/task/71382#comment202911 - grubmodules=(all_video at_keyboard boot btrfs cat chain configfile echo efifwsetup efinet ext2 f2fs fat font \ + grubmodules=(all_video at_keyboard boot btrfs cat chain configfile echo efifwsetup efinet exfat ext2 f2fs fat font \ gfxmenu gfxterm gzio halt hfsplus iso9660 jpeg keylayouts linux loadenv loopback lsefi lsefimmap \ - minicmd normal part_apple part_gpt part_msdos png read reboot regexp search search_fs_file \ - search_fs_uuid search_label serial sleep tpm usb usbserial_common usbserial_ftdi usbserial_pl2303 \ - usbserial_usbdebug video xfs zstd) + minicmd normal ntfs ntfscomp part_apple part_gpt part_msdos png read reboot regexp search \ + search_fs_file search_fs_uuid search_label serial sleep tpm udf usb usbserial_common usbserial_ftdi \ + usbserial_pl2303 usbserial_usbdebug video xfs zstd) grub-mkstandalone -O x86_64-efi \ --modules="${grubmodules[*]}" \ --locales="en@quot" \ diff --git a/configs/baseline/grub/grub.cfg b/configs/baseline/grub/grub.cfg index 7d73fe6..d606b10 100644 --- a/configs/baseline/grub/grub.cfg +++ b/configs/baseline/grub/grub.cfg @@ -3,6 +3,10 @@ insmod part_gpt insmod part_msdos insmod fat insmod iso9660 +insmod ntfs +insmod ntfscomp +insmod exfat +insmod udf # Use graphics-mode output insmod all_video diff --git a/configs/releng/grub/grub.cfg b/configs/releng/grub/grub.cfg index ddd8af2..ddf71e7 100644 --- a/configs/releng/grub/grub.cfg +++ b/configs/releng/grub/grub.cfg @@ -3,6 +3,10 @@ insmod part_gpt insmod part_msdos insmod fat insmod iso9660 +insmod ntfs +insmod ntfscomp +insmod exfat +insmod udf # Use graphics-mode output insmod all_video -- cgit v1.2.3-70-g09d2 From 28d2bc11e3dc4a86667a8f5f379d8ac9c18c0a03 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Thu, 27 Oct 2022 11:04:42 +0300 Subject: mkarchiso: do not place memtest86+ in netboot artifacts Move memtest86+ to `/boot/memtest86+/` on ISO 9660. That directory is not copied to netboot artifact output. Netboot boot menu https://ipxe.archlinux.org/releng/netboot/archlinux.ipxe does not have entries for memtest and archiso-manager removes these files (not the EFI one, though) before uploading the release files anyway. --- CHANGELOG.rst | 2 ++ archiso/mkarchiso | 14 ++++++-------- configs/releng/grub/grub.cfg | 2 +- configs/releng/syslinux/archiso_tail.cfg | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e2dfa9e..2b0d90f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -23,6 +23,8 @@ Changed Removed ------- +- Do not place memtest86+ in netboot artifacts. + [69] - 2022-12-24 ================= diff --git a/archiso/mkarchiso b/archiso/mkarchiso index c1a8c22..ce89642 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -471,11 +471,10 @@ _make_bootmode_bios.syslinux.mbr() { # Add other aditional/extra files to ${install_dir}/boot/ if [[ -e "${pacstrap_dir}/boot/memtest86+/memtest.bin" ]]; then + install -d -m 0755 -- "${isofs_dir}/boot/memtest86+/" # rename for PXE: https://wiki.archlinux.org/title/Syslinux#Using_memtest - install -m 0644 -- "${pacstrap_dir}/boot/memtest86+/memtest.bin" "${isofs_dir}/${install_dir}/boot/memtest" - install -d -m 0755 -- "${isofs_dir}/${install_dir}/boot/licenses/memtest86+/" - install -m 0644 -- "${pacstrap_dir}/usr/share/licenses/common/GPL2/license.txt" \ - "${isofs_dir}/${install_dir}/boot/licenses/memtest86+/" + install -m 0644 -- "${pacstrap_dir}/boot/memtest86+/memtest.bin" "${isofs_dir}/boot/memtest86+/memtest" + install -m 0644 -- "${pacstrap_dir}/usr/share/licenses/common/GPL2/license.txt" "${isofs_dir}/boot/memtest86+/" fi _msg_info "Done! SYSLINUX set up for BIOS booting from a disk successfully." } @@ -722,10 +721,9 @@ _make_bootmode_uefi-x64.grub.esp() { # Add other aditional/extra files to ${install_dir}/boot/ if [[ -e "${pacstrap_dir}/boot/memtest86+/memtest.efi" ]]; then - install -m 0644 -- "${pacstrap_dir}/boot/memtest86+/memtest.efi" "${isofs_dir}/${install_dir}/boot/memtest.efi" - install -d -m 0755 -- "${isofs_dir}/${install_dir}/boot/licenses/memtest86+/" - install -m 0644 -- "${pacstrap_dir}/usr/share/licenses/common/GPL2/license.txt" \ - "${isofs_dir}/${install_dir}/boot/licenses/memtest86+/" + install -d -m 0755 -- "${isofs_dir}/boot/memtest86+/" + install -m 0644 -- "${pacstrap_dir}/boot/memtest86+/memtest.efi" "${isofs_dir}/boot/memtest86+/memtest.efi" + install -m 0644 -- "${pacstrap_dir}/usr/share/licenses/common/GPL2/license.txt" "${isofs_dir}/boot/memtest86+/" fi _msg_info "Done! GRUB set up for UEFI booting successfully." diff --git a/configs/releng/grub/grub.cfg b/configs/releng/grub/grub.cfg index ddf71e7..eb45a00 100644 --- a/configs/releng/grub/grub.cfg +++ b/configs/releng/grub/grub.cfg @@ -55,7 +55,7 @@ if [ "${grub_platform}" == "efi" ]; then if [ "${grub_cpu}" == "x86_64" ]; then menuentry "Run Memtest86+ (RAM test)" --class memtest86 --class gnu --class tool { set gfxpayload=800x600,1024x768 - linux /%INSTALL_DIR%/boot/memtest.efi + linux /boot/memtest86+/memtest.efi } menuentry "UEFI Shell" { insmod chain diff --git a/configs/releng/syslinux/archiso_tail.cfg b/configs/releng/syslinux/archiso_tail.cfg index dcbb413..e84897c 100644 --- a/configs/releng/syslinux/archiso_tail.cfg +++ b/configs/releng/syslinux/archiso_tail.cfg @@ -10,7 +10,7 @@ APPEND hd0 0 # https://www.memtest.org/ LABEL memtest MENU LABEL Run Memtest86+ (RAM test) -LINUX /%INSTALL_DIR%/boot/memtest +LINUX /boot/memtest86+/memtest # https://wiki.syslinux.org/wiki/index.php/Hdt_(Hardware_Detection_Tool) LABEL hdt -- cgit v1.2.3-70-g09d2 From 40e09767f0cea7c4a94af98504e9c936f1dd7720 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Wed, 25 Jan 2023 23:05:48 +0200 Subject: mkarchiso: add more details to the comment in grub-embed.cfg Link to the upstream issue report. --- archiso/mkarchiso | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/archiso/mkarchiso b/archiso/mkarchiso index ce89642..c116a27 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -590,10 +590,13 @@ _make_common_bootmode_grub_cfg(){ efiboot_files+=("${work_dir}/grub/" "${profile}/grub/"!(*.cfg)) + # Prepare grub.cfg that will be embedded inside the GRUB binaries IFS='' read -r -d '' grubembedcfg <<'EOF' || true if ! [ -d "$cmdpath" ]; then - # On some firmware, GRUB has a wrong cmdpath when booted from an optical disc. - # https://gitlab.archlinux.org/archlinux/archiso/-/issues/183 + # On some firmware, GRUB has a wrong cmdpath when booted from an optical disc. During El Torito boot, GRUB is + # launched from a case-insensitive FAT-formatted EFI system partition, but it seemingly cannot access that partition + # and sets cmdpath to the whole cd# device which has case-sensitive ISO 9660 + Rock Ridge + Joliet file systems. + # See https://gitlab.archlinux.org/archlinux/archiso/-/issues/183 and https://savannah.gnu.org/bugs/?62886 if regexp --set=1:isodevice '^(\([^)]+\))\/?[Ee][Ff][Ii]\/[Bb][Oo][Oo][Tt]\/?$' "$cmdpath"; then cmdpath="${isodevice}/EFI/BOOT" fi -- cgit v1.2.3-70-g09d2 From f5ade898f9cb0de1f6fb01fcef088d8a6b56de7d Mon Sep 17 00:00:00 2001 From: nl6720 Date: Sat, 28 Jan 2023 13:08:49 +0200 Subject: Do not duplicate grub.cfg in efiboot.img Instruct the embeded grub.cfg to search for a volume with a `/.disk/%UUID_SEARCH_FILENAME%.uuid` file and load `/EFI/BOOT/grub.cfg` from it. This avoid duplicating GRUB configuration files in two places (ISO 9660 and FAT) and ensures there is no confusion about which is the _correct_ configuration file. Since nothing besides EFI binaries is copied to `efibootimg`, the `_make_common_bootmode_grub_copy_to_efibootimg` function is removed. Fixes #208 --- CHANGELOG.rst | 2 ++ archiso/mkarchiso | 54 ++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 20 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d55c15d..e00ebcb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,8 @@ Changed - Identify the ISO volume via a UUID instead of a file system label to avoid collisions of multiple ISOs created in the same month. - Honor ``SOURCE_DATE_EPOCH`` in the ``date`` command used by ``profiledef.sh`` of the shipped profiles. +- Do not duplicate ``grub.cfg`` in both ISO 9660 and the EFI system partition / El Torito image. GRUB will search for + the ISO volume and load the ``grub.cfg`` from there. Removed ------- diff --git a/archiso/mkarchiso b/archiso/mkarchiso index c116a27..00c974e 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -544,18 +544,7 @@ _make_efibootimg() { mmd -i "${efibootimg}" ::/EFI ::/EFI/BOOT } -# Copy GRUB files to efiboot.img which is used by both IA32 UEFI and x64 UEFI. -_make_common_bootmode_grub_copy_to_efibootimg() { - local files_to_copy=() - - files_to_copy+=("${work_dir}/grub/"*) - if compgen -G "${profile}/grub/!(*.cfg)" &> /dev/null; then - files_to_copy+=("${profile}/grub/"!(*.cfg)) - fi - mcopy -i "${efibootimg}" "${files_to_copy[@]}" ::/EFI/BOOT/ -} - -# Copy GRUB files to efiboot.img which is used by both IA32 UEFI and x64 UEFI. +# Copy GRUB files to ISO 9660 which is used by both IA32 UEFI and x64 UEFI _make_common_bootmode_grub_copy_to_isofs() { local files_to_copy=() @@ -563,6 +552,7 @@ _make_common_bootmode_grub_copy_to_isofs() { if compgen -G "${profile}/grub/!(*.cfg)" &> /dev/null; then files_to_copy+=("${profile}/grub/"!(*.cfg)) fi + install -d -m 0755 -- "${isofs_dir}/EFI/BOOT" install -m 0644 -- "${files_to_copy[@]}" "${isofs_dir}/EFI/BOOT/" } @@ -586,9 +576,6 @@ _make_common_bootmode_grub_cfg(){ s|%UUID_SEARCH_FILENAME%|${uuid_search_filename}|g" \ "${_cfg}" > "${work_dir}/grub/${_cfg##*/}" done - # Add all GRUB files to the list of files used to calculate the required FAT image size. - efiboot_files+=("${work_dir}/grub/" - "${profile}/grub/"!(*.cfg)) # Prepare grub.cfg that will be embedded inside the GRUB binaries IFS='' read -r -d '' grubembedcfg <<'EOF' || true @@ -597,12 +584,39 @@ if ! [ -d "$cmdpath" ]; then # launched from a case-insensitive FAT-formatted EFI system partition, but it seemingly cannot access that partition # and sets cmdpath to the whole cd# device which has case-sensitive ISO 9660 + Rock Ridge + Joliet file systems. # See https://gitlab.archlinux.org/archlinux/archiso/-/issues/183 and https://savannah.gnu.org/bugs/?62886 - if regexp --set=1:isodevice '^(\([^)]+\))\/?[Ee][Ff][Ii]\/[Bb][Oo][Oo][Tt]\/?$' "$cmdpath"; then - cmdpath="${isodevice}/EFI/BOOT" + if regexp --set=1:archiso_bootdevice '^\(([^)]+)\)\/?[Ee][Ff][Ii]\/[Bb][Oo][Oo][Tt]\/?$' "${cmdpath}"; then + set cmdpath="(${archiso_bootdevice})/EFI/BOOT" + set ARCHISO_HINT="${archiso_bootdevice}" fi fi -configfile "${cmdpath}/grub.cfg" + +# Prepare a hint for the search command using the device in cmdpath +if [ -z "${ARCHISO_HINT}" ]; then + regexp --set=1:ARCHISO_HINT '^\(([^)]+)\)' "${cmdpath}" +fi + +# Search for the ISO volume +if search --no-floppy --set=archiso_device --file '/.disk/%UUID_SEARCH_FILENAME%.uuid' --hint "${ARCHISO_HINT}"; then + set ARCHISO_HINT="${archiso_device}" + if probe --set ARCHISO_UUID --fs-uuid "${ARCHISO_HINT}"; then + export ARCHISO_UUID + fi +else + echo "Could not find a volume with a '/.disk/%UUID_SEARCH_FILENAME%.uuid' file on it!" +fi + +# Load grub.cfg +if [ "${ARCHISO_HINT}" == 'memdisk' -o -z "${ARCHISO_HINT}" ]; then + echo 'Could not find the ISO volume!' +elif [ -e "(${ARCHISO_HINT})/EFI/BOOT/grub.cfg" ]; then + export ARCHISO_HINT + set root="${ARCHISO_HINT}" + configfile "(${ARCHISO_HINT})/EFI/BOOT/grub.cfg" +else + echo "File '(${ARCHISO_HINT})/EFI/BOOT/grub.cfg' not found!" +fi EOF + grubembedcfg="${grubembedcfg//'%UUID_SEARCH_FILENAME%'/"${uuid_search_filename}"}" printf '%s\n' "$grubembedcfg" > "${work_dir}/grub-embed.cfg" } @@ -645,7 +659,7 @@ _make_bootmode_uefi-ia32.grub.esp() { mcopy -i "${efibootimg}" "${work_dir}/BOOTIA32.EFI" ::/EFI/BOOT/BOOTIA32.EFI # Copy GRUB files - _run_once _make_common_bootmode_grub_copy_to_efibootimg + _run_once _make_common_bootmode_grub_copy_to_isofs if [[ -e "${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi" ]]; then mcopy -i "${efibootimg}" "${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi" ::/shellia32.efi @@ -716,7 +730,7 @@ _make_bootmode_uefi-x64.grub.esp() { mcopy -i "${efibootimg}" "${work_dir}/BOOTx64.EFI" ::/EFI/BOOT/BOOTx64.EFI # Copy GRUB files - _run_once _make_common_bootmode_grub_copy_to_efibootimg + _run_once _make_common_bootmode_grub_copy_to_isofs if [[ -e "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ]]; then mcopy -i "${efibootimg}" "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ::/shellx64.efi -- cgit v1.2.3-70-g09d2 From b94d7c4ce5afdec032835378a7f6c564aecb05ed Mon Sep 17 00:00:00 2001 From: nl6720 Date: Sat, 28 Jan 2023 13:22:42 +0200 Subject: Move grub files from /EFI/BOOT/ to /boot/grub/ on ISO 9660 Move the location of GRUB files so that there is boot-platform (BIOS vs EFI) neutral place for GRUB-specific files (e.g. configuration files, background images, etc.). The EFI binaries are obviosly staying in the default/fallback boot path `/EFI/BOOT/BOOT*.EFI`, otherwise there will be no UEFI booting. The /boot/grub/ directory will be used to store BIOS (i386-pc) GRUB bootsector images, if we get to that. It is also a requirement for implementing `loopback.cfg` support, since the file's path must be `/boot/grub/loopback.cfg`. Implements #206 --- CHANGELOG.rst | 2 ++ archiso/mkarchiso | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e00ebcb..da1c9ea 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,6 +22,8 @@ Changed - Honor ``SOURCE_DATE_EPOCH`` in the ``date`` command used by ``profiledef.sh`` of the shipped profiles. - Do not duplicate ``grub.cfg`` in both ISO 9660 and the EFI system partition / El Torito image. GRUB will search for the ISO volume and load the ``grub.cfg`` from there. +- Moved GRUB files on ISO 9660 from ``/EFI/BOOT/`` to a boot-platform neutral place ``/boot/grub/``. This does not apply + to the EFI binaries that remain in the default/fallback boot path. Removed ------- diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 00c974e..9acba1a 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -552,8 +552,8 @@ _make_common_bootmode_grub_copy_to_isofs() { if compgen -G "${profile}/grub/!(*.cfg)" &> /dev/null; then files_to_copy+=("${profile}/grub/"!(*.cfg)) fi - install -d -m 0755 -- "${isofs_dir}/EFI/BOOT" - install -m 0644 -- "${files_to_copy[@]}" "${isofs_dir}/EFI/BOOT/" + install -d -m 0755 -- "${isofs_dir}/boot/grub" + install -m 0644 -- "${files_to_copy[@]}" "${isofs_dir}/boot/grub/" } # Prepare GRUB configuration files @@ -608,12 +608,12 @@ fi # Load grub.cfg if [ "${ARCHISO_HINT}" == 'memdisk' -o -z "${ARCHISO_HINT}" ]; then echo 'Could not find the ISO volume!' -elif [ -e "(${ARCHISO_HINT})/EFI/BOOT/grub.cfg" ]; then +elif [ -e "(${ARCHISO_HINT})/boot/grub/grub.cfg" ]; then export ARCHISO_HINT set root="${ARCHISO_HINT}" - configfile "(${ARCHISO_HINT})/EFI/BOOT/grub.cfg" + configfile "(${ARCHISO_HINT})/boot/grub/grub.cfg" else - echo "File '(${ARCHISO_HINT})/EFI/BOOT/grub.cfg' not found!" + echo "File '(${ARCHISO_HINT})/boot/grub/grub.cfg' not found!" fi EOF grubembedcfg="${grubembedcfg//'%UUID_SEARCH_FILENAME%'/"${uuid_search_filename}"}" -- cgit v1.2.3-70-g09d2 From d96a3569957906eb95a76e302cf75da250cd8337 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Sat, 28 Jan 2023 13:57:36 +0200 Subject: mkarchiso: write grubenv in _make_common_bootmode_grub_cfg Add all variables that we replace with values in configuration files. Keep `${isofs_dir}/${install_dir}/grubenv` with fewer variables for backwards compatibility. It will be removed in the future. --- CHANGELOG.rst | 3 +++ README.rst | 2 +- archiso/mkarchiso | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'archiso/mkarchiso') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index da1c9ea..0196770 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -24,6 +24,9 @@ Changed the ISO volume and load the ``grub.cfg`` from there. - Moved GRUB files on ISO 9660 from ``/EFI/BOOT/`` to a boot-platform neutral place ``/boot/grub/``. This does not apply to the EFI binaries that remain in the default/fallback boot path. +- Move ``grubenv`` to ``/boot/grub/grubenv`` on ISO 9660 so that it is together with the rest of GRUB-specific files. + Additionally write more variables in it. The previous ``/${install_dir}/grubenv`` (``/arch/grubenv`` for releng) + is deprecated and a future archiso release will not create this file anymore. Removed ------- diff --git a/README.rst b/README.rst index 51cb600..5a544c5 100644 --- a/README.rst +++ b/README.rst @@ -129,7 +129,7 @@ boot the iso image from GRUB with a version specific cow directory to mitigate o .. code:: sh loopback loop archlinux.iso - load_env -f (loop)/arch/grubenv + load_env -f (loop)/boot/grub/grubenv linux (loop)/arch/boot/x86_64/vmlinuz-linux ... \ cow_directory=${NAME}/${VERSION} ... initrd (loop)/arch/boot/x86_64/initramfs-linux-lts.img diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 9acba1a..0ffe0ca 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -618,6 +618,18 @@ fi EOF grubembedcfg="${grubembedcfg//'%UUID_SEARCH_FILENAME%'/"${uuid_search_filename}"}" printf '%s\n' "$grubembedcfg" > "${work_dir}/grub-embed.cfg" + + # Write grubenv + printf '%.1024s' \ + "$(printf '# GRUB Environment Block\nNAME=%s\nVERSION=%s\nARCHISO_LABEL=%s\nINSTALL_DIR=%s\nARCH=%s\nUUID_SEARCH_FILENAME=%s\n%s' \ + "${iso_name}" \ + "${iso_version}" \ + "${iso_label}" \ + "${install_dir}" \ + "${arch}" \ + "${uuid_search_filename}" \ + "$(printf '%0.1s' "#"{1..1024})")" \ + > "${work_dir}/grub/grubenv" } _make_bootmode_uefi-ia32.grub.esp() { @@ -1067,6 +1079,10 @@ _export_netboot_artifacts() { _msg_info "Exporting netboot artifacts..." install -d -m 0755 "${out_dir}" cp -a -- "${isofs_dir}/${install_dir}/" "${out_dir}/" + + # Remove grubenv since it serves no purpose in netboot artifacts + rm -f -- "${out_dir}/${install_dir}/grubenv" + _msg_info "Done!" du -hs -- "${out_dir}/${install_dir}" } @@ -1663,7 +1679,13 @@ _make_version() { install -d -m 0755 -- "${isofs_dir}/${install_dir}" # Write version file to ISO 9660 printf '%s\n' "${iso_version}" > "${isofs_dir}/${install_dir}/version" + + fi + if [[ "${buildmode}" == "iso" ]]; then # Write grubenv with version information to ISO 9660 + # TODO: after sufficient time has passed, do not create this file anymore when GRUB boot modes are used. + # _make_common_bootmode_grub_cfg already creates ${isofs_dir}/boot/grub/grubenv + rm -f -- "${isofs_dir}/${install_dir}/grubenv" printf '%.1024s' "$(printf '# GRUB Environment Block\nNAME=%s\nVERSION=%s\n%s' \ "${iso_name}" "${iso_version}" "$(printf '%0.1s' "#"{1..1024})")" \ > "${isofs_dir}/${install_dir}/grubenv" -- cgit v1.2.3-70-g09d2 From c8474f8dbe2df8fa9af11e4b3d0bde24bb8b54f9 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Thu, 9 Feb 2023 11:16:52 +0200 Subject: Move the .uuid file to /boot/grub/YYYY-mm-dd-HH-MM-SS-00.uuid To prevent the file from being accidentally missed when someone copies the ISO's contents, let's not place it in a directory that starts with a dot. Since all GRUB related files are in /boot/grub/, put it there too. Instead of using a more unique UUID for the file name, use `YYYY-mm-dd-HH-MM-SS-00.uuid` which matches the ISO's modification date in UTC,i.e. its "UUID". If multiple ISOs would be generated in the exact same second, the ISO 9660 modification date (i.e. its "UUID") would be the same, so there would be not way to distinguish between the volumes anyway. This also makes the file look less suspicious to the casual glance. --- CHANGELOG.rst | 2 +- archiso/mkarchiso | 28 +++++++++++++++------------- configs/baseline/grub/grub.cfg | 2 +- configs/releng/grub/grub.cfg | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0196770..7a83622 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,7 +10,7 @@ Added - Support *file system transposition* to simplify boot medium preparation for UEFI boot via extracting the ISO image contents to a drive. ``grub.cfg`` does not hardcode the ISO volume label anymore, instead GRUB will search for volume - with a ``/.disk/%UUID_SEARCH_FILENAME%.uuid`` file on it. + with a ``/boot/grub/YYYY-mm-dd-HH-MM-SS-00.uuid`` file on it. - Preload GRUB's NTFS modules for UEFI that allegedly have native NTFS support. GRUB's exFAT and UDF modules are also preloaded in case someone finds them useful. diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 0ffe0ca..a543280 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -558,22 +558,24 @@ _make_common_bootmode_grub_copy_to_isofs() { # Prepare GRUB configuration files _make_common_bootmode_grub_cfg(){ - local _cfg uuid_search_filename - - # Create a .uuid file and place it in /.disk/ on ISO 9660 to provide a way for GRUB to search for the volume - uuid_search_filename="$(uuidgen --sha1 --namespace 93a870ff-8565-4cf3-a67b-f47299271a96 \ - --name "${SOURCE_DATE_EPOCH} disk search UUID")" - install -d -m 0755 -- "${isofs_dir}/.disk" - : > "${isofs_dir}/.disk/${uuid_search_filename}.uuid" + local _cfg archiso_uuid search_filename install -d -- "${work_dir}/grub" + # Precalculate the ISO's modification date in UTC, i.e. its "UUID" + TZ=UTC printf -v archiso_uuid '%(%F-%H-%M-%S-00)T' "$SOURCE_DATE_EPOCH" + # Create a /boot/grub/YYYY-mm-dd-HH-MM-SS-00.uuid file on ISO 9660. GRUB will search for it to find the ISO + # volume. This is similar to what grub-mkrescue does, except it places the file in /.disk/, but we opt to use a + # directory that does not start with a dot to avoid it being accidentally missed when copying the ISO's contents. + : > "${work_dir}/grub/${archiso_uuid}.uuid" + search_filename="/boot/grub/${archiso_uuid}.uuid" + # Fill GRUB configuration files for _cfg in "${profile}/grub/"*'.cfg'; do sed "s|%ARCHISO_LABEL%|${iso_label}|g; s|%INSTALL_DIR%|${install_dir}|g; s|%ARCH%|${arch}|g; - s|%UUID_SEARCH_FILENAME%|${uuid_search_filename}|g" \ + s|%ARCHISO_SEARCH_FILENAME%|${search_filename}|g" \ "${_cfg}" > "${work_dir}/grub/${_cfg##*/}" done @@ -596,13 +598,13 @@ if [ -z "${ARCHISO_HINT}" ]; then fi # Search for the ISO volume -if search --no-floppy --set=archiso_device --file '/.disk/%UUID_SEARCH_FILENAME%.uuid' --hint "${ARCHISO_HINT}"; then +if search --no-floppy --set=archiso_device --file '%ARCHISO_SEARCH_FILENAME%' --hint "${ARCHISO_HINT}"; then set ARCHISO_HINT="${archiso_device}" if probe --set ARCHISO_UUID --fs-uuid "${ARCHISO_HINT}"; then export ARCHISO_UUID fi else - echo "Could not find a volume with a '/.disk/%UUID_SEARCH_FILENAME%.uuid' file on it!" + echo "Could not find a volume with a '%ARCHISO_SEARCH_FILENAME%' file on it!" fi # Load grub.cfg @@ -616,18 +618,18 @@ else echo "File '(${ARCHISO_HINT})/boot/grub/grub.cfg' not found!" fi EOF - grubembedcfg="${grubembedcfg//'%UUID_SEARCH_FILENAME%'/"${uuid_search_filename}"}" + grubembedcfg="${grubembedcfg//'%ARCHISO_SEARCH_FILENAME%'/"${search_filename}"}" printf '%s\n' "$grubembedcfg" > "${work_dir}/grub-embed.cfg" # Write grubenv printf '%.1024s' \ - "$(printf '# GRUB Environment Block\nNAME=%s\nVERSION=%s\nARCHISO_LABEL=%s\nINSTALL_DIR=%s\nARCH=%s\nUUID_SEARCH_FILENAME=%s\n%s' \ + "$(printf '# GRUB Environment Block\nNAME=%s\nVERSION=%s\nARCHISO_LABEL=%s\nINSTALL_DIR=%s\nARCH=%s\nARCHISO_SEARCH_FILENAME=%s\n%s' \ "${iso_name}" \ "${iso_version}" \ "${iso_label}" \ "${install_dir}" \ "${arch}" \ - "${uuid_search_filename}" \ + "${search_filename}" \ "$(printf '%0.1s' "#"{1..1024})")" \ > "${work_dir}/grub/grubenv" } diff --git a/configs/baseline/grub/grub.cfg b/configs/baseline/grub/grub.cfg index e855ea9..13043b3 100644 --- a/configs/baseline/grub/grub.cfg +++ b/configs/baseline/grub/grub.cfg @@ -29,7 +29,7 @@ if [ -z "${ARCHISO_UUID}" ]; then if [ -z "${ARCHISO_HINT}" ]; then regexp --set=1:ARCHISO_HINT '^\(([^)]+)\)' "${cmdpath}" fi - search --no-floppy --set=root --file '/.disk/%UUID_SEARCH_FILENAME%.uuid' --hint "${ARCHISO_HINT}" + search --no-floppy --set=root --file '%ARCHISO_SEARCH_FILENAME%' --hint "${ARCHISO_HINT}" probe --set ARCHISO_UUID --fs-uuid "${root}" fi diff --git a/configs/releng/grub/grub.cfg b/configs/releng/grub/grub.cfg index 88a5d60..c4478e8 100644 --- a/configs/releng/grub/grub.cfg +++ b/configs/releng/grub/grub.cfg @@ -29,7 +29,7 @@ if [ -z "${ARCHISO_UUID}" ]; then if [ -z "${ARCHISO_HINT}" ]; then regexp --set=1:ARCHISO_HINT '^\(([^)]+)\)' "${cmdpath}" fi - search --no-floppy --set=root --file '/.disk/%UUID_SEARCH_FILENAME%.uuid' --hint "${ARCHISO_HINT}" + search --no-floppy --set=root --file '%ARCHISO_SEARCH_FILENAME%' --hint "${ARCHISO_HINT}" probe --set ARCHISO_UUID --fs-uuid "${root}" fi -- cgit v1.2.3-70-g09d2 From a0941539c01951031ac199413d7107d942200b23 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Thu, 26 Jan 2023 16:21:24 +0200 Subject: Move SYSLINUX directory from /syslinux/ to /boot/syslinux/ This allows to reduce the number of top-level directories by one and matches with the GRUB directory move. Most boot loader related things will now be in the /boot/ directory. Fixes #207 --- CHANGELOG.rst | 1 + archiso/mkarchiso | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7a83622..2b58b21 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -27,6 +27,7 @@ Changed - Move ``grubenv`` to ``/boot/grub/grubenv`` on ISO 9660 so that it is together with the rest of GRUB-specific files. Additionally write more variables in it. The previous ``/${install_dir}/grubenv`` (``/arch/grubenv`` for releng) is deprecated and a future archiso release will not create this file anymore. +- Moved syslinux directory from ``/syslinux/`` to ``/boot/syslinux/`` to keep most boot loader files in ``/boot/``. Removed ------- diff --git a/archiso/mkarchiso b/archiso/mkarchiso index a543280..e0806bd 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -443,30 +443,30 @@ _make_boot_on_iso9660() { # Prepare syslinux for booting from MBR (isohybrid) _make_bootmode_bios.syslinux.mbr() { _msg_info "Setting up SYSLINUX for BIOS booting from a disk..." - install -d -m 0755 -- "${isofs_dir}/syslinux" + install -d -m 0755 -- "${isofs_dir}/boot/syslinux" for _cfg in "${profile}/syslinux/"*.cfg; do sed "s|%ARCHISO_LABEL%|${iso_label}|g; s|%INSTALL_DIR%|${install_dir}|g; s|%ARCH%|${arch}|g" \ - "${_cfg}" > "${isofs_dir}/syslinux/${_cfg##*/}" + "${_cfg}" > "${isofs_dir}/boot/syslinux/${_cfg##*/}" done if [[ -e "${profile}/syslinux/splash.png" ]]; then - install -m 0644 -- "${profile}/syslinux/splash.png" "${isofs_dir}/syslinux/" + install -m 0644 -- "${profile}/syslinux/splash.png" "${isofs_dir}/boot/syslinux/" fi - install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/"*.c32 "${isofs_dir}/syslinux/" - install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/lpxelinux.0" "${isofs_dir}/syslinux/" - install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/memdisk" "${isofs_dir}/syslinux/" + install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/"*.c32 "${isofs_dir}/boot/syslinux/" + install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/lpxelinux.0" "${isofs_dir}/boot/syslinux/" + install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/memdisk" "${isofs_dir}/boot/syslinux/" _run_once _make_boot_on_iso9660 - if [[ -e "${isofs_dir}/syslinux/hdt.c32" ]]; then - install -d -m 0755 -- "${isofs_dir}/syslinux/hdt" + if [[ -e "${isofs_dir}/boot/syslinux/hdt.c32" ]]; then + install -d -m 0755 -- "${isofs_dir}/boot/syslinux/hdt" if [[ -e "${pacstrap_dir}/usr/share/hwdata/pci.ids" ]]; then gzip -cn9 "${pacstrap_dir}/usr/share/hwdata/pci.ids" > \ - "${isofs_dir}/syslinux/hdt/pciids.gz" + "${isofs_dir}/boot/syslinux/hdt/pciids.gz" fi find "${pacstrap_dir}/usr/lib/modules" -name 'modules.alias' -print -exec gzip -cn9 '{}' ';' -quit > \ - "${isofs_dir}/syslinux/hdt/modalias.gz" + "${isofs_dir}/boot/syslinux/hdt/modalias.gz" fi # Add other aditional/extra files to ${install_dir}/boot/ @@ -482,9 +482,9 @@ _make_bootmode_bios.syslinux.mbr() { # Prepare syslinux for El-Torito booting _make_bootmode_bios.syslinux.eltorito() { _msg_info "Setting up SYSLINUX for BIOS booting from an optical disc..." - install -d -m 0755 -- "${isofs_dir}/syslinux" - install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/isolinux.bin" "${isofs_dir}/syslinux/" - install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/isohdpfx.bin" "${isofs_dir}/syslinux/" + install -d -m 0755 -- "${isofs_dir}/boot/syslinux" + install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/isolinux.bin" "${isofs_dir}/boot/syslinux/" + install -m 0644 -- "${pacstrap_dir}/usr/lib/syslinux/bios/isohdpfx.bin" "${isofs_dir}/boot/syslinux/" # ISOLINUX and SYSLINUX installation is shared _run_once _make_bootmode_bios.syslinux.mbr @@ -1288,9 +1288,9 @@ _validate_requirements_buildmode_netboot() { _add_xorrisofs_options_bios.syslinux.eltorito() { xorrisofs_options+=( # El Torito boot image for x86 BIOS - '-eltorito-boot' 'syslinux/isolinux.bin' + '-eltorito-boot' 'boot/syslinux/isolinux.bin' # El Torito boot catalog file - '-eltorito-catalog' 'syslinux/boot.cat' + '-eltorito-catalog' 'boot/syslinux/boot.cat' # Required options to boot with ISOLINUX '-no-emul-boot' '-boot-load-size' '4' '-boot-info-table' ) @@ -1300,7 +1300,7 @@ _add_xorrisofs_options_bios.syslinux.eltorito() { _add_xorrisofs_options_bios.syslinux.mbr() { xorrisofs_options+=( # SYSLINUX MBR bootstrap code; does not work without "-eltorito-boot syslinux/isolinux.bin" - '-isohybrid-mbr' "${isofs_dir}/syslinux/isohdpfx.bin" + '-isohybrid-mbr' "${isofs_dir}/boot/syslinux/isohdpfx.bin" # When GPT is used, create an additional partition in the MBR (besides 0xEE) for sectors 0–1 (MBR # bootstrap code area) and mark it as bootable # May allow booting on some systems -- cgit v1.2.3-70-g09d2