5

I have installed latest version Ubuntu LTS 20.04.1 and now when I try to install updates I get a message "not enough free space" from the Software Updater. It also indicates:

The upgrade needs a total of 243 M free space on disk '/boot'. Please free at least an additional 10.2 M of disk space on '/boot'. You can remove old kernels using 'sudo apt autoremove', and you could also set COMPRESS=xz in /etc/initramfs-tools/initramfs.conf to reduce the size of your initramfs.

This current version is a update version from 18.04 LTS and is not a clean install that I did not have this problem with. I have used sudo apt-get autoremove, and sudo apt-get clean with no luck in being able to run software updater. I have also rebooted and it did not make a difference. Any help would be appreciated.

Output of 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

Output of 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

Output of 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's answer worked and I am finally able to use Software Updater after using this. I did try the other suggestions without luck.

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

Thank you all so very much.

mook765
  • 15,925
bull
  • 65
  • 8
  • 2
    That was a bad idea ot have a separate /boot. – Pilot6 Dec 02 '20 at 18:29
  • Edit your question to show us the complete output of df and the complete output of ls -lah /boot and the complete output of dpkg -l | grep linux-image. – user535733 Dec 02 '20 at 19:18
  • user535733 Okay i have posted requested output. Hope this helps. Thanks. – bull Dec 03 '20 at 18:56
  • 3
    I think this question is a bit different from the claimed duplicate because in this case there are not many unused kernels (or related files), but only two kernels in /boot, so this question needs different answer. – jarno Dec 04 '20 at 13:38
  • DWARD suggestion worked for me when others did not. Thank you all. 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 – bull Dec 04 '20 at 15:39
  • 1
    Oh, if my answer did not work, then I would appreciate, if you tell what went wrong. Besides, the script you referred to may only work temporarily, because future kernel updates may fill the /boot partition again if no further actions are made. – jarno Dec 04 '20 at 16:10
  • JARNO thanks for your help also but using terminal is a challenge for me so I used a simpler solution. – bull Dec 04 '20 at 20:05
  • 1
    Well, the final command line is simpler and easier to remember in my solution, but of course you have to install the script first by running the command line given in the site. My script also has a bug tracker unlike some pipeline that has just been copied from somewhere. – jarno Dec 05 '20 at 14:08
  • 1
    So maybe, if you have to remove kernels again, you could try my solution. – jarno Dec 05 '20 at 14:10
  • JARNO You are correct that I was able to update software only a few times and then I got same error message, so I have decided to do a fresh install of 20.04.1 to see if that cures the problem. – bull Dec 12 '20 at 18:21
  • 1
    That is probably the best solution. – jarno Dec 15 '20 at 13:34
  • Search brought me here - in my situation I had only one kernel installed, so no extra. For me, sudo aptitude purge linux-headers-#.#.#-## completed successfully, installing the updated kernel by its conflict resolution. After that upgrade of initramfs-tools and linux-firmware showed errors about full /boot, but seems initrd.img had already been generated OK during the kernel upgrade (the system booted afterward). – Randall Whitman Jun 28 '22 at 04:23

1 Answers1

3

It seems that the /boot partition you inherited from 18.04 LTS release installation is rather small and your initrd.img files rather large (and oddly much larger for the 54 version), so the partition can not hold enough kernels as such.

I suggest you install my linux-purge script from here and run

sudo linux-purge -k 0

to purge the 5.4.0-53 kernel and all the excessive config files (marked by "rc").

Then change the COMPRESS setting to COMPRESS=xz in /etc/initramfs-tools/initramfs.conf configuration like suggested, though it will slow down installation of new kernels and possibly some other packages.

Thereafter run Software Updater again to install all updates. Hopefully then new kernels fit in /boot also in the future, if you let Software Updater or Unattended Upgrades handle removing extra kernels.

jarno
  • 5,600