升级和自动删除后 Apt 和 Grub 损坏

升级和自动删除后 Apt 和 Grub 损坏

我2天前按顺序运行了以下命令:

  1. sudo apt 更新 && sudo apt 升级 -y
  2. sudo apt 自动删除
  3. sudo apt 更新 && sudo apt 升级 -y

现在 apt 包管理器不让我安装任何包。我也无法更新 grub。计算机可以照常重启。

无论如何,sudo apt --fix-broken install 都会返回相同的错误附加输出:

unmesh@unmeshpc:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-5.4.0-91-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 11.8 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 582323 files and directories currently installed.)
Removing linux-image-5.4.0-91-generic (5.4.0-91.102) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.4.0-91-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 14: /etc/default/grub: GRUB_CMDLINE_LIN: not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.4.0-91-generic (--remove):
 installed linux-image-5.4.0-91-generic package post-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-5.4.0-91-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

unmesh@unmeshpc:~$ sudo apt update
[sudo] password for unmesh: 
Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease                                               
Hit:2 http://in.archive.ubuntu.com/ubuntu focal InRelease                                                  
Hit:3 http://ppa.launchpad.net/gezakovacs/ppa/ubuntu focal InRelease                                       
Hit:5 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease                                          
Hit:6 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease                                 
Hit:7 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease                                        
Hit:8 http://ppa.launchpad.net/tsbarnes/indicator-keylock/ubuntu focal InRelease                           
Get:9 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                                  
Hit:10 http://packages.ros.org/ros/ubuntu focal InRelease                                                  
Hit:4 https://packagecloud.io/ookla/speedtest-cli/ubuntu focal InRelease                                   
Fetched 114 kB in 8s (14.8 kB/s)                                                                           
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

为了便于调试,我附加了运行升级命令后的 bash 输出:

unmesh@unmeshpc:~$ sudo apt upgrade -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
Need to get 0 B/8,992 kB of archives.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-5.11.0-38-generic (5.11.0-38.42~20.04.1) ...
depmod: WARNING: could not open modules.order at /lib/modules/5.11.0-38-generic:
 No such file or directory
depmod: WARNING: could not open modules.builtin at /lib/modules/5.11.0-38-generi
c: No such file or directory
Setting up linux-image-5.11.0-41-generic (5.11.0-41.45~20.04.1) ...
Processing triggers for linux-image-5.11.0-38-generic (5.11.0-38.42~20.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.11.0-38-generic
Error! Your kernel headers for kernel 5.11.0-38-generic cannot be found.
Please install the linux-headers-5.11.0-38-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 5.11.0-38-generic cannot be found.
Please install the linux-headers-5.11.0-38-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.11.0-38-generic
cat: /var/tmp/mkinitramfs_f3YBdS/lib/modules/5.11.0-38-generic/modules.builtin: 
No such file or directory
depmod: WARNING: could not open modules.order at /var/tmp/mkinitramfs_f3YBdS/lib
/modules/5.11.0-38-generic: No such file or directory
depmod: WARNING: could not open modules.builtin at /var/tmp/mkinitramfs_f3YBdS/l
ib/modules/5.11.0-38-generic: No such file or directory
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 14: /etc/default/grub: GRUB_CMDLINE_LIN: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.11.0-38-generic (--configure):
 installed linux-image-5.11.0-38-generic package post-installation script subpro
cess returned error exit status 1
Processing triggers for linux-image-5.11.0-41-generic (5.11.0-41.45~20.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.11.0-41-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.11.0-41-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 14: /etc/default/grub: GRUB_CMDLINE_LIN: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.11.0-41-generic (--configure):
 installed linux-image-5.11.0-41-generic package post-installation script subpro
cess returned error exit status 1
Errors were encountered while processing:
 linux-image-5.11.0-38-generic
 linux-image-5.11.0-41-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

update-grub 输出给出以下输出:

unmesh@unmeshpc:~$ sudo update-grub
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 14: /etc/default/grub: GRUB_CMDLINE_LIN: not found

Neofetch 输出如下:

$ neofetch
            .-/+oossssoo+/-.               unmesh@unmeshpc 
        `:+ssssssssssssssssss+:`           --------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 20.04.3 LTS x86_64 
    .ossssssssssssssssssdMMMNysssso.       Host: HP Pavilion Gaming Laptop 15-ec1xxx 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 5.11.0-41-generic 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 1 day, 10 hours, 58 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 3763 (dpkg), 22 (snap) 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 5.0.17 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 1920x1080 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   DE: GNOME 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Mutter 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   WM Theme: Yaru-dark 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: adwaita-dark-amoled-master [GTK2/3] 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Icons: Yaru [GTK2/3] 
  +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal: tilix 
   /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: AMD Ryzen 5 4600H with Radeon Graphics (12) @ 3.000GHz 
    .ossssssssssssssssssdMMMNysssso.       GPU: NVIDIA 01:00.0 NVIDIA Corporation Device 1f99 
      -+sssssssssssssssssyyyssss+-         GPU: AMD ATI 05:00.0 Renoir 
        `:+ssssssssssssssssss+:`           Memory: 2625MiB / 7309MiB 
            .-/+oossssoo+/-.
                                                               

我正在运行以下内核:

uname -r
5.11.0-41-generic

                                                               

我该如何解决这些问题?

谢谢

问候,Unmesh

相关内容