Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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.