找不到 /boot/grub/menu.lst 文件

找不到 /boot/grub/menu.lst 文件

我在尝试安装 docker 时遇到错误。

我已尝试过sudo apt-get autoremove,但是没有帮助。

输出如下:

sudo apt install docker.io            
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-modules-4.15.0-29-generic
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  bridge-utils cgroupfs-mount containerd pigz runc ubuntu-fan
Suggested packages:
  aufs-tools btrfs-tools debootstrap docker-doc rinse zfs-fuse | zfsutils
The following packages will be REMOVED:
  linux-image-4.15.0-29-generic
The following NEW packages will be installed:
  bridge-utils cgroupfs-mount containerd docker.io pigz runc ubuntu-fan
0 upgraded, 7 newly installed, 1 to remove and 433 not upgraded.
1 not fully installed or removed.
Need to get 0 B/52.2 MB of archives.
After this operation, 249 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 280062 files and directories currently installed.)
Removing linux-image-4.15.0-29-generic (4.15.0-29.31~16.04.1) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-29-generic
/etc/kernel/postrm.d/zz-update-grub:
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: line 1094: read: read error: 0: Bad file descriptor
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-4.15.0-29-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-4.15.0-29-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

sudo apt-get autoremove是为了移除一个实际上很杂乱的包裹。

您的问题的答案很可能在最后一个“段落”中。问题似乎无法找到/boot/grub/menu.lst file。它询问,Would you like /boot/grub/menu.lst generated for you? (y/N)

如果您回答否(N),您可能需要再试一次但回答是(y)。

如果您回答是,我建议您检查系统中是否存在该文件。如果不存在,您可以创建一个空白文件,看看是否可行。如果可行,您可以尝试读取它以查看它是否存在明显问题,或者暂时重命名它以妥善保管,并将其替换为空白文件。

这是一个问题,其中某人有相同的错误消息并且接受的答案涉及创建一个以该名称命名的空白文件: Ubuntu Server 18.04 apt-get 失败

答案2

输出中最有问题的一行是

/usr/sbin/update-grub: line 1094: read: read error: 0: Bad file descriptor
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1

因此你需要重新安装 GRUB 相关软件包

sudo apt-get install --reinstall grub2-common

然后重试。

相关内容