Skip to content

In MBR mode on 64-bit system, $grub_cpu is i386 not x84_64 #3

Description

@steve6375

grub_cpu returns "i386" on a 64-bit system, I suggest setting up some variables for the user to use in his .cfg or .inc files to make it easier, e.g.

# DEFINE VARIABLES FOR MBR\EFI and 32/64-bit
set BIT64=false; set BIT32=false; set MBR=false; set EFI=false; set EFI64=false; set EFI32=false; set MBR32=false; set MBR64=false
if cpuid -l; then set BIT64=true; else set BIT32=true; fi
if [ "${grub_platform}" == "pc" ]; then set MBR=true; fi
if [ "${grub_platform}" == "efi" ]; then set EFI=true; fi
if [ "${grub_cpu}" == "x86_64" and $EFI = true ]; then set EFI64=true; fi
if [ "${grub_cpu}" == "i386" and $EFI = true ]; then set EFI32=true; fi
if [ $BIT64 = true and $MBR = true ]; then set MBR64=true; fi
if [ $BIT32 = true and $MBR = true ]; then set MBR32=true; fi
export MBR EFI MBR32 MBR64 EFI32 EFI64 BIT32 BIT64
#Examples
#if [ $BIT64 = true and $MBR = true ] ; then echo 64-bit MBR ; fi
#if [ $BIT64 = true and $EFI = true ] ; then echo 64-bit EFI ; fi
#if $BIT64 ; then echo 64-bit ; fi
#if $BIT32 ; then echo 32-bit ; fi

ISO files can be placed in a sub-folder and then .inc menus can be added such as

	if [ -f "/usb-modboot/ISO/ubuntu-18.04-desktop-amd64.iso" -a $BIT64 ]; then
			menuentry "Ubuntu amd64" "ubuntu.iso" {
				set iso_path="/usb-modboot/ISO/ubuntu-18.04-desktop-amd64.iso"
				export iso_path
				loopback loopdev_cfg "${iso_path}"
				set orig_root="$root"
				set root=(loopdev_cfg)
				configfile /boot/grub/loopback.cfg
				loopback -d loopdev_cfg
				set root="$orig_root"
				terminal_output $terminal
			}
	fi



Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions