![“efibootmgr:无法设置变量 Boot0000:没有此文件或目录”和“efibootmgr:无法准备启动变量:没有此文件或目录”](https://linux22.com/image/1159420/%E2%80%9Cefibootmgr%EF%BC%9A%E6%97%A0%E6%B3%95%E8%AE%BE%E7%BD%AE%E5%8F%98%E9%87%8F%20Boot0000%EF%BC%9A%E6%B2%A1%E6%9C%89%E6%AD%A4%E6%96%87%E4%BB%B6%E6%88%96%E7%9B%AE%E5%BD%95%E2%80%9D%E5%92%8C%E2%80%9Cefibootmgr%EF%BC%9A%E6%97%A0%E6%B3%95%E5%87%86%E5%A4%87%E5%90%AF%E5%8A%A8%E5%8F%98%E9%87%8F%EF%BC%9A%E6%B2%A1%E6%9C%89%E6%AD%A4%E6%96%87%E4%BB%B6%E6%88%96%E7%9B%AE%E5%BD%95%E2%80%9D.png)
为 x86_64-efi 平台安装 grub-efi-amd64-signed 偶尔(约 20 次测试中的 1 次)无法创建 Boot0000 记录,并出现以下错误“efibootmgr:无法设置变量 Boot0000:没有此文件或目录”和“efibootmgr:无法准备启动变量:没有此文件或目录”
我甚至尝试在运行前删除所有启动记录,grub-install -v /dev/sda
但没有成功。
我希望使用 grub 而不是建议的读数来使用 rEFInd 来实现这种可靠性。
以下序列是我的调试信息:
+ 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
我编写了一个 bash 脚本来 100% 重现这个问题:
#!/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
以下是我的解决方法:
# ensure fallback UEFI NVRAM boot record variable exists
efibootmgr -c -d /dev/sda -p 1 -w -L fallback -l '\EFI\ubuntu\grubx64.efi'
创建第二个冗余引导记录是解决我的不可靠硬件问题的完美方法。这样 grub-install 就可以继续删除、编辑和使用 Boot0000/ubuntu 记录。如果 Boot0000/ubuntu 记录丢失,则 BIOS 将自动选择 Boot0001/fallback 未触及的记录并启动操作系统。
/var/log/kern.log -> 内核:[179.804812] efivars:set_variable() 失败:状态=8000000000000009
这与 efi_no_storage_paranoia=1 内核参数结合,为我提供了所需的硬件可靠性。
答案1
我的 ACER SWITCH3 SW312-31 也遇到了类似的问题。我联系了 ACER 支持,得到的答复是,更新 EFI(固件)的唯一方法是使用已安装的 windows10。我找不到使用已安装的 EFI 更新固件的任何方法。幸运的是,现在我可以启动并定期登录我的(root)帐户。我不确定我是怎么做到的。在我不能这样做之前,我将 ubuntu 19.04 更新到 19.10,并在 EFI 上上传了新的 GRUB / EFI 文件。然后它再次发生,我无法登录。这似乎是图形驱动程序无法正常工作。最新的操作是禁用 EFI 安全检查,然后我就可以登录了。我会检查所有日志记录。