在内核 5.4.0.104 中启动时出现“无效的魔法数字”错误

在内核 5.4.0.104 中启动时出现“无效的魔法数字”错误

大家好,使用 Ubuntu 的用户们,

我的联想 X230 平板电脑安装了 Ubuntu 18.04,安装在三星 4 SSD 上,今天只能启动到最小的 bash。在我看来,这似乎是 GRUB 或启动分区的问题,我使用了软件包boot-repair(https://help.ubuntu.com/community/Boot-Repair)通过 USB-Live-System(也是 Ubuntu 18.04)来“修复”启动分区。

修复过程的日志是

boot-repair-4ppa200                                              [20220310_1118]

============================= Boot Repair Summary ==============================






Recommended repair: ____________________________________________________________

The default repair of the Boot-Repair utility will reinstall the grub2 of
sda2 into the MBR of sda.
Grub-efi will not be selected by default because no ESP detected.
Additional repair will be performed: unhide-bootmenu-10s



Unhide GRUB boot menu in sda2/etc/default/grub

========================= Reinstall the grub2 of sda2 ==========================

chroot /mnt/boot-sav/sda2 grub-install --version
grub-install (GRUB) 2.02-2ubuntu8.23

==> Reinstall the GRUB of sda2 into the MBR of sda

chroot /mnt/boot-sav/sda2 grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.

chroot /mnt/boot-sav/sda2 update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-104-generic
Found initrd image: /boot/initrd.img-5.4.0-104-generic
Found linux image: /boot/vmlinuz-5.4.0-100-generic
Found initrd image: /boot/initrd.img-5.4.0-100-generic
Found linux image: /boot/vmlinuz-5.4.0-99-generic
Found initrd image: /boot/initrd.img-5.4.0-99-generic
Found linux image: /boot/vmlinuz-5.4.0-90-generic
Found initrd image: /boot/initrd.img-5.4.0-90-generic
Found linux image: /boot/vmlinuz-5.4.0-89-generic
Found initrd image: /boot/initrd.img-5.4.0-89-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin

Unhide GRUB boot menu in sda2/boot/grub/grub.cfg

Boot successfully repaired.

You can now reboot your computer.


============================ Boot Info After Repair ============================

 => Grub2 (v2.00) is installed in the MBR of /dev/sda and looks at sector 2048 
    of the same hard drive for core.img. core.img is at this location and 
    looks for (,gpt2)/boot/grub. It also embeds following components:
    
    modules
    ---------------------------------------------------------------------------
    fshelp ext2 part_gpt biosdisk
    ---------------------------------------------------------------------------
 => Syslinux MBR (5.00 and higher) is installed in the MBR of /dev/sdb.

sda1: __________________________________________________________________________

    File system:       BIOS Boot partition
    Boot sector type:  Grub2's core.img
    Boot sector info: 

sda2: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info: 
    Operating System:  Ubuntu 18.04.6 LTS
    Boot files:        /boot/grub/grub.cfg /etc/fstab /etc/default/grub 
                       /boot/grub/i386-pc/core.img

sdb1: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  SYSLINUX 6.03
    Boot sector info:  Syslinux looks at sector 32864 of /dev/sdb1 for its 
                       second stage. The integrity check of Syslinux failed. 
                       No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        /boot/grub/grub.cfg /syslinux.cfg 
                       /efi/BOOT/grubx64.efi /ldlinux.sys


================================ 1 OS detected =================================

OS#1:   Ubuntu 18.04.6 LTS on sda2

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

CPU architecture: 64-bit
Video: 3rd Gen Core processor Graphics Controller from Intel Corporation
Live-session OS is Ubuntu 64-bit (Ubuntu 18.04.5 LTS, bionic, x86_64)

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

BIOS/UEFI firmware: GCETB5WW (2.75 ) from LENOVO
The firmware seems EFI-compatible, but this live-session is in Legacy/BIOS/CSM mode (not in EFI mode).



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

Disks info: ____________________________________________________________________

sda : is-GPT,   hasBIOSboot,    has-noESP,  not-usb,    not-mmc, has-os,    no-wind,    2048 sectors * 512 bytes

Partitions info (1/3): _________________________________________________________

sda2    : is-os,    64, apt-get,    grub-pc ,   grub2,  grub-install,   grubenv-ok, update-grub,    farbios

Partitions info (2/3): _________________________________________________________

sda2    : isnotESP, fstab-without-efi,  no-nt,  no-winload, no-recov-nor-hid,   no-bmgr,    notwinboot

Partitions info (3/3): _________________________________________________________

sda2    : not--sepboot, with-boot,  fstab-without-boot, not-sep-usr,    with--usr,  fstab-without-usr,  std-grub.d, sda

fdisk -l (filtered): ___________________________________________________________

Disk sda: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Disk identifier: 77496514-CFD9-4986-81C9-0ADDBD4EF3F9
      Start        End    Sectors  Size Type
sda1   2048       4095       2048    1M BIOS boot
sda2   4096 7814035455 7814031360  3.7T Linux filesystem
Disk sdb: 28.8 GiB, 30943995904 bytes, 60437492 sectors
Disk identifier: 0x04b788c8
      Boot Start      End  Sectors  Size Id Type
sdb1  *     2048 60437491 60435444 28.8G  c W95 FAT32 (LBA)

parted -lm (filtered): _________________________________________________________

sda:4001GB:scsi:512:512:gpt:ATA Samsung SSD 870:;
1:1049kB:2097kB:1049kB:::bios_grub;
2:2097kB:4001GB:4001GB:ext4::;
sdb:30.9GB:scsi:512:512:msdos:Kingston DataTraveler 3.0:;
1:1049kB:30.9GB:30.9GB:fat32::boot, lba;

blkid (filtered): ______________________________________________________________

NAME   FSTYPE   UUID                                 PARTUUID                             LABEL       PARTLABEL
sda                                                                                                   
├─sda1                                               478eef14-aac2-4ab4-a344-5287a2a055ba             
└─sda2 ext4     d940e80a-eb1c-4cd8-ae21-5f6a8e250ef4 7e3d528f-60fa-4c7a-91f7-d0d312f3cc37             
sdb                                                                                                   
└─sdb1 vfat     78CD-058D                            04b788c8-01                          UBUNTU 18_0 

Mount points (filtered): _______________________________________________________

           Avail Use% Mounted on
/dev/sda2    1.4T  56% /mnt/boot-sav/sda2
/dev/sdb1   22.2G  23% /cdrom

Mount options (filtered): ______________________________________________________

/dev/sda2   ext4            rw,relatime
/dev/sdb1   vfat            ro,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro

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

Ubuntu   d940e80a-eb1c-4cd8-ae21-5f6a8e250ef4
Ubuntu, with Linux 5.4.0-104-generic   d940e80a-eb1c-4cd8-ae21-5f6a8e250ef4
Ubuntu, with Linux 5.4.0-100-generic   d940e80a-eb1c-4cd8-ae21-5f6a8e250ef4
Ubuntu, with Linux 5.4.0-99-generic   d940e80a-eb1c-4cd8-ae21-5f6a8e250ef4
Ubuntu, with Linux 5.4.0-90-generic   d940e80a-eb1c-4cd8-ae21-5f6a8e250ef4
Ubuntu, with Linux 5.4.0-89-generic   d940e80a-eb1c-4cd8-ae21-5f6a8e250ef4
### END /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_uefi-firmware ###

========================== sda2/etc/fstab (filtered) ===========================

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=d940e80a-eb1c-4cd8-ae21-5f6a8e250ef4 /               ext4    errors=remount-ro 0       1
/swapfile                                 none            swap    sw              0       0

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

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
GRUB_DISABLE_OS_PROBER=false

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

           GiB - GB             File                                 Fragment(s)
   0.001964569 = 0.002109440    boot/grub/grub.cfg                             1
1096.656921387 = 1177.526403072 boot/grub/i386-pc/core.img                     1
1519.777778625 = 1631.848964096 boot/vmlinuz-5.4.0-100-generic                 1
2101.746528625 = 2256.733151232 boot/vmlinuz-5.4.0-104-generic                 1
1847.706077576 = 1983.959293952 boot/vmlinuz-5.4.0-89-generic                  1
1841.448265076 = 1977.240018944 boot/vmlinuz-5.4.0-90-generic                  1
1038.902778625 = 1115.513364480 boot/vmlinuz-5.4.0-99-generic                  1
2101.746528625 = 2256.733151232 vmlinuz                                        1
1519.777778625 = 1631.848964096 vmlinuz.old                                    1
1074.044242859 = 1153.246224384 boot/initrd.img-5.4.0-100-generic              7
2102.181636810 = 2257.200345088 boot/initrd.img-5.4.0-104-generic              4
1573.306636810 = 1689.325137920 boot/initrd.img-5.4.0-89-generic               3
1852.564449310 = 1989.175930880 boot/initrd.img-5.4.0-90-generic               2
1039.619136810 = 1116.282548224 boot/initrd.img-5.4.0-99-generic               4
2102.181636810 = 2257.200345088 initrd.img                                     4
1074.044242859 = 1153.246224384 initrd.img.old                                 7

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

-rwxr-xr-x 1 root root 12808 Feb 24  2021 10_linux
-rwxr-xr-x 1 root root 11298 Jul 31  2020 20_linux_xen
-rwxr-xr-x 1 root root 12059 Jul 31  2020 30_os-prober
-rwxr-xr-x 1 root root  1418 Jul 31  2020 30_uefi-firmware
-rwxr-xr-x 1 root root   214 Jul 31  2020 40_custom
-rwxr-xr-x 1 root root   216 Jul 31  2020 41_custom

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

Try Ubuntu without installing
Install Ubuntu
OEM install (for manufacturers)
Check disc for defects

========================= sdb1/syslinux.cfg (filtered) =========================

DEFAULT loadconfig

LABEL loadconfig
  CONFIG /isolinux/isolinux.cfg
  APPEND /isolinux/

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

           GiB - GB             File                                 Fragment(s)
            ?? = ??             boot/grub/grub.cfg                             1

================== sdb1: Location of files loaded by Syslinux ==================

           GiB - GB             File                                 Fragment(s)
            ?? = ??             syslinux.cfg                                   1
            ?? = ??             ldlinux.sys                                    1

现在,我可以启动除最新版本(5.4.0.104-generic)之外的所有内核:当尝试在 GRUB 中启动此条目时,我收到错误消息... invalid magic number ... need to load kernel first

如果我不使用最新版本的内核,这会是个问题吗?

我可以运行哪些额外的诊断程序来查明问题并修复它(例如启动到 5.4.0-104 的条目)?

我重新安装了linux-headers-5.4.0-104-genericlinux-image-5.4.0-104-generic,但这没有帮助。

答案1

如果原始启动文件/boot/vmlinuz-<kernel-version>以某种方式损坏,则可能会发生这种情况。

卸载最新 Linux 内核的软件包(linux-generic)并重新安装它们可以解决问题。

对于标准通用内核,可以通过以下方式完成:

sudo apt-get install --reinstall linux-generic

这将重新安装元包linux-headers-genericlinux-image-generic,进而重新安装最新的图像和头包。

如果您使用其他内核风格,则必须相应地调整元包的名称。

相关内容