即使只安装了两个内核,/boot 上也没有剩余空间

即使只安装了两个内核,/boot 上也没有剩余空间

我已经安装了最新版本的 Ubuntu LTS 20.04.1,现在当我尝试安装更新时,软件更新程序会显示“可用空间不足”的消息。它还表明:

升级需要磁盘“/boot”上总共 243 M 的可用空间。请在“/boot”上至少释放 10.2 M 的额外磁盘空间。您可以使用“sudo apt autoremove”删除旧内核,也可以在 /etc/initramfs-tools/initramfs.conf 中设置 COMPRESS=xz 以减小 initramfs 的大小。

当前版本是 18.04 LTS 的更新版本,并非全新安装,因此我没有遇到此问题。我使用过sudo apt-get autoremove,但sudo apt-get clean无法运行软件更新程序。我也重新启动过,但没有任何效果。任何帮助都将不胜感激。

输出sudo apt autoremove

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded

输出ls -lah /boot

total 217M
drwxr-xr-x  5 root root 1.0K Dec  2 09:53 .
drwxr-xr-x 24 root root 4.0K Oct 20 07:08 ..
-rw-r--r--  1 root root 233K Oct 21 02:00 config-5.4.0-53-generic
-rw-r--r--  1 root root 233K Nov  5 09:03 config-5.4.0-54-generic
drwx------  3 root root 4.0K Dec 31  1969 efi
drwxr-xr-x  5 root root 1.0K Nov 24 07:39 grub
lrwxrwxrwx  1 root root   27 Nov 17 07:52 initrd.img -> initrd.img-5.4.0-54-generic
-rw-r--r--  1 root root  81M Nov 13 07:33 initrd.img-5.4.0-53-generic
-rw-r--r--  1 root root 103M Dec  2 09:53 initrd.img-5.4.0-54-generic
lrwxrwxrwx  1 root root   27 Nov 17 07:52 initrd.img.old -> initrd.img-5.4.0-53-generic
drwx------  2 root root  12K Nov 15  2018 lost+found
-rw-r--r--  1 root root 179K Aug 18 03:46 memtest86+.bin
-rw-r--r--  1 root root 181K Aug 18 03:46 memtest86+.elf
-rw-r--r--  1 root root 181K Aug 18 03:46 memtest86+_multiboot.bin
-rw-------  1 root root 4.6M Oct 21 02:00 System.map-5.4.0-53-generic
-rw-------  1 root root 4.6M Nov  5 09:03 System.map-5.4.0-54-generic
lrwxrwxrwx  1 root root   24 Nov 17 07:52 vmlinuz -> vmlinuz-5.4.0-54-generic
-rw-------  1 root root  12M Oct 21 02:01 vmlinuz-5.4.0-53-generic
-rw-------  1 root root  12M Nov  5 10:11 vmlinuz-5.4.0-54-generic
lrwxrwxrwx  1 root root   24 Nov 17 07:52 vmlinuz.old -> vmlinuz-5.4.0-53-generic

输出dpkg -l | grep linux-image

rc  linux-image-4.10.0-28-generic              4.10.0-28.32~16.04.2                                amd64        Linux kernel image for version 4.10.0 on 64 bit x86 SMP
rc  linux-image-4.15.0-101-generic             4.15.0-101.102                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-106-generic             4.15.0-106.107                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-108-generic             4.15.0-108.109                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-109-generic             4.15.0-109.110                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-111-generic             4.15.0-111.112                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-112-generic             4.15.0-112.113                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-115-generic             4.15.0-115.116                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-117-generic             4.15.0-117.118                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-118-generic             4.15.0-118.119                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-121-generic             4.15.0-121.123                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-122-generic             4.15.0-122.124                                      amd64        Signed kernel image generic
rc  linux-image-4.15.0-39-generic              4.15.0-39.42                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-42-generic              4.15.0-42.45                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-43-generic              4.15.0-43.46                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-44-generic              4.15.0-44.47                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-45-generic              4.15.0-45.48                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-46-generic              4.15.0-46.49                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-47-generic              4.15.0-47.50                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-48-generic              4.15.0-48.51                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-50-generic              4.15.0-50.54                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-51-generic              4.15.0-51.55                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-52-generic              4.15.0-52.56                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-54-generic              4.15.0-54.58                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-55-generic              4.15.0-55.60                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-58-generic              4.15.0-58.64                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-60-generic              4.15.0-60.67                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-62-generic              4.15.0-62.69                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-64-generic              4.15.0-64.73                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-65-generic              4.15.0-65.74                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-66-generic              4.15.0-66.75                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-69-generic              4.15.0-69.78                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-70-generic              4.15.0-70.79                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-72-generic              4.15.0-72.81                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-74-generic              4.15.0-74.84                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-76-generic              4.15.0-76.86                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-88-generic              4.15.0-88.88                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-91-generic              4.15.0-91.92                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-96-generic              4.15.0-96.97                                        amd64        Signed kernel image generic
rc  linux-image-4.15.0-99-generic              4.15.0-99.100                                       amd64        Signed kernel image generic
rc  linux-image-5.4.0-52-generic               5.4.0-52.57                                         amd64        Signed kernel image generic
ii  linux-image-5.4.0-53-generic               5.4.0-53.59                                         amd64        Signed kernel image generic
ii  linux-image-5.4.0-54-generic               5.4.0-54.60                                         amd64        Signed kernel image generic
ii  linux-image-generic                        5.4.0.54.57                                         amd64        Generic Linux kernel image

DWARD 的回答有效,使用后我终于可以使用软件更新程序了。我尝试了其他建议,但没有成功。

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e $(uname -r | cut -f1,2 -d"-") | grep -e '[0-9]' | xargs sudo apt-get -y purge

非常感谢大家。

答案1

看起来您从 18.04 LTS 版本安装继承的 /boot 分区相当小,而您的 initrd.img 文件相当大(奇怪的是,对于 54 版本来说,它要大得多),因此该分区无法容纳足够的内核。

我建议你安装我的linux 清除脚本来自这里然后运行

sudo linux-purge -k 0

清除 5.4.0-53 内核和所有多余的配置文件(以“rc”标记)。

然后按照建议将 /etc/initramfs-tools/initramfs.conf 配置中的 COMPRESS 设置更改为 COMPRESS=xz,尽管这会减慢新内核和可能其他一些软件包的安装速度。

之后再次运行软件更新程序以安装所有更新。如果您让软件更新程序或无人值守升级程序处理删除额外内核,那么希望将来新内核也能适合 /boot。

相关内容