Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.