Wednesday 27 August 2014

Detect a 64-bit or 32-bit CPU in Easy2Boot

We can use grub4dos to detect the CPU bitness using the is64bit command.
E2B v1.56 Main  menu heading shows CPU type and total usable system memory

We can use this to make a .mnu file for the MAINMENU folder:



$$$CPU_TYPE.mnu
===============
# Display as menu item if CPU is 32-bit or 64-bit

iftitle [checkrange 2,3 is64bit]   --- INFORMATION: 64-bit CPU ---
errorcheck off


iftitle [checkrange 0,1 is64bit]   --- INFORMATION: 32-bit CPU ---
errorcheck off


To make a menu entry that will allow the user to check it use:

title Check the Processor\n Detect if CPU is 32-bit or 64-bit
checkrange 2,3 is64bit && pause Processor is 64-bit
checkrange 0,1 is64bit && pause Processor is 32-bit
errorcheck off
boot

The 64Bit_Auto_Detect_ISO.mnu file in the E2B Sample mnu folder has an example where either a 32-bit or 64-bit ISO will be automatically run depending on the system CPU:

# Change the 1st, 2nd and 3rd line as required - line 4 may be deleted if no pause required

title Run a 32-bit or 64-bit linux ISO \n Auto-Detect system type and run correct ISO
set ISO=Ubuntu32.iso
checkrange 2,3 is64bit && set ISO=Ubuntu64.iso
pause WILL BOOT %ISO% - Press ENTER key to continue...
/%grub%/qrun.g4b $HOME$/%ISO%
boot

To make a .mnu file for a 64-bit ISO that will only be visible if the system has a 64-bit CPU, we can use:

iftitle [if exist $HOME$/Ubuntu64.iso && checkrange 2,3 is64bit] Ubuntu 64-bit \n Boot from a 64-bit ISO
/%grub%/qrun.g4b $HOME$/Ubuntu64.iso
boot

No comments:

Post a Comment