GRUB

Jump to: navigation, search
GRUB

GRUB2-logo.png

GNU GRUB (GRand Unified Bootloader) is a multiboot boot loader

Download for openSUSE

Vendor: Free Software Foundation, Inc.
Developer: Free Software Foundation, Inc.
License: GNU General Public License
Web: http://www.gnu.org/software/grub/

GRUB is a boot loader. That means it will load an operating system that is installed on the computer.
Icon-warning.png
Warning: Starting from December 2023, Tumbleweed and MicroOS use systemd-boot instead of Grub.

GRUB2 and GRUB Legacy

GRUB2 is now the default boot loader in openSUSE, replacing GRUB Legacy (GRUB versions 0.9x). GRUB2 has more advanced features than GRUB Legacy. GRUB Legacy is still available, but is no longer being actively developed.

More information about GRUB2 can be found here.

GRUB2

GRUB2 on btrfs /boot

Because GRUB2 cannot write btrfs, see [1], there are problems writing /boot/grub2/grubenv from within GRUB2 itself which is e.g. necessary when using GRUB_SAVEDEFAULT in /etc/default/grub.

As a solution, openSUSE patched GRUB2 to allow storing the volatile grubenv data in a reserved block of the btrfs /boot partition. It stores the location and size of that block in the "original" /boot/grub2/grubenv as "env_block=512+1" where 512 means the offset inside the partition and "1" means the size. Both values are in units of file-system sectors which are typically 512 bytes in size. So, to inspect the data stored there, you can use

  dd if=/dev/yourbootpartition bs=512 skip=512 count=1

The proper way to read and adjust those values is however via the grub2-editenv command.

Recovering from broken grubenv

In case, GRUB2 complains about

  Error: invalid environment block. Press any key to continue...

the following steps allow to recreate it:

  rm /boot/grub2/grubenv
  grub2-editenv - unset dummy

The "unset" step is necessary to actually set up the storage in the reserved btrfs sector and store the location in /boot/grub2/grubenv which should then contain:

  # GRUB Environment Block
  # WARNING: Do not edit this file by tools other than grub2-editenv!!!
  env_block=512+1
  #################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

If you omitted this step, the "env_block" value would still be missing and GRUB2 would still not be able to store variables.

Support guides

External links