7

I have a bootable usb flash drive with grub2 handling booting of ISOs (mostly different spins of Ubuntu). I am editing the menu.cfg myself and have my own script to update grub because I don't want to waste time using external tools.

I would like to hide 64-bit ISOs on a 32-bit system, so that I can't make the mistake of trying to boot an incompatible ISO.

Is it possible for grub2 to detect whether the processor is x64 or i386 and display a different menu (or preferably enable/disable some menu options) accordingly?

Edit: I'm aware of the grub2 CLI command cpuid -l, to check for long mode, but I'm not sure if or how that can be used in menu.cfg.

1 Answer 1

4

Remove only the menu entries (leaving all the config stuff at the top) and put them into two different files, one for 64-bit and one for 32-bit. Then, add code like below into the main menu.cfg to load the appropriate menu file for the system.

if cpuid -l; then
    configfile /boot/grub/grub-amd64.cfg
else
    configfile /boot/grub/grub-i386.cfg
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .