如何修复部分升级的内核

如何修复部分升级的内核

几周前,我通过 ssh 将 Ubuntu 从 18 升级到 20,升级过程曾因/boot分区已满(设备上没有剩余空间)而中断过一次,我释放了空间,重新启动了升级过程并完成了升级。然后系统开始返回类似这样的错误,这通常是由于设备上没有剩余空间(再次)导致的,但现在不再是这样了,空间足够了

apt-get update && apt-get --with-new-pkgs upgrade
Hit:1 http://ch.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://ch.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://ch.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Reading package lists... Done
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.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up initramfs-tools (0.136ubuntu6.3) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.3) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-48-generic
Error 24 : Write error : cannot write compressed block
E: mkinitramfs failure cpio 141 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.4.0-48-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 initramfs-tools
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

两周前,我通过使用以前的内核重新启动系统、手动删除并重新安装当前内核(5.4.0-48-generic)、再次使用最新内核重新启动系统来解决了这个问题。

我可以再做一次,但是由于问题再次出现,所以它可能会再次发生。

有人对这个问题有更深入的了解吗,可以让我一次性解决所有问题?

编辑:@guiverc

cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

@没有人

# dpkg -l | egrep -v '^ii|rc'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
+++-======================================-=====================================-============-===============================================================================
iF  initramfs-tools                        0.136ubuntu6.3                        all          generic modular initramfs generator (automation)

答案1

wget -c http://mirrors.kernel.org/ubuntu/pool/main/i/initramfs-tools/initramfs-tools_0.136ubuntu6_all.deb

直接用 dpkg 安装。

sudo dpkg -i initramfs-tools_0.136ubuntu6_all.deb

请注意,只有当此部分运行时没有错误,接下来的步骤才会有效,我的意思是从 initramfs-tool 安装并删除剩余的配置文件。

sudo apt purge $(dpkg -l | egrep '^rc' | awk '{print $2}')

或者你可以使用

sudo dpkg -P $(dpkg -l | egrep '^rc' | awk '{print $2}')

剩余的 conf 文件有时会产生麻烦。

sudo apt update && sudo apt full-upgrade

当前焦点内核是

uname -r
5.4.0-52-generic

确保您的系统上有 linux-generic 软件包。

相关内容