Debian

Grub 安裝失敗

  • October 4, 2019

我有一個執行良好的 Debian Jessie 安裝,但後來我執行了apt-get update && apt-get upgrade && apt-get dist-upgrade.

然後重新啟動後,它直接進入BIOS。我意識到 Grub 不見了,所以我執行了一個 live cd 並進入Rescue mode,掛載了我的根分區,+ 引導分區並執行了這些命令:

Grub 找到linux 映像:

root@debian:~# update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-4.9.0-3-amd64
Found initrd image: /boot/initrd.img-4.9.0-3-amd64
Found linux image: /boot/vmlinuz-4.9.0-0.bpo.3-amd64
Found initrd image: /boot/initrd.img-4.9.0-0.bpo.3-amd64
Found linux image: /boot/vmlinuz-3.16.0-4-amd64
Found initrd image: /boot/initrd.img-3.16.0-4-amd64
Found Ubuntu 16.10 (16.10) on /dev/sdb2
Adding boot menu entry for EFI firmware configuration
done

然後grub-install

root@debian:~# grub-install /dev/sda
Installing for x86_64-efi platform.
Could not prepare Boot variable: No such file or directory
grub-install: error: efibootmgr failed to register the boot entry: Input/output error.

lsblk:

root@debian:~# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0  92.6G  0 part /
├─sda2   8:2    0 130.4G  0 part 
└─sda3   8:3    0   573M  0 part /boot/efi

我做錯什麼了嗎?/boot/efi我的分區上的空間太少了嗎?

root@debian:~# ls -l /boot/efi/EFI/debian/
total 120
-rwx------ 1 root root 121856 Jul 20 20:29 grubx64.efi

efibootmgr不顯示 Debian 安裝:

root@debian:~# efibootmgr --verbose | grep debian

編輯 :

每次嘗試使用以下命令創建引導載入程序時,我都會收到此錯誤efibootmgr

grub-install: info: executing efibootmgr -c -d /dev/sda -p 3 -w -L grub -l \EFI\grub\grubx64.efi.
Could not prepare Boot variable: No such file or directory
grub-install: error: efibootmgr failed to register the boot entry: Input/output error.

通過安裝引導變數來修復 efibootmgr 錯誤efibootmgr

# mount -t efivarfs efivarfs /sys/firmware/efi/efivars

然後efibootmgr給了我關於空間的錯誤:

Could not prepare Boot variable: No space left on device

通過刪除轉儲文件解決了這個問題:

# rm /sys/firmware/efi/efivars/dump-*

然後照常跑

update-grub 
grub-install -v --target=x86_64-efi --recheck /dev/sda

它執行成功!

如果您的磁碟不是 /dev/sda,請嘗試指定包含載入程序的磁碟:

efibootmgr --create --disk /dev/nvme0n1 --part 1 --label Ubuntu

引用自:https://unix.stackexchange.com/questions/379774