grub2

GRUB2 menu in early config


I'm trying to create a menu in the early config file of GRUB 2.04 in file early.cfg:

menuentry foo {
  echo foo1
}
menuentry bar {
  echo bar1
}

I'm building core.img with:

$ grub-mkimage -v -v -v -C xz -O i386-pc -p /prefix -o core.img -c early.cfg biosdisk part_msdos part_gpt luks linux16 gcry_rijndael gcry_sha512 gcry_sha256 lvm chain cpio gzio xzio search echo fat ext2 reiserfs btrfs zfs xfs ntfs ntfscomp

At boot time no filesystems are available (yet) to load grub.cfg from. When I boot, I get the grub> prompt.

How do I get to the menu? I tried typing normal + Enter, Esc, Esc, but it doesn't show me the menu, it just puts me back to the grub> prompt with the screen cleared.

Ultimately I'd like to activate the menu defined in the early config by default. How do I do that?


Solution

  • According to the GRUB2 manual, it's impossible to have menu entries in early.cfg:

    The embedded configuration file may not contain menu entries directly, but may only read them from elsewhere using configfile.