3

Running on Ubuntu 20.04, low disk space on /boot error message came up while trying to update.

The upgrade needs a total of 228 M free space on disk '/boot'. Please free at least an additional 24,8 M of disk space on '/boot'.

in my /boot folder I have the following files:

/boot
total 460452
drwx------ 3 root root      4096 Jan  1  1970 efi
-rw-r--r-- 1 root root    184884 Aug 18  2020 memtest86+_multiboot.bin
-rw-r--r-- 1 root root    184380 Aug 18  2020 memtest86+.elf
-rw-r--r-- 1 root root    182704 Aug 18  2020 memtest86+.bin
drwx------ 2 root root     16384 Feb  2  2021 lost+found
-rw------- 1 root root   6219821 Jan  6 17:21 System.map-5.15.0-58-generic
-rw-r--r-- 1 root root    262181 Jan  6 17:21 config-5.15.0-58-generic
-rw------- 1 root root  11450528 Jan  6 17:21 vmlinuz-5.15.0-58-generic
-rw-r--r-- 1 root root 217500477 Jan 20 06:33 initrd.img-5.15.0-58-generic
-rw------- 1 root root   6221223 Jan 25 10:27 System.map-5.15.0-60-generic
-rw-r--r-- 1 root root    262215 Jan 25 10:27 config-5.15.0-60-generic
-rw------- 1 root root  11458344 Jan 25 10:29 vmlinuz-5.15.0-60-generic
lrwxrwxrwx 1 root root        25 Feb  9 06:53 vmlinuz.old -> vmlinuz-5.15.0-58-generic
lrwxrwxrwx 1 root root        25 Feb  9 06:53 vmlinuz -> vmlinuz-5.15.0-60-generic
lrwxrwxrwx 1 root root        28 Feb  9 06:53 initrd.img.old -> initrd.img-5.15.0-58-generic
lrwxrwxrwx 1 root root        28 Feb  9 06:53 initrd.img -> initrd.img-5.15.0-60-generic
-rw-r--r-- 1 root root 217514515 Feb  9 06:53 initrd.img-5.15.0-60-generic
drwxr-xr-x 4 root root      4096 Feb  9 06:54 grub

the command "uname -a" returns:

uname -a
Linux balazskocsis 5.15.0-60-generic #66~20.04.1-Ubuntu SMP Wed Jan 25 09:41:30 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

when I list out the dpkg packages I get:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
linux-generic-hwe-20.04
linux-headers-5.15.0-58-generic
linux-headers-5.8.0-63-generic
linux-headers-generic-hwe-20.04
linux-hwe-5.15-headers-5.15.0-58
linux-hwe-5.8-headers-5.8.0-63
linux-image-5.15.0-58-generic
linux-image-generic-hwe-20.04
linux-libc-dev:amd64
linux-modules-5.15.0-58-generic
linux-modules-extra-5.15.0-58-generic

I believe that I need to clean up with the purge command the kernel version 5-15.0-58:

sudo apt-get -y purge linux-modules-5.15.0-58-generic

but I am not really sure.

If I interpret this correctly:

lrwxrwxrwx 1 root root        25 Feb  9 06:53 vmlinuz.old -> vmlinuz-5.15.0-58-generic
lrwxrwxrwx 1 root root        25 Feb  9 06:53 vmlinuz -> vmlinuz-5.15.0-60-generic

the current version is the 5.15.0-60 and the ones with 5.15.0-58 can be removed.

Given the output of the /boot folder listing and the uname -a, would it be safe to remove the 5.15.0-58 version?

B.Kocis
  • 163
  • 1
    How much space is in your /boot? It seems you have created a bottleneck for yourself by restricting the space in /boot. A default Ubuntu installation share /boot with / so it doesn't run out of space. Also, you have the two latest kernels, which is also the default for Ubuntu (this is a safeguard so you can boot a previous kernel). To avoid problems, have at least 2GB space in /boot. – Artur Meinild Feb 14 '23 at 08:58
  • 1
    Older versions of the installer did make /boot separate and too small, in some instances. If you've upgraded a machine through a few releases, it's entirely plausible to have a small /boot by default. – popey Feb 14 '23 at 10:03
  • I believe the solution is to take some good backups, and then try and resize your partitions - see below.. – Artur Meinild Feb 14 '23 at 10:38
  • 2
  • purge seems misused -- there are no files in /etc to remove. The use of -y with any remove or purge command is unwise -- you are telling apt that it's okay to destroy your system without double-checking with you first. – user535733 Feb 14 '23 at 12:36
  • hi @Arthur Meinid, yes, I have this version for years now, and updated regularly. The boot size is the nominal 1GB, which is currently 71% full. The updates need only extra 28MB more of the free space for the installation. The resize of the boot is a good advice, but currently I am reluctant for such solution. Removing old kernels is much more appealing. I just wanted to know if one of those kernel versions (old) is safe to purge. – B.Kocis Feb 14 '23 at 12:51
  • @user535733 re: the use of --purge for kernels, please see here. Old kernels leave a good amount of module files left (up to 3-4 MB per old kernel) if --purge is not used - just FYI. – Artur Meinild Feb 14 '23 at 13:12
  • 1
    @ArturMeinild, consider raising the /lib/modules issue in Discourse -- it might be an unreported bug; I've never seen any developer traffic about it. Thanks for enlightening. – user535733 Feb 14 '23 at 13:20
  • @user535733 I'll look into it. Thanks! – Artur Meinild Feb 14 '23 at 13:24

1 Answers1

4

If you're sure that the kernel version 5.15.0-60 is working properly, then yes you can remove kernel version 5-15.0-58.

On my system, the following files are automatically removed for old kernels:

linux-modules-extra-5.15.0-xx-generic
linux-modules-5.15.0-xx-generic
linux-image-5.15.0-xx-generic
linux-headers-5.15.0-xx-generic
linux-headers-5.15.0-xx

So you could run:

sudo apt remove --purge linux-modules-extra-5.15.0-58-generic linux-modules-5.15.0-58-generic linux-image-5.15.0-58-generic linux-headers-5.15.0-58-generic linux-headers-5.15.0-58

However, be advised that by doing this, you're removing the safety net of having a backup kernel installed (the previous one), and will only have one working kernel on the system.

In the long run, it would be much more advisable to expand your /boot partition, so Ubuntu can run normally with 2 working kernels installed.

Artur Meinild
  • 26,018
  • Thanks for the answer. So in case one would have temporarily only one kernel, would a new kernel version by added after an update or an upgrade? i.e. when would a new kernel version come out, so a new "safety-net" could be generated? – B.Kocis Feb 14 '23 at 14:12
  • 1
    Yes. But this situation would likely repeat itself, in that each time a new kernel was released, you first had to remove the previous one before you could upgrade. But it's perfectly possible to do. – Artur Meinild Feb 14 '23 at 14:48