Ubuntu 更新错误启动盘空间不足。sudo apt autoremove,不起作用!

Ubuntu 更新错误启动盘空间不足。sudo apt autoremove,不起作用!

在终端中,当我尝试(sudo apt autoremove)时,出现下面列出的错误。这是一个单启动系统。

user@user-HP-EliteBook-840-G3:~$ sudo apt  autoremove
[sudo] password for user: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-5.15.0-105-generic (5.15.0-105.115) ...
Processing triggers for linux-image-5.15.0-105-generic (5.15.0-105.115) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.15.0-105-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
zstd: error 25 : Write error : No space left on device (cannot write compressed block) 
E: mkinitramfs failure zstd -q -1 -T0 25
update-initramfs: failed for /boot/initrd.img-5.15.0-105-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-5.15.0-105-generic (--configure):
 installed linux-image-5.15.0-105-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-5.15.0-105-generic
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11 (main/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11-icons-small (main/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11-icons-hidpi (main/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11 (restricted/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11-icons-small (restricted/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target DEP-11-icons-hidpi (restricted/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target CNF (restricted/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
W: Target CNF (restricted/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:40 and /etc/apt/sources.list:54
E: Sub-process /usr/bin/dpkg returned an error code (1)
user@user-HP-EliteBook-840-G3:~$ 

答案1

看看
$ dpkg -l | grep -E ^ii.*linux-image
是否打印了两行以上的行;如果是,则
$ sudo apt purge <full-text-from-second-column>
对数字最低的行进行操作。

最重要的是,您似乎在文件中至少有一个 COPY EXTRA 行:at /etc/apt/sources.list:40 and /etc/apt/sources.list:54
要摆脱它们,请执行
sudo nano /etc/apt/sources.list
并删除第二份副本,然后使用相同的名称保存文件(CTRL-O,Enter)。

之后重试sudo apt update && sudo apt upgrade

答案2

您的启动分区似乎已完全填满。您至少需要在该分区上腾出一些磁盘空间。

  1. 首先检查你正在运行哪个内核,以便不是意外删除了该内核。;-) 您可以通过输入以下命令来检查您的实际内核:
    uname -a

  2. 然后,您可以通过输入以下命令列出所有其他已安装的内核:
    dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'

  3. 我还会列出目录内容/boot
    cd /boot && ls -ahl
    应该有一些针对某些内核的符号链接。我还会避免删除其中一个。

  4. 现在您可以从步骤 2 中选择一个未使用的内核。使用以下命令将其删除:(列表中的名称
    sudo dpkg --remove <kernelname>
    在哪里)<kernelname>

  5. 现在您应该有一些可用空间可以运行:
    sudo apt autoclean && sudo apt autoremove

相关内容