Grub 总是显示命令行,无法修复

Grub 总是显示命令行,无法修复

使用恢复以前的快照后timeshift,grub 现在启动到命令行。如果我输入以下命令,我可以返回 Ubuntu (KDE neon):

> set prefix=(hd0,gpt1)/efi/grub (or "set prefix=(hd0,gpt1)/efi/neon" both works)
> set root=(hd0,gpt4)/
> insmod normal
> normal

不幸的是,我每次都应该输入这些命令,但我不知道如何修复它。我尝试过运行:

sudo update-grub
sudo grub-install /dev/nvme0n1

我也尝试过跑步Boot-repair但没有运气。如果我在 BIOS 上将启动顺序更改为 Windows,则可以毫无问题地启动它。

下面是输出boot-info命令:

boot-info-4ppa203                                              [20230304_1957]

============================== Boot Info Summary ===============================

 => No boot loader is installed in the MBR of /dev/nvme0n1.
 => No boot loader is installed in the MBR of /dev/nvme1n1.

nvme0n1p1: _____________________________________________________________________

    File system:       vfat
    Boot sector type:  Windows 8/10/11/2012: FAT32
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        /efi/Boot/bkpbootx64.efi /efi/Boot/bootx64.efi 
                       /efi/Boot/fbx64.efi /efi/Boot/mmx64.efi 
                       /efi/grub/grubx64.efi /efi/grub/mmx64.efi 
                       /efi/grub/shimx64.efi /efi/neon/grubx64.efi 
                       /efi/neon/mmx64.efi /efi/neon/shimx64.efi 
                       /efi/grub/grub.cfg /efi/neon/grub.cfg 
                       /efi/ubuntu/grub.cfg /efi/Microsoft/Boot/bootmgfw.efi 
                       /efi/Microsoft/Boot/bootmgr.efi

nvme0n1p2: _____________________________________________________________________

    File system:       
    Boot sector type:  -
    Boot sector info: 

nvme0n1p3: _____________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows 8/10/11/2012: NTFS
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  Windows 10 or 11
    Boot files:        /Windows/System32/winload.exe

nvme0n1p4: _____________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info: 
    Operating System:  KDE neon User - 5.26
    Boot files:        /boot/grub/grub.cfg /etc/fstab /etc/default/grub

nvme0n1p5: _____________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info: 
    Operating System:  
    Boot files:        

nvme1n1p1: _____________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows 8/10/11/2012: NTFS
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        


================================ 2 OS detected =================================

OS#1:   KDE neon User - 5.26 on nvme0n1p4
OS#2:   Windows 10 or 11 on nvme0n1p3

================================ Host/Hardware =================================

CPU architecture: 64-bit
Video: NVIDIA Corporation Advanced Micro Devices, Inc. [AMD/ATI] from NVIDIA Corporation Advanced Micro Devices, Inc. [AMD/ATI]
BOOT_IMAGE of the installed session in use:
/boot/vmlinuz-6.0.9-060009-generic root=UUID=b386cc7c-a076-48b9-bdf7-86fe3af5136c ro quiet splash vt.handoff=7
df -Th / : /dev/nvme0n1p4 ext4   98G   55G   39G  59% /

===================================== UEFI =====================================

BIOS/UEFI firmware: GKCN59WW(1.59) from LENOVO
The firmware is EFI-compatible, and is set in EFI-mode for this installed-session.
SecureBoot disabled (confirmed by mokutil).
BootCurrent: 0004
Timeout: 0 seconds
BootOrder: 0004,2001,0000,0005,2002,2003
Boot0000* Windows Boot Manager  HD(1,GPT,f9f3fec7-bd7d-4ef5-afbf-633df4359ff0,0x800,0xfa000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)RC
Boot0002* EFI PXE 0 for IPv6 (88-A4-C2-A6-A1-D5)    PciRoot(0x0)/Pci(0x2,0x1)/Pci(0x0,0x0)/MAC(88a4c2a6a1d5,0)/IPv6([::]:<->[::]:,0,0)RC
Boot0003* EFI PXE 0 for IPv4 (88-A4-C2-A6-A1-D5)    PciRoot(0x0)/Pci(0x2,0x1)/Pci(0x0,0x0)/MAC(88a4c2a6a1d5,0)/IPv4(0.0.0.00.0.0.0,0,0)RC
Boot0004* grub  HD(1,GPT,f9f3fec7-bd7d-4ef5-afbf-633df4359ff0,0x800,0xfa000)/File(\EFI\grub\shimx64.efi)
Boot0005* ke    HD(1,GPT,f9f3fec7-bd7d-4ef5-afbf-633df4359ff0,0x800,0xfa000)/File(\EFI\neon\grubx64.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...a................
Boot2001* EFI USB Device    RC
Boot2002* EFI DVD/CDROM RC
Boot2003* EFI Network   RC


============================= Drive/Partition Info =============================

Disks info: ____________________________________________________________________

nvme0n1 : is-GPT,   no-BIOSboot,    has---ESP,  not-usb,    not-mmc, has-os,    has-win,    2048 sectors * 512 bytes
nvme1n1 : is-GPT,   no-BIOSboot,    has-noESP,  not-usb,    not-mmc, no-os, no-wind,    2048 sectors * 512 bytes

Partitions info (1/3): _________________________________________________________

nvme0n1p4   : is-os,    64, apt-get,    signed grub-pc grub-efi ,   grub2,  grub-install,   grubenv-ok, update-grub,    farbios
nvme1n1p1   : no-os,    64, nopakmgr,   no-docgrub, nogrub, nogrubinstall,  no-grubenv, noupdategrub,   farbios
nvme0n1p1   : no-os,    64, nopakmgr,   no-docgrub, nogrub, nogrubinstall,  no-grubenv, noupdategrub,   not-far
nvme0n1p3   : is-os,    64, nopakmgr,   no-docgrub, nogrub, nogrubinstall,  no-grubenv, noupdategrub,   not-far
nvme0n1p5   : no-os,    64, nopakmgr,   no-docgrub, nogrub, nogrubinstall,  no-grubenv, noupdategrub,   farbios

Partitions info (2/3): _________________________________________________________

nvme0n1p4   : isnotESP, fstab-has-goodEFI,  no-nt,  no-winload, no-recov-nor-hid,   no-bmgr,    notwinboot
nvme1n1p1   : isnotESP, part-has-no-fstab,  no-nt,  no-winload, no-recov-nor-hid,   no-bmgr,    notwinboot
nvme0n1p1   : is---ESP, part-has-no-fstab,  no-nt,  no-winload, no-recov-nor-hid,   no-bmgr,    notwinboot
nvme0n1p3   : isnotESP, part-has-no-fstab,  no-nt,  haswinload, no-recov-nor-hid,   no-bmgr,    notwinboot
nvme0n1p5   : isnotESP, part-has-no-fstab,  no-nt,  no-winload, no-recov-nor-hid,   no-bmgr,    notwinboot

Partitions info (3/3): _________________________________________________________

nvme0n1p4   : not--sepboot, with-boot,  fstab-without-boot, not-sep-usr,    with--usr,  fstab-without-usr,  std-grub.d, nvme0n1
nvme1n1p1   : not--sepboot, no---boot,  part-has-no-fstab,  not-sep-usr,    no---usr,   part-has-no-fstab,  no--grub.d, nvme1n1
nvme0n1p1   : not--sepboot, no---boot,  part-has-no-fstab,  not-sep-usr,    no---usr,   part-has-no-fstab,  no--grub.d, nvme0n1
nvme0n1p3   : not--sepboot, no---boot,  part-has-no-fstab,  not-sep-usr,    no---usr,   part-has-no-fstab,  no--grub.d, nvme0n1
nvme0n1p5   : maybesepboot, no---boot,  part-has-no-fstab,  not-sep-usr,    no---usr,   part-has-no-fstab,  no--grub.d, nvme0n1

fdisk -l (filtered): ___________________________________________________________

Disk nvme1n1: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk identifier: 41D0A58A-BCCA-4999-AE9C-77ED139B7F5D
          Start        End    Sectors   Size Type
nvme1n1p1  2048 1953523711 1953521664 931.5G Microsoft basic data
Disk nvme0n1: 476.96 GiB, 512110190592 bytes, 1000215216 sectors
Disk identifier: 41BFB7F3-AF8C-41C5-9190-2DB7078D13D7
              Start        End   Sectors   Size Type
nvme0n1p1      2048    1026047   1024000   500M EFI System
nvme0n1p2   1026048    1058815     32768    16M Microsoft reserved
nvme0n1p3   1058816  135243775 134184960    64G Microsoft basic data
nvme0n1p4 135243776  344958975 209715200   100G Linux filesystem
nvme0n1p5 344958976 1000215182 655256207 312.5G Linux filesystem

parted -lm (filtered): _________________________________________________________

nvme0n1:512GB:nvme:512:512:gpt:SAMSUNG MZVLB512HBJQ-000L2:;
1:1049kB:525MB:524MB:fat32:EFI System Partition:boot, esp;
2:525MB:542MB:16.8MB::Microsoft reserved partition:msftres;
3:542MB:69.2GB:68.7GB:ntfs:Windows:msftdata;
4:69.2GB:177GB:107GB:ext4::;
5:177GB:512GB:335GB:ext4::;
nvme1n1:1000GB:nvme:512:512:gpt:T-CREATE TM8FPH001T:;
1:1049kB:1000GB:1000GB:ntfs:Basic data partition:msftdata;

blkid (filtered): ______________________________________________________________

NAME        FSTYPE UUID                                 PARTUUID                             LABEL  PARTLABEL
nvme1n1                                                                                             
└─nvme1n1p1 ntfs   EC84F84484F812B6                     30897a30-bc92-4dd4-95c7-197c6a9c1507 Assets Basic data partition
nvme0n1                                                                                             
├─nvme0n1p1 vfat   02F8-E8D1                            f9f3fec7-bd7d-4ef5-afbf-633df4359ff0        EFI System Partition
├─nvme0n1p2                                             dcc345ec-1019-4035-a464-2f89c1271e3b        Microsoft reserved partition
├─nvme0n1p3 ntfs   34ACF8C4ACF881A2                     5f35bfa4-31c9-4038-b18f-a6c7df590937        Windows
├─nvme0n1p4 ext4   b386cc7c-a076-48b9-bdf7-86fe3af5136c 5d681f33-e946-7e4a-b80a-9b02561aacfc        
└─nvme0n1p5 ext4   1fb6f877-742b-467e-bcb6-96c3f097a920 a1c0e888-2eb2-c547-953c-3dbc1a0b413f        

Mount points (filtered): _______________________________________________________

                           Avail Use% Mounted on
/dev/nvme0n1p3             18.5G  71% /mnt/boot-sav/nvme0n1p3
/dev/nvme0n1p4             38.8G  55% /
/dev/nvme0n1p5             83.3G  68% /home
/dev/nvme1n1p1             27.8G  97% /media/razor/Assets
/dev/nvme1n1p1[/Documents] 27.8G  97% /home/razor/Documents
/dev/nvme1n1p1[/Music]     27.8G  97% /home/razor/Music
/dev/nvme1n1p1[/Pictures]  27.8G  97% /home/razor/Pictures
/dev/nvme1n1p1[/Videos]    27.8G  97% /home/razor/Videos

Mount options (filtered): ______________________________________________________


==================== nvme0n1p1/efi/grub/grub.cfg (filtered) ====================

search.fs_uuid b386cc7c-a076-48b9-bdf7-86fe3af5136c root 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

==================== nvme0n1p1/efi/neon/grub.cfg (filtered) ====================

search.fs_uuid 466639e3-84e8-470b-84da-98a7ca9396f2 root 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

=================== nvme0n1p1/efi/ubuntu/grub.cfg (filtered) ===================

search.fs_uuid 466639e3-84e8-470b-84da-98a7ca9396f2 root 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

=================== nvme0n1p4/boot/grub/grub.cfg (filtered) ====================

GNU/Linux   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 6.0.9-060009-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 6.0.7-060007-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.19.12-051912-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.19.9-051909-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.19.7-051907-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.19.5-051905-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.19.3-051903-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.19.1-051901-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.19-051900-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.4.0-135-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
GNU/Linux, with Linux 5.4.0-131-generic   b386cc7c-a076-48b9-bdf7-86fe3af5136c
Windows Boot Manager (on nvme0n1p1)   osprober-efi-02F8-E8D1
### END /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_uefi-firmware ###

======================== nvme0n1p4/etc/fstab (filtered) ========================

# <file system> <mount point> <type> <options> <dump> <pass>
UUID=b386cc7c-a076-48b9-bdf7-86fe3af5136c   /   ext4    defaults,noatime    0   1
UUID=1fb6f877-742b-467e-bcb6-96c3f097a920   /home   ext4    defaults,noatime    0   2
UUID=EC84F84484F812B6   /media/razor/Assets ntfs3   noatime,uid=1000,gid=1000,fmask=0112,dmask=0002,rw,iocharset=utf8   0   0
/media/razor/Assets/Pictures    /home/razor/Pictures    auto    defaults,nofail,nobootwait,bind 0   2
/media/razor/Assets/Music   /home/razor/Music   auto    defaults,nofail,nobootwait,bind 0   2
/media/razor/Assets/Videos  /home/razor/Videos  auto    defaults,nofail,nobootwait,bind 0   2
/media/razor/Assets/Documents   /home/razor/Documents   auto    defaults,nofail,nobootwait,bind 0   2
UUID=02F8-E8D1  /boot/efi       vfat    defaults      0       1

==================== nvme0n1p4/etc/default/grub (filtered) =====================

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=10
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
GRUB_DISABLE_OS_PROBER=false

================= nvme0n1p4: Location of files loaded by Grub ==================

           GiB - GB             File                                 Fragment(s)
 126.663829803 = 136.004251648  boot/grub/grub.cfg                             4
 128.473628998 = 137.947508736  boot/vmlinuz                                   2
 112.476821899 = 120.771067904  boot/vmlinuz-5.19-051900-generic               1
 112.523818970 = 120.821530624  boot/vmlinuz-5.19.1-051901-generic             2
 128.375267029 = 137.841893376  boot/vmlinuz-5.19.12-051912-generic            1
 128.387691498 = 137.855234048  boot/vmlinuz-5.19.3-051903-generic             2
 128.398700714 = 137.867055104  boot/vmlinuz-5.19.5-051905-generic             1
 128.411128998 = 137.880399872  boot/vmlinuz-5.19.7-051907-generic             2
 128.422142029 = 137.892225024  boot/vmlinuz-5.19.9-051909-generic             1
 128.439483643 = 137.910845440  boot/vmlinuz-5.4.0-131-generic                 1
 128.455112457 = 137.927626752  boot/vmlinuz-5.4.0-135-generic                 1
 128.465816498 = 137.939120128  boot/vmlinuz-6.0.7-060007-generic              2
 128.473628998 = 137.947508736  boot/vmlinuz-6.0.9-060009-generic              2
 128.455112457 = 137.927626752  boot/vmlinuz.old                               1
 157.724925995 = 169.355849728  boot/initrd.img                                1
  80.364151001 = 86.290350080   boot/initrd.img-5.19-051900-generic            1
  76.364162445 = 81.995395072   boot/initrd.img-5.19.1-051901-generic          1
 144.364200592 = 155.009880064  boot/initrd.img-5.19.12-051912-generic         1
 160.364177704 = 172.189724672  boot/initrd.img-5.19.3-051903-generic          1
 158.864253998 = 170.579193856  boot/initrd.img-5.19.5-051905-generic          2
 157.176685333 = 168.767180800  boot/initrd.img-5.19.7-051907-generic          1
 157.301689148 = 168.901402624  boot/initrd.img-5.19.9-051909-generic          1
 157.383125305 = 168.988844032  boot/initrd.img-5.4.0-131-generic              1
 157.465816498 = 169.077633024  boot/initrd.img-5.4.0-135-generic              2
 157.592098236 = 169.213227008  boot/initrd.img-6.0.7-060007-generic           1
 157.724925995 = 169.355849728  boot/initrd.img-6.0.9-060009-generic           1
 157.465816498 = 169.077633024  boot/initrd.img.old                            2

=================== nvme0n1p4: ls -l /etc/grub.d/ (filtered) ===================

-rwxr-xr-x. 1 root root 18224 Jan 11  2022 10_linux
-rwxr-xr-x. 1 root root 42359 Aug 12  2021 10_linux_zfs
-rwxr-xr-x. 1 root root 12894 Aug 12  2021 20_linux_xen
-rwxr-xr-x. 1 root root 12059 Aug 12  2021 30_os-prober
-rwxr-xr-x. 1 root root  1424 Aug 12  2021 30_uefi-firmware
-rwxr-xr-x. 1 root root   700 Feb 21  2022 35_fwupd
-rwxr-xr-x. 1 root root   214 Aug 12  2021 40_custom
-rwxr-xr-x. 1 root root   216 Aug 12  2021 41_custom



Suggested repair: ______________________________________________________________

The default repair of the Boot-Repair utility would reinstall the grub-efi of
nvme0n1p4,
using the following options:  nvme0n1p1/boot/efi
Additional repair would be performed: unhide-bootmenu-10s use-standard-efi-file restore-efi-backups

Final advice in case of suggested repair: ______________________________________

Please do not forget to make your UEFI firmware boot on the KDE neon User - 5.26 entry (nvme0n1p1/efi/****/grub****.efi (**** will be updated in the final message) file) !
If your computer reboots directly into Windows, try to change the boot order in your UEFI firmware.
If your UEFI firmware does not allow to change the boot order, change the default boot entry of the Windows bootloader.
For example you can boot into Windows, then type the following command in an admin command prompt:
bcdedit /set {bootmgr} path \EFI\****\grub****.efi (**** will be updated in the final message)

答案1

nvme0n1p1/efi/neon/grub.cfg和都nvme0n1p1/efi/ubuntu/grub.cfg引用具有 UUID 的文件系统466639e3-84e8-470b-84da-98a7ca9396f2,该文件系统似乎不再存在于系统上。至少这些 UUID 应该替换为有效的 UUID,因为它们在当前形式下是无用的。

Boot-Repair 打印输出中的输出efibootmgr -v表明 UEFI 引导选项Boot0004是当前活动的选项,也是第一个位于 中的选项BootOrder,它指的是\EFI\grub\shimx64.efi带有 PARTUUID 的分区f9f3fec7-bd7d-4ef5-afbf-633df4359ff0,即nvme0n1p1

作为强力修复,您可以进行编辑nvme0n1p1/efi/grub/grub.cfg以或多或少匹配您发现的命令:

set prefix=(hd0,gpt1)/efi/grub
set root=(hd0,gpt4)
configfile $root/boot/grub/grub.cfg
# or maybe "insmod normal" and then "normal", just like you did...

或者您可以尝试此版本,以便对未来的配置更改更加宽容:

search.fs_uuid 02F8-E8D1 root       # search for nvme0n1p1 by FS UUID
set prefix=($root)'/efi/grub'       # sets the prefix using the root
search.fs_uuid b386cc7c-a076-48b9-bdf7-86fe3af5136c root   # find nvme0n1p4 by FS UUID
# maybe "insmod normal" and then "normal" here, or...
configfile $root/boot/grub/grub.cfg

背景:最初在 EFI 系统分区的同一目录中shimx64.efi启动(在您的系统上为)。它首先在它本身所在的同一目录中读取一个 mini- ,这在现代 Debian 和衍生版本上使用(并且越来越多地在其他发行版上使用)来识别主目录在哪里。通常它位于根文件系统或专用文件系统上(如果根文件系统已加密或放置在 GRUB 无法读取的 LVM、RAID 或类似文件系统上)。grubx64.efinvme0n1p1grub.cfg/boot/grub/boot

但就您而言,您的 EFI 系统分区似乎包含一个/efi/grub似乎可用作 GRUB 前缀的目录(即从中加载更多 GRUB 模块的位置)。或者这可能是一个转移注意力的事情:考虑到您的设置包括shimx64.efi满足安全启动要求的所有必需的 GRUB 模块必须已经内置到主grubx64.efi二进制文件中,因为如果安全启动生效,GRUB 实际上将无法加载任何模块。

(安全启动固件将强制限制加载到内存中的任何内容都将被标记为不可执行,除非它来自有效签名的 Windows 样式 PE+ 二进制文件。GRUB 模块是 ELF 格式的二进制文件,而不是 PE+,因此它们不能但 maingrubx64.efi是一个 PE+ 文件,它可以在签名之前包含内置的 ELF 模块。)

/boot/grub/grub.cfg从根文件系统来看,包含引导菜单定义的实际“主”GRUB 配置位于nvme0n1p4.但是 GRUB 一次只能“查看”一个文件系统,并且该$root变量通常用于指定 GRUB 将访问的文件系统。

相关内容