help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to get the architecture of the machine just booted up


From: Pascal Hambourg
Subject: Re: Is there a way to get the architecture of the machine just booted up by GRUB2: [32|64]-[amd|arm]? ...
Date: Sun, 17 Dec 2023 21:50:42 +0100
User-agent: Mozilla Thunderbird

On 17/12/2023 at 17:24, Albretch Mueller wrote:

On 12/17/23, Pascal Hambourg wrote:

Let's assume you you create such an ISO image for UEFI boot only. It
must contain an EFI partition with EFI images for each firmware
architecture : bootarm64.efi (built for ARM64), bootx64.efi (built for
AMD64/x86_64) and bootriscv64.efi (built for RISC-V64). The UEFI
firmware will seek the matching EFI image, and the GRUB image will
report the architecture in $grub_cpu and $grub_platform.

Note: bootxxx.efi may be a GRUB image or a shim image which loads
grubxxx.efi in turn (for secure boot).

Note 2: there have been a few lightweight PC with 32-bit UEFI firmware and 64-bit x86 CPU around. To boot on these you need to install an x86 32-bit EFI image as bootia32.efi. It can boot i386 and amd64 kernels.

All that DVD would need is an EFI
partition with the EFI images for each firmware architecture.

Correct.

yes, "secure boot" would be the way to go.
(...)
Any tutorials, literature you would suggest for advanced
users and developers?
Most of what you need is in the GRUB documentation you already have.
If you use signed shim+GRUB provided by Debian for secure boot, install them in /EFI/BOOT in the EFI partition, and install a grub.cfg config file in /EFI/debian in the same partition, which checks $grub-cpu to select the kernel image, for example :

if [ $grub_cpu = x86_64 ]; then
        # instructions to boot with amd64 kernel
elif [ $grub_cpu = i386 ]; then
        # instructions to boot with i386 kernel
elif [ $grub_cpu = arm64 ]; then
        # instructions to boot with arm64 kernel
elif [ $grub_cpu = riscv64 ]; then
        # instructions to boot with riscv64 kernel
fi

If you do not care about secure boot and build your own EFI images with grub-mkimage, you can set the prefix to a different path and install a different grub.cfg there for each architecture.

If you want to support legacy BIOS boot or ia32/i386 EFI boot, I do not know how GRUB can detect whether the CPU is 32 or 64 bits capable.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]