apt autoremove 不会在启动时释放空间

apt autoremove 不会在启动时释放空间

在过去的几个月里,我偶尔会收到警告,说我的 ubuntu 20.04 上的启动分区磁盘空间不足。通常执行此操作sudo apt autoremove会释放空间,直到下次更新。

但在过去的几周中,该命令没有释放任何空间,并且我的启动分区上始终只有 26mb,这在更新时会出现错误。

以下是 apt autoremove 的输出

nocnoc@nocnoc-ThinkPad-T470p:~$ sudo apt autoremove
[sudo] password for nocnoc: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up initramfs-tools (0.136ubuntu6.6) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.6) ...
update-initramfs: Generating /boot/initrd.img-5.11.0-41-generic
W: Possible missing firmware /lib/firmware/i915/skl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/bxt_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/glk_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/cml_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/icl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/ehl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/ehl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/tgl_huc_7.5.0.bin for module i91
5
W: Possible missing firmware /lib/firmware/i915/tgl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/tgl_huc_7.5.0.bin for module i91
5
W: Possible missing firmware /lib/firmware/i915/tgl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/dg1_dmc_ver2_02.bin for module i
915
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.
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.11.0-41-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
E: Sub-process /usr/bin/dpkg returned an error code (1)

任何想法都将不胜感激,谢谢!

编辑:

我的笔记本电脑主分区有 20GB 可用空间,问题是 ubuntu 中的 /boot 分区太小,已满。所以我想知道如何使用 apt 来减少空间或增加 /boot 的大小

这是我的输出sudo apt -f install

nocnoc@nocnoc-ThinkPad-T470p:~$ sudo apt -f install
[sudo] password for nocnoc: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up initramfs-tools (0.136ubuntu6.6) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.6) ...
update-initramfs: Generating /boot/initrd.img-5.11.0-41-generic
W: Possible missing firmware /lib/firmware/i915/skl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/bxt_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/glk_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/cml_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/icl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/ehl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/ehl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/tgl_huc_7.5.0.bin for module i91
5
W: Possible missing firmware /lib/firmware/i915/tgl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/tgl_huc_7.5.0.bin for module i91
5
W: Possible missing firmware /lib/firmware/i915/tgl_guc_49.0.1.bin for module i9
15
W: Possible missing firmware /lib/firmware/i915/dg1_dmc_ver2_02.bin for module i
915
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.
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.11.0-41-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
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑2:

以下是 lsblk 的输出:

nocnoc@nocnoc-ThinkPad-T470p:~$ lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0           7:0    0  61.3M  1 loop  /snap/authy/6
loop1           7:1    0  61.5M  1 loop  /snap/authy/7
loop2           7:2    0     4K  1 loop  /snap/bare/5
loop3           7:3    0     9M  1 loop  /snap/canonical-livepatch/126
loop4           7:4    0  64.5M  1 loop  /snap/caprine/48
loop5           7:5    0  94.5M  1 loop  /snap/go/8779
loop6           7:6    0  64.5M  1 loop  /snap/caprine/47
loop7           7:7    0 147.9M  1 loop  /snap/chromium/1854
loop8           7:8    0 147.9M  1 loop  /snap/chromium/1845
loop9           7:9    0  99.4M  1 loop  /snap/core/11993
loop10          7:10   0 183.9M  1 loop  /snap/inkscape/9256
loop11          7:11   0  99.3M  1 loop  /snap/core/11743
loop12          7:12   0 467.5M  1 loop  /snap/goland/156
loop13          7:13   0  64.6M  1 loop  /snap/sublime-text/109
loop14          7:14   0  65.2M  1 loop  /snap/gtk-common-themes/1519
loop15          7:15   0     9M  1 loop  /snap/canonical-livepatch/119
loop16          7:16   0   219M  1 loop  /snap/gnome-3-34-1804/72
loop17          7:17   0 175.4M  1 loop  /snap/postman/132
loop18          7:18   0   3.3M  1 loop  /snap/shellcheck/1654
loop19          7:19   0 323.6M  1 loop  /snap/telegram-desktop/3455
loop20          7:20   0  60.3M  1 loop  /snap/pocket-casts/9
loop21          7:21   0 100.4M  1 loop  /snap/drawio/134
loop22          7:22   0 602.1M  1 loop  /snap/goland/163
loop23          7:23   0 242.4M  1 loop  /snap/gnome-3-38-2004/76
loop24          7:24   0 162.1M  1 loop  /snap/spotify/53
loop25          7:25   0  82.9M  1 loop  /snap/discord/130
loop26          7:26   0  66.5M  1 loop  /snap/citra-emu/144
loop27          7:27   0 176.9M  1 loop  /snap/krita/64
loop28          7:28   0 260.7M  1 loop  /snap/kde-frameworks-5-core18/32
loop29          7:29   0 162.9M  1 loop  /snap/gnome-3-28-1804/145
loop30          7:30   0 167.3M  1 loop  /snap/spotify/56
loop31          7:31   0 217.5M  1 loop  /snap/code/84
loop32          7:32   0    87M  1 loop  /snap/teams-for-linux/195
loop33          7:33   0 247.9M  1 loop  /snap/gnome-3-38-2004/87
loop34          7:34   0   3.2M  1 loop  /snap/shellcheck/1462
loop35          7:35   0  94.5M  1 loop  /snap/go/8839
loop36          7:36   0  64.7M  1 loop  /snap/sublime-text/110
loop37          7:37   0  54.2M  1 loop  /snap/snap-store/558
loop38          7:38   0   535M  1 loop  /snap/pycharm-professional/260
loop39          7:39   0 100.4M  1 loop  /snap/drawio/135
loop40          7:40   0 175.4M  1 loop  /snap/postman/133
loop41          7:41   0    51M  1 loop  /snap/snap-store/547
loop42          7:42   0  60.3M  1 loop  /snap/pocket-casts/10
loop43          7:43   0 517.7M  1 loop  /snap/nightmayr-kf5-qt-5-15-2-core20/20
loop44          7:44   0  77.2M  1 loop  /snap/discord/128
loop45          7:45   0 116.6M  1 loop  /snap/docker/1125
loop46          7:46   0 164.8M  1 loop  /snap/gnome-3-28-1804/161
loop47          7:47   0  55.5M  1 loop  /snap/core18/2253
loop48          7:48   0 122.4M  1 loop  /snap/fromscratch/4
loop49          7:49   0   362M  1 loop  /snap/obs-studio/1273
loop50          7:50   0 518.3M  1 loop  /snap/nightmayr-kf5-qt-5-15-2-core20/26
loop51          7:51   0    87M  1 loop  /snap/teams-for-linux/205
loop52          7:52   0  42.2M  1 loop  /snap/snapd/14066
loop53          7:53   0   4.2M  1 loop  /snap/tree/18
loop54          7:54   0  61.9M  1 loop  /snap/core20/1242
loop55          7:55   0 276.7M  1 loop  /snap/gimp/372
loop56          7:56   0 362.2M  1 loop  /snap/obs-studio/1276
loop57          7:57   0 131.6M  1 loop  /snap/docker/796
loop58          7:58   0   219M  1 loop  /snap/gnome-3-34-1804/77
loop59          7:59   0  43.3M  1 loop  /snap/snapd/14295
loop60          7:60   0  55.5M  1 loop  /snap/core18/2246
loop61          7:61   0 213.8M  1 loop  /snap/code/83
loop62          7:62   0  61.9M  1 loop  /snap/core20/1270
loop63          7:63   0   277M  1 loop  /snap/gimp/380
loop64          7:64   0 313.2M  1 loop  /snap/telegram-desktop/3343
loop65          7:65   0 184.8M  1 loop  /snap/inkscape/9090
loop66          7:66   0 264.8M  1 loop  /snap/citra-emu/143
loop67          7:67   0  65.1M  1 loop  /snap/gtk-common-themes/1515
loop68          7:68   0   8.1M  1 loop  /snap/pick-colour-picker/238
loop69          7:69   0 295.7M  1 loop  /snap/vlc/2344
loop70          7:70   0 669.7M  1 loop  /snap/pycharm-professional/265
nvme0n1       259:0    0 238.5G  0 disk  
├─nvme0n1p1   259:1    0   512M  0 part  /boot/efi
├─nvme0n1p2   259:2    0   732M  0 part  /boot
└─nvme0n1p3   259:3    0 237.3G  0 part  
  └─nvme0n1p3_crypt
              253:0    0 237.2G  0 crypt 
    ├─vgubuntu-root
    │         253:1    0 236.3G  0 lvm   /run/timeshift/backup
    └─vgubuntu-swap_1
              253:2    0   976M  0 lvm   [SWAP]

下面是 ls /boot/ 的输出

nocnoc@nocnoc-ThinkPad-T470p:~$ ls /boot
config-5.11.0-38-generic      memtest86+.bin
config-5.11.0-40-generic      memtest86+.elf
config-5.11.0-41-generic      memtest86+_multiboot.bin
config-5.4.0-91-generic       System.map-5.11.0-38-generic
efi                           System.map-5.11.0-40-generic
grub                          System.map-5.11.0-41-generic
initrd.img                    System.map-5.4.0-91-generic
initrd.img-5.11.0-38-generic  vmlinuz
initrd.img-5.11.0-40-generic  vmlinuz-5.11.0-38-generic
initrd.img-5.11.0-41-generic  vmlinuz-5.11.0-40-generic
initrd.img-5.4.0-91-generic   vmlinuz-5.11.0-41-generic
initrd.img.old                vmlinuz-5.4.0-91-generic
lost+found                    vmlinuz.old

答案1

答案是进入启动并手动删除旧内核,而不是依赖 apt autoremove。问题本质上是 apt 无法完成最新内核 (5.11.0-41) 的安装,因为空间不足,而 autoremove 不会删除旧内核 (5.11.0-38),直到安装最新内核。就我而言。

sudo apt remove 'linux*5.4.0-91*'

sudo apt remove 'linux*5.11.0-38*'

我在上面的命令中使用通配符(*),因为内核由 5 个包(标题、图像、模块)组成。

此命令还可能删除 linux-generic、linux-headers-generic 和 linux-image-generic。这是正常的,无需担心,因为您确实拥有这些软件包的 HWE 版本(软件包名称相同,但附加了 -hwe-20.04,这些软件包提供了您正在使用的 5.11 内核)。

完成所有操作后,您可能需要运行 sudo apt -f install 来完成 5.11.0-41 的安装。

相关内容