笔记

笔记

我在运行 Ubuntu 21.10 Server 的 Raspberry Pi Zero W 2 上安装并配置了 WiFi。我运行了apt update,然后apt upgrade得到了以下输出。这是一块全新的主板和全新安装,所以我完全不确定会发生什么。

sudo apt upgrade

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 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.140ubuntu6) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-firmware (1.201.1) ...
update-initramfs: Generating /boot/initrd.img-5.13.0-1008-raspi
Killed
E: mkinitramfs failure zstd -q -19 -T0 137
update-initramfs: failed for /boot/initrd.img-5.13.0-1008-raspi with 1.
dpkg: error processing package linux-firmware (--configure):installed linux-firmware package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of linux-image-raspi:
 linux-image-raspi depends on linux-firmware; however:
  Package linux-firmware is not configured yet.
dpkg: error processing package linux-image-raspi (--configure):
 dependency problems - leaving unconfigured
Setting up linux-image-5.13.0-1011-raspi (5.13.0-1011.13) ...
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of linux-raspi:
 linux-raspi depends on linux-image-raspi (= 5.13.0.1011.17); however:
  Package linux-image-raspi is not configured yet.
dpkg: error processing package linux-raspi (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for initramfs-tools (0.140ubuntu6) ...
update-initramfs: Generating /boot/initrd.img-5.13.0-1008-raspi
Killed
E: mkinitramfs failure zstd -q -19 -T0 137
update-initramfs: failed for /boot/initrd.img-5.13.0-1008-raspi with 1.
dpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
Processing triggers for linux-image-5.13.0-1011-raspi (5.13.0-1011.13) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.13.0-1011-raspi
Killed
E: mkinitramfs failure zstd -q -19 -T0 137
update-initramfs: failed for /boot/initrd.img-5.13.0-1011-raspi with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-5.13.0-1011-raspi (--configure):
 installed linux-image-5.13.0-1011-raspi package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 linux-firmware
 linux-image-raspi
 linux-raspi
 initramfs-tools
 linux-image-5.13.0-1011-raspi
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我在使用 64 位 Ubuntu Server 21.10 的 Pi Zero 2 上也遇到了同样的问题。除非启用了交换文件,否则更新过程可能会耗尽内存。

交换文件创建示例 -

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile swap swap defaults 0 0" | sudo tee -a /etc/fstab

参考:https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-20-04/

答案2

您的系统已经搞砸了,我怀疑这是一个全新安装的系统,因为这个问题不应该出现在全新安装中,无论如何,我建议重新安装作为首选,但如果你不能,那么这里有一个答案可以帮助你摆脱这些错误。

笔记

  • 我是在每个解决方案后添加“*”这很可能会起作用。

简短回答 *

简单地删除并重新安装软件包:-

您可以通过以下方式删除软件包:-

$ sudo dpkg --remove --force-remove-reinstreq linux-firmware
$ sudo dpkg --remove --force-remove-reinstreq linux-image-raspi
$ sudo dpkg --remove --force-remove-reinstreq linux-raspi
$ sudo dpkg --remove --force-remove-reinstreq initramfs-tools
$ sudo dpkg --remove --force-remove-reinstreq linux-image-5.13.0-1011-raspi
$ sudo apt-get -f install

然后重新安装它们

sudo apt-get install linux-firmware linux-image-raspi linux-raspi initramfs-tools  linux-image-5.13.0-1011-raspi

先进的解决方案:-

使用强制安装。*

一般来说,使用apt -f install即可!
运行:

sudo apt -f install

如果错误已修复,那么恭喜您,但如果没有,请继续。

稍微前进一下 *

您可能需要清除缓存文件来apt修复此问题。通常,它不会以任何方式损害您的操作系统。
您可以运行

sudo rm -rf /var/cache/apt/archives/*.deb

更有可能的是,它会修复错误!如果没有,请继续。

另一种解决方案。

你也可以尝试一下 -

sudo -E apt-get install aptitude
sudo -E aptitude safe-upgrade
sudo -E aptitude dist-upgrade

在那之后

mkdir ~/debs
cd ~/debs
ls
sudo apt download linux-firmware linux-image-raspi linux-raspi initramfs-tools  linux-image-5.13.0-1011-raspi

sudo dpkg -i --force-all ./*.deb

删除并重新安装软件包。

您可以通过以下方式删除软件包:-

$ sudo dpkg --remove --force-remove-reinstreq linux-firmware
$ sudo dpkg --remove --force-remove-reinstreq linux-image-raspi
$ sudo dpkg --remove --force-remove-reinstreq linux-raspi
$ sudo dpkg --remove --force-remove-reinstreq initramfs-tools
$ sudo dpkg --remove --force-remove-reinstreq linux-image-5.13.0-1011-raspi
$ sudo apt-get -f install

然后重新安装它们

sudo apt-get install linux-firmware linux-image-raspi linux-raspi initramfs-tools  linux-image-5.13.0-1011-raspi

最后一个选项 *

作为最后一个选项,您可以尝试删除错误包的安装后文件。这不会解决错误,但您的系统将忽略这些错误。

cd /var/lib/dpkg/info/
mkdir ~/backup
mv linux-firmware ~/backup
mv linux-image-raspi ~/backup
mv linux-raspi ~/backup
mv initramfs-tools ~/backup
mv linux-image-5.13.0-1011-raspi ~/backup

sudo apt -f install

它有效吗?

如果它不起作用那就没有运气了。如果这些命令不起作用,那么你的系统就会比以前更混乱。正如您所说,这是一个全新安装,因此只需重新安装 ubuntu。

相关内容