我在 Ubuntu 18.04 服务器上有这个问题,可能是因为/boot/grub/menu.lst
不存在:
root@myserver:~# apt install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
liblua5.1-0 libyajl2
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-4.15.0-175-generic (4.15.0-175.184) ...
Processing triggers for linux-image-4.15.0-175-generic (4.15.0-175.184) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.15.0-175-generic
W: initramfs-tools configuration sets RESUME=/dev/mapper/vg-lv_swap
W: but no matching swap device is available.
I: The initramfs will attempt to resume from /dev/vda2
I: (UUID=4c30643f-055d-4ad7-babc-b2a6b8ac3138)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.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 gene
rated for you? (y/N) /usr/sbin/update-grub-legacy-ec2: line 1101: read: read err
or: 0: Bad file descriptor
run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 1
dpkg: error processing package linux-image-4.15.0-175-generic (--configure):
installed linux-image-4.15.0-175-generic package post-installation script subpr
ocess returned error exit status 1
Errors were encountered while processing:
linux-image-4.15.0-175-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@myserver:~# locate menu.lst
/boot/grub.bak/menu.lst_backup_by_grub2_prerm
/boot/grub.bak/menu.lst~
/var/lib/ucf/cache/:run:grub:menu.lst
root@myserver:~# cat /var/lib/ucf/cache/:run:grub:menu.lst
## ## End Default Options ##
title Ubuntu 18.04.6 LTS, kernel 4.15.0-173-generic
root (hd0)
kernel /vmlinuz-4.15.0-173-generic root=/dev/mapper/vg-lv_root ro console=hvc0
initrd /initrd.img-4.15.0-173-generic
title Ubuntu 18.04.6 LTS, kernel 4.15.0-173-generic (recovery mode)
root (hd0)
kernel /vmlinuz-4.15.0-173-generic root=/dev/mapper/vg-lv_root ro single
initrd /initrd.img-4.15.0-173-generic
### END DEBIAN AUTOMAGIC KERNELS LIST
root@myserver:~#
和:
root@myserver:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 461M 0 461M 0% /dev
tmpfs 99M 776K 98M 1% /run
/dev/vda1 23G 5.3G 17G 25% /
tmpfs 493M 0 493M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 493M 0 493M 0% /sys/fs/cgroup
/dev/vdb1 147G 52G 88G 38% /var/www/html/video
tmpfs 99M 0 99M 0% /run/user/0
root@myserver:~# uname -a
Linux myserver.com 4.15.0-173-generic #182-Ubuntu SMP Fri Mar 18 15:53:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
任何想法?谢谢
我通过以下方式解决了。
首先,我得到了分区的 UUID:
并检查了
/boot
目录:我使用该信息手动重新创建
menu.lst
(从另一台机器复制默认注释代码):然后我重新启动,最后:
在安装过程中,我选择了:
最后,我再次重新启动并正确加载了新内核。