Score:3

Which kernel version to delete when low disk space on /boot?

pk flag

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?

Artur Meinild avatar
vn flag
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`.
pl flag
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.
Artur Meinild avatar
vn flag
I believe the solution is to take some good backups, and then try and resize your partitions - see below..
Artur Meinild avatar
vn flag
Does this answer your question? [How do I resize my /boot partition?](https://askubuntu.com/questions/280211/how-do-i-resize-my-boot-partition)
user535733 avatar
cn flag
`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.
B.Kocis avatar
pk flag
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.
Artur Meinild avatar
vn flag
@user535733 re: the use of `--purge` for kernels, please [see here](https://askubuntu.com/questions/1406581/why-does-ubuntu-not-clean-out-old-kernel-module-files-in-lib-modules-when-old). 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.
user535733 avatar
cn flag
@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.
Artur Meinild avatar
vn flag
@user535733 I'll look into it. Thanks!
Score:4
vn flag

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.

B.Kocis avatar
pk flag
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?
Artur Meinild avatar
vn flag
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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.