grub-efi-amd64-signed installing for x86_64-efi platform occasionally (~1 out of 20 tests) fails to create the Boot0000 record with the following errors "efibootmgr: Could not set variable Boot0000: No such file or directory" and "efibootmgr: Could not prepare boot variable: No such file or directory"
I have even attempted to delete all boot records before running grub-install -v /dev/sda
without success.
I want to get this reliability working using grub over suggested readings to use rEFInd.
The rEFInd Boot Manager: Keeping rEFInd Booting
The following sequence is my debug information:
+ efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
Boot0002* Hard Drive BBS(HD,,0x0)AMGOAMNO........m.K.I.N.G.S.T.O.N. .S.M.S.2.0.0.S.3.6.0.G....................A.........................>..Gd-.;.A..MQ..L.0.5.2.0.B.6.2.7.1.6.3.0.5.B.B.D. . . . ......AMBOAMNO........{.K.i.n.g.s.t.o.n.D.a.t.a.T.r.a.v.e.l.e.r. .3...0.P.M.A.P....................A.......................N..Gd-.;.A..MQ..L.K.i.n.g.s.t.o.n.D.a.t.a.T.r.a.v.e.l.e.r. .3...0.P.M.A.P......AMBO
Boot0003* UEFI: KingstonDataTraveler 3.0PMAP PciRoot(0x0)/Pci(0x1d,0x7)/USB(2,0)/HD(1,MBR,0x4294967189,0x800,0x1cdf000)AMBO
+ update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
Found memtest86+ image: /boot/memtest86+.bin
done
++ seq 0 9
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0000 -B
efibootmgr: Could not delete Boot0000: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0001 -B
efibootmgr: Could not delete Boot0001: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0002 -B
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
Boot0003* UEFI: KingstonDataTraveler 3.0PMAP
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0003 -B
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0004 -B
efibootmgr: Could not delete Boot0004: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0005 -B
efibootmgr: Could not delete Boot0005: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0006 -B
efibootmgr: Could not delete Boot0006: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0007 -B
efibootmgr: Could not delete Boot0007: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0008 -B
efibootmgr: Could not delete Boot0008: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ for i in '$(seq 0 9)'
+ efibootmgr -b 0009 -B
efibootmgr: Could not delete Boot0009: No such file or directory
efibootmgr: Could not delete boot variable: No such file or directory
+ efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
+ grub-install -v /dev/sda
grub-install: info: executing modprobe efivars 2>/dev/null.
grub-install: info: Looking for /sys/firmware/efi ...
grub-install: info: ...found.
Installing for x86_64-efi platform.
grub-install: info: cannot open `/boot/grub/device.map': No such file or directory.
grub-install: info: /dev/sda1 is not present.
grub-install: info: Looking for /dev/sda1.
grub-install: info: /dev/sda is a parent of /dev/sda1.
grub-install: info: /dev/sda1 starts from 34.
grub-install: info: opening the device hostdisk//dev/sda.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Partition 0 starts from 34.
grub-install: info: /dev/sda1 is present.
grub-install: info: Looking for /dev/sda1.
grub-install: info: /dev/sda is a parent of /dev/sda1.
grub-install: info: /dev/sda1 starts from 34.
grub-install: info: opening the device hostdisk//dev/sda.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Partition 0 starts from 34.
grub-install: info: /dev/sda1 is present.
grub-install: info: Looking for /dev/sda1.
grub-install: info: /dev/sda is a parent of /dev/sda1.
grub-install: info: /dev/sda1 starts from 34.
grub-install: info: opening the device hostdisk//dev/sda.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Scanning for DISKFILTER devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid1x devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09_be devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/sda.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/sda.
grub-install: info: scanning hostdisk//dev/sda for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/sda.
grub-install: info: no LVM signature found.
grub-install: info: Partition 0 starts from 34.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/sda is 117231408.
...grub-install info continued...
grub-install: info: adding 170 padding fixup entries.
grub-install: info: writing 960 bytes of a fixup block starting at 0xc000.
grub-install: info: reading /usr/lib/grub/x86_64-efi/fshelp.mod.
grub-install: info: reading /usr/lib/grub/x86_64-efi/ext2.mod.
grub-install: info: reading /usr/lib/grub/x86_64-efi/part_gpt.mod.
grub-install: info: reading /usr/lib/grub/x86_64-efi/search_fs_uuid.mod.
grub-install: info: reading /boot/grub/x86_64-efi/load.cfg.
grub-install: info: kernel_img=0xd7cc90, kernel_size=0x18a00.
grub-install: info: the core size is 0x1dbd8.
grub-install: info: writing 0x1ee00 bytes.
grub-install: info: copying `/usr/lib/shim/shimx64.efi.signed' -> `/boot/efi/EFI/ubuntu/shimx64.efi'.
grub-install: info: copying `/usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed' -> `/boot/efi/EFI/ubuntu/grubx64.efi'.
grub-install: info: copying `/usr/lib/shim/mmx64.efi' -> `/boot/efi/EFI/ubuntu/mmx64.efi'.
grub-install: info: copying `/boot/grub/x86_64-efi/load.cfg' -> `/boot/efi/EFI/ubuntu/grub.cfg'.
grub-install: info: Registering with EFI: distributor = `ubuntu', path = `\EFI\ubuntu\shimx64.efi', ESP at hostdisk//dev/sda,gpt1.
grub-install: info: executing efibootmgr --version </dev/null >/dev/null.
grub-install: info: executing modprobe -q efivars.
grub-install: info: executing efibootmgr -c -d /dev/sda -p 1 -w -L ubuntu -l \EFI\ubuntu\shimx64.efi.
efibootmgr: Could not set variable Boot0000: No such file or directory
efibootmgr: Could not prepare boot variable: No such file or directory
Installation finished. No error reported.
+ update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
Found memtest86+ image: /boot/memtest86+.bin
done
+ efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
I have written a bash script to 100% reproduce this problem:
#!/bin/bash
# UEFI NVRAM Variable Reproducibility Unit Test
set -x
while true
do
efibootmgr -v
for i in $(seq 0 9)
do
efibootmgr -b 000$i -B
done
efibootmgr -v
grub-install
if [ $(efibootmgr -v | grep -c ubuntu) -eq 0 ]
then
echo "BUG!!! OS will now fail to boot!!!"
exit 0
fi
done
The following is my workaround solution:
# ensure fallback UEFI NVRAM boot record variable exists
efibootmgr -c -d /dev/sda -p 1 -w -L fallback -l '\EFI\ubuntu\grubx64.efi'
Creating a second redundant boot record is a perfect workaround for my unreliable hardware problem. This way grub-install can continue to delete, edit and use the Boot0000/ubuntu record. If the Boot0000/ubuntu record is ever lost then the Boot0001/fallback untouched record will be automatically selected by the BIOS and boot the OS.
/var/log/kern.log -> kernel: [ 179.804812] efivars: set_variable() failed: status=8000000000000009
This in combination with the efi_no_storage_paranoia=1 kernel parameter gives me the hardware reliability I need.