Recovery

GRUB Tips

Boot from GRUB rescue

If bootloader file is damaged, it’s still possible to boot computer with GRUB rescue image.

This section is also applicable if you are in grub rescue>.

  1. On another computer, generate rescue image with:

    pacman -S --needed mtools libisoburn grub
    grub-install
    grub-mkrescue -o grub-rescue.img
    dd if=grub-rescue.img of=/dev/your-usb-stick
    

    Boot computer from the rescue media. Both legacy and EFI mode are supported.

    Or download generated GRUB rescue image.

  2. List available disks with ls command:

    grub> ls (hd # press tab
    Possible devices are:
    
     hd0 hd1 hd2 hd3
    
  3. List partitions by pressing tab key:

    grub> ls (hd0 # press tab
    Possible partitions are:
    
    Device hd0: No known filesystem detected - Sector size 512B - Total size  20971520KiB
    Partition hd0,gpt1: Filesystem type fat - Label `EFI', UUID 0DF5-3A76 - Partition start at 1024KiB - Total size 1048576KiB
    Partition hd0,gpt2: No known filesystem detected - Partition start at 1049600KiB - Total size 4194304KiB
    
    • If boot pool is encrypted:

      Unlock it with cryptomount:

      grub> insmod luks
      grub> cryptomount hd0,gpt2
      Attempting to decrypt master key...
      Enter passphrase for hd0,gpt2 (af5a240e13e24483acf02600d61e0f36):
      Slot 1 opened
      

      Unlocked LUKS container is (crypto0):

      grub> ls (crypto0)
      Device crypto0: Filesystem type zfs - Label `bpool_ip3tdb' - Last modification
      time 2021-05-03 12:14:08 Monday, UUID f14d7bdf89fe21fb - Sector size 512B -
      Total size 4192256KiB
      
    • If boot pool is not encrypted:

      grub> ls (hd0,gpt2)
      Device hd0,gpt2: Filesystem type zfs - Label `bpool_ip3tdb' - Last modification
      time 2021-05-03 12:14:08 Monday, UUID f14d7bdf89fe21fb - Sector size 512B -
      Total size 4192256KiB
      
  4. List boot environments nested inside bpool/$INST_ID/BOOT:

    grub> ls (crypto0)/sys/BOOT
    @/ default/ be0/
    
  5. Instruct GRUB to load configuration from be0 boot environment:

    grub> prefix=(crypto0)/sys/BOOT/be0/@/grub
    grub> configfile $prefix/grub.cfg
    
  6. GRUB menu should now appear.

  7. After entering system, reinstall GRUB.

Switch GRUB prefix when disk fails

If you are using LUKS encrypted boot pool with multiple disks, the primary disk failed, GRUB will fail to load configuration.

If there’s still enough redundancy for the boot pool, try fix GRUB with the following method:

  1. Ensure Slot 1 opened message is shown

    Welcome to GRUB!
    
    error: no such cryptodisk found.
    Attempting to decrypt master key...
    Enter passphrase for hd0,gpt2 (c0987ea1a51049e9b3056622804de62a):
    Slot 1 opened
    error: disk `cryptouuid/47ed1b7eb0014bc9a70aede3d8714faf' not found.
    Entering rescue mode...
    grub rescue>
    

    If error: access denied. is shown, try re-enter password with:

    grub rescue> cryptomount hd0,gpt2
    
  2. Check prefix:

    grub rescue > set
    # prefix=(cryptouuid/47ed1b7eb0014bc9a70aede3d8714faf)/sys/BOOT/be0@/grub
    # root=cryptouuid/47ed1b7eb0014bc9a70aede3d8714faf
    
  3. Set correct prefix and root by replacing cryptouuid/UUID with crypto0:

    grub rescue> prefix=(crypto0)/sys/BOOT/default@/grub
    grub rescue> root=crypto0
    
  4. Boot GRUB:

    grub rescue> insmod normal
    grub rescue> normal
    

    GRUB should then boot normally.

  5. After entering system, edit /etc/fstab to promote one backup to /boot/efi.

  6. Make the change to prefix and root permanent by reinstalling GRUB.