我的 grub 引导程序似乎已严重损坏,我该如何修复它?

我的 grub 引导程序似乎已严重损坏,我该如何修复它?

机器目前正在运行,我尚未尝试重新启动。

运行后sudo apt upgrade,我在输出中看到:

Setting up grub-efi-amd64-bin (2.04-1ubuntu44) ...
Setting up grub2-common (2.02-2ubuntu8.23) ...
Setting up ubuntu-release-upgrader-core (1:18.04.44) ...
Setting up grub-efi-amd64 (2.04-1ubuntu44) ...
Installing for x86_64-efi platform.
EFI variables are not supported on this system.
EFI variables are not supported on this system.
grub-install: error: efibootmgr failed to register the boot entry: No such file or directory.
Failed: grub-install --target=x86_64-efi  
WARNING: Bootloader is not properly installed, system may not be bootable
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-142-generic
Found initrd image: /boot/initrd.img-4.15.0-142-generic
Found linux image: /boot/vmlinuz-4.15.0-141-generic
Found initrd image: /boot/initrd.img-4.15.0-141-generic
Found linux image: /boot/vmlinuz-4.15.0-136-generic
Found initrd image: /boot/initrd.img-4.15.0-136-generic
done
Setting up grub-efi-amd64-signed (1.167~18.04.1+2.04-1ubuntu44) ...
Installing for x86_64-efi platform.
EFI variables are not supported on this system.
Installation finished. No error reported.

这表明存在问题。我运行grub-emu,并看到以下输出:

error: sparse file not allowed.
error: no such device: 21b294f1-25bd-4265-9c4e-d6e4aeb57e97.
error: can't find command `linux'.
error: can't find command `initrd'.

无论我在 中选择什么选项grub-emu,我都会得到相同的结果。

如果我运行file -s /dev/sda,我会看到:

/dev/sda: Linux rev 1.0 ext4 filesystem data, UUID=6e1fd477-4aec-4323-83b8-55c419ce471f (needs journal recovery) (extents) (64bit) (large files) (huge files)

我需要做什么来修复这台服务器?


编辑:

$ cat /etc/fstab
LABEL=cloudimg-rootfs   /    ext4   defaults    0 0
LABEL=UEFI  /boot/efi   vfat    defaults    0 0

我意识到我错了,/dev/sda不是我的启动驱动器,/dev/vda是(这是一个 digitalocean vm):

$ file -s /dev/vda
/dev/vda: DOS/MBR boot sector, extended partition table (last)
$ lsblk -o +PARTUUID /dev/vda
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT PARTUUID
vda     252:0    0   50G  0 disk            
├─vda1  252:1    0 49.9G  0 part /          bcf3ccb8-bce6-4498-93fb-1b9bd59fc81c
├─vda14 252:14   0    4M  0 part            2081abbc-a4ba-496a-b391-07952095f65d
└─vda15 252:15   0  106M  0 part /boot/efi  ee783a1a-c5d0-42d9-b874-71796971f49b
$ bootctl --path /boot/efi status
File system "/boot/efi" has wrong type for an EFI System Partition (ESP).
System:
    Not booted with EFI

Boot Loader Binaries:
          ESP: /boot/efi
systemd-boot not installed in ESP.
         File: └─/EFI/BOOT/BOOTX64.EFI

Default Boot Entry:
Failed to open "/boot/efi/loader/loader.conf": No such file or directory
Failed to read boot config from "/boot/efi/loader/loader.conf": No such file or directory
Failed to load bootspec config from "/boot/efi/loader": No such file or directory
$ sudo tree -p /boot/efi
/boot/efi
├── [drwxr-xr-x]  EFI
│   ├── [drwxr-xr-x]  BOOT
│   │   ├── [-rwxr-xr-x]  BOOTX64.CSV
│   │   ├── [-rwxr-xr-x]  BOOTX64.EFI
│   │   ├── [-rwxr-xr-x]  fbx64.efi
│   │   ├── [-rwxr-xr-x]  grub.cfg
│   │   ├── [-rwxr-xr-x]  grubx64.efi
│   │   └── [-rwxr-xr-x]  mmx64.efi
│   └── [drwxr-xr-x]  ubuntu
│       ├── [-rwxr-xr-x]  BOOTX64.CSV
│       ├── [-rwxr-xr-x]  grub.cfg
│       ├── [-rwxr-xr-x]  grubx64.efi
│       ├── [-rwxr-xr-x]  mmx64.efi
│       └── [-rwxr-xr-x]  shimx64.efi
└── [drwxr-xr-x]  boot
    └── [drwxr-xr-x]  grub
        └── [-rwxr-xr-x]  grub.cfg

答案1

日志恢复通常在挂载文件系统时自动执行。如果你想手动执行,你可以确保文件系统不是然后安装跑步e2fsck

相关内容