升级错误:删除内核时

升级错误:删除内核时

尝试安装或升级系统时 - 删除内核会引发错误,与 grub 有关。Grub 工作正常,启动时我可以看到菜单。是否应该提供一些其他信息?

$ sudo apt-get upgrade
...
The following packages will be REMOVED:
  linux-image-4.15.0-52-generic
...
Removing linux-image-4.15.0-52-generic (4.15.0-52.56) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-52-generic
/etc/kernel/postrm.d/x-grub-legacy-ec2:
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... 

Could not find /boot/grub/menu.lst file. Would you like /boot/grub/menu.lst generated for you? (y/N) /usr/sbin/update-grub-legacy-ec2: line 1101: read: read error: 0: Bad file descriptor
run-parts: /etc/kernel/postrm.d/x-grub-legacy-ec2 exited with return code 1
dpkg: error processing package linux-image-4.15.0-52-generic (--remove):
 installed linux-image-4.15.0-52-generic package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-4.15.0-52-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)


leonid@DevSSD:~$ grub-install --version
grub-install (GRUB) 2.02-2ubuntu8.13
leonid@DevSSD:~$ uname -r
4.15.0-54-generic

更新:

$ dpkg -l | grep grub
ii  grub-common                           2.02-2ubuntu8.13                             amd64        GRand Unified Bootloader (common files)
ii  grub-efi-amd64                        2.02-2ubuntu8.13                             amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 version)
ii  grub-efi-amd64-bin                    2.02-2ubuntu8.13                             amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 binaries)
ii  grub-efi-amd64-signed                 1.93.14+2.02-2ubuntu8.13                     amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 version, signed)
ii  grub-legacy-ec2                       1:1                                          all          Handles update-grub for ec2 instances
ii  grub2-common                          2.02-2ubuntu8.13                             amd64        GRand Unified Bootloader (common files for version 2)

更新:启动是 UEFI,我曾经用 BootRepair 修复过 grub

答案1

首先,请像@heynnema 提到的那样进行文件系统检查。

sudo dpkg -P grub-legacy-ec2  

当命令不起作用时。

sudo mv /etc/kernel/postrm.d/x-grub-legacy-ec2 $HOME

在两种情况下都随后运行

sudo dpkg --configure -a 

答案2

你最好先检查一下你的文件系统...那里可能有一些损坏...

对于 18.04 或更新版本...

  • 启动至 Ubuntu Live DVD/USB
  • terminalCtrl+ Alt+打开窗口T
  • 类型sudo fdisk -l
  • 识别“Linux 文件系统”的 /dev/sdXX 设备名称
  • 输入sudo fsck -f /dev/sdXX,替换sdXX为您之前找到的数字
  • fsck如果有错误则重复命令
  • 类型reboot

相关内容