[prev in list] [next in list] [prev in thread] [next in thread] 

List:       grub-help
Subject:    Re: Is there a way to get the architecture of the machine just booted up by GRUB2: [32|64]-[amd|arm]
From:       Pascal Hambourg <pascal () plouf ! fr ! eu ! org>
Date:       2023-12-18 20:15:37
Message-ID: 9a7aca36-f903-4c47-a942-30ed2e51b519 () plouf ! fr ! eu ! org
[Download RAW message or body]

On 18/12/2023 at 08:55, Andrei Borzenkov wrote:
>
> You can also probably load a 32 bit kernel from a 64 bit grub.

Why would you would want to do this ? A 32-bit kernel cannot read or 
write 64-bit EFI variables.

> We are back to the same question - what are criteria for
> choosing the "right" kernel that grub needs to implement?
(...)
>>> Besides, distributions may require additional CPU features beyond mere
>>> "supports 64 bit".
>>
>> Do you mean 32-bit CPU features such as PAE ?
> 
> https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels

Debian provides only a single kernel flavour for the amd64 architecture, 
and two flavours for i386: 686 (without PAE) and 686-pae. So this script 
should do the trick:

if [ $grub_cpu = x86_64 ]; then
	set arch=amd64
elif [ $grub_cpu = i386 ]; then
	if cpuid -l ; then
		set arch=amd64
	elif cpuid -p ; then
		set arch=686-pae
	else
		set arch=686
	fi
elif [ $grub_cpu = arm64 ]; then
	set arch=arm64
elif [ $grub_cpu = riscv64 ]; then
	set arch=riscv64
fi

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic