Unable to set a GRUB password on a Raspberry Pi 3 system

The Problem

grub-rpi3.efi is built on RPI3 image build stage, and it is missing a crucial module for password prompt:

# efibootmgr -v -v 
Could not read variable 'BootNext': No such file or directory 
error trace: 
 vars.c:332 vars_get_variable(): open(/sys/firmware/efi/vars/BootNext-8be4df61-93ca-11d2-aa0d-00e098032b8c/raw_var, O_RDONLY) failed: No such file or directory 
 lib.c:139 efi_get_variable(): ops->get_variable failed: No such file or directory 
Could not read variable 'BootCurrent': No such file or directory 
error trace: 
 vars.c:332 vars_get_variable(): 
open(/sys/firmware/efi/vars/BootCurrent-8be4df61-93ca-11d2-aa0d-00e098032b8c/raw_var, O_RDONLY) failed: No such file or directory 
 lib.c:139 efi_get_variable(): ops->get_variable failed: No such file or directory 
Could not read variable 'Timeout': No such file or directory 
error trace: 
 vars.c:332 vars_get_variable(): 
open(/sys/firmware/efi/vars/Timeout-8be4df61-93ca-11d2-aa0d-00e098032b8c/raw_var, O_RDONLY) failed: No such file or directory lib.c:139 efi_get_variable(): ops->get_variable failed: No such file or directory 
Could not read variable 'BootOrder': No such file or directory 
error trace: 
 vars.c:332 vars_get_variable(): 
open(/sys/firmware/efi/vars/BootOrder-8be4df61-93ca-11d2-aa0d-00e098032b8c/raw_var, O_RDONLY) failed: No such file or directory lib.c:139 efi_get_variable(): ops->get_variable failed: No such file or directory 
 efibootmgr.c:372 read_order(): efi_get_variable failed: No such file or directory 
No BootOrder is set; firmware will attempt recovery 
Could not read variable 'MirrorCurrent': No such file or directory 
error trace: 
 vars.c:332 vars_get_variable(): 
open(/sys/firmware/efi/vars/MirrorCurrent-7b9be2e0-e28a-4197-ad3e-32f062f9462c/raw_var, O_RDONLY) failed: No such file or directory 
 lib.c:139 efi_get_variable(): ops->get_variable failed: No such file or directory 
Could not read variable 'MirrorRequest': No such file or directory 
error trace: 
 vars.c:332 vars_get_variable(): 
open(/sys/firmware/efi/vars/MirrorRequest-7b9be2e0-e28a-4197-ad3e-32f062f9462c/raw_var, O_RDONLY) failed: No such file or directory 
 lib.c:139 efi_get_variable(): ops->get_variable failed: No such file or directory

The Solution

Follow the steps outlined below to fix the issue:

1. Verify that file is in place:

# file grub-rpi3.efi

2. Install package grub2-efi-aa64-modules.

3. Set the default boot device:

# echo "set root=(hd0,msdos2)" > grub2-early.cfg

4. Review grub-early.cfg to verify there is exactly one “set root” string.

5. Build the image:

# grub2-mkimage -c grub-early.cfg -O arm64-efi -o grub-rpi3.efi -p "(hd0,msdos1)/efi/redhat" all_video boot btrfs cat chain echo efifwsetup efinet ext2 fat font gfxmenu gfxterm gzio halt hfsplus iso9660 jpeg loadenv loopback lvm mdraid09 mdraid1x minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs http linux configfile

6. Verify the new file in the local directory:

# file grub-rpi3.efi

7. Add a copy of the file to /boot/efi/EFI/redhat/ directory.

# cp grub-rpi3.efi /boot/efi/EFI/redhat/

This should also produce a warning about replacing an existing file.

8. Flush the I/O buffers out to media:

# sync; sync; sync

9. Gracefully reboot.

Related Post