5

I would like to upgrade my Ubuntu from 22.04. to 24.04, however I am missing some more 10MB on the /boot partition.

I wanted to check what linux kernels are still installed in my system, as sudo apt autoremove had nothing left to remove.

And here comes my confusion: checking with dpkg -l | grep linux-image returns these kernels:

ii  linux-image-5.15.0-119-generic             5.15.0-119.129                                                       amd64        Signed kernel image generic
ii  linux-image-6.5.0-44-generic               6.5.0-44.44~22.04.1                                                  amd64        Signed kernel image generic
ii  linux-image-6.8.0-40-generic               6.8.0-40.40~22.04.3                                                  amd64        Signed kernel image generic
ii  linux-image-generic                        5.15.0.119.119                                                       amd64        Generic Linux kernel image
ii  linux-image-generic-hwe-22.04              6.8.0-40.40~22.04.3                                                  amd64        Generic Linux kernel image
ii  linux-image-unsigned-4.19.0-041900-generic 4.19.0-041900.201810221809                                           amd64        Linux kernel image for version 4.19.0 on 64 bit x86 SMP

Nice, seems like I could drop 5.15 and 4.19 at least...checking with uname -r I see 6.8.0-40-generic should be the current one. I would expect that prior kernel was 6.5.0-44-generic. However, checking with ls -l /boot I see this surprise:

total 522700
-rw-r--r-- 1 root root   1508678 Okt 23  2018 abi-4.19.0-041900-generic
-rw-r--r-- 1 root root    219610 Okt 23  2018 config-4.19.0-041900-generic
-rw-r--r-- 1 root root    262072 Aug  2 16:15 config-5.15.0-119-generic
-rw-r--r-- 1 root root    280697 Jun 18 15:18 config-6.5.0-44-generic
-rw-r--r-- 1 root root    287007 Jul 30 16:33 config-6.8.0-40-generic
drwxr-xr-x 3 root root     16384 Jan  1  1970 efi
drwxr-xr-x 5 root root      4096 Sep  9 16:16 grub
lrwxrwxrwx 1 root root        29 Aug 21 12:21 initrd.img -> initrd.img-5.15.0-119-generic
-rw-r--r-- 1 root root  76512349 Jun 21 10:34 initrd.img-4.19.0-041900-generic
-rw-r--r-- 1 root root 114952176 Aug 21 12:22 initrd.img-5.15.0-119-generic
-rw-r--r-- 1 root root 129903766 Aug 19 11:48 initrd.img-6.5.0-44-generic
-rw-r--r-- 1 root root 133025202 Aug 27 10:54 initrd.img-6.8.0-40-generic
lrwxrwxrwx 1 root root        27 Aug 21 12:21 initrd.img.old -> initrd.img-6.8.0-40-generic
drwx------ 2 root root     16384 Sep 28  2018 lost+found
-rw-r--r-- 1 root root    182800 Feb  6  2022 memtest86+.bin
-rw-r--r-- 1 root root    184476 Feb  6  2022 memtest86+.elf
-rw-r--r-- 1 root root    184980 Feb  6  2022 memtest86+_multiboot.bin
-rw-r--r-- 1 root root        17 Okt 23  2018 retpoline-4.19.0-041900-generic
-rw------- 1 root root   4324765 Okt 23  2018 System.map-4.19.0-041900-generic
-rw------- 1 root root   6289146 Aug  2 16:15 System.map-5.15.0-119-generic
-rw------- 1 root root   8269177 Jun 18 15:18 System.map-6.5.0-44-generic
-rw------- 1 root root   8654773 Jul 30 16:33 System.map-6.8.0-40-generic
lrwxrwxrwx 1 root root        26 Aug 21 12:21 vmlinuz -> vmlinuz-5.15.0-119-generic
-rw------- 1 root root   8603504 Okt 23  2018 vmlinuz-4.19.0-041900-generic
-rw------- 1 root root  11704712 Aug  2 16:43 vmlinuz-5.15.0-119-generic
-rw------- 1 root root  14263016 Jun 18 15:19 vmlinuz-6.5.0-44-generic
-rw------- 1 root root  14928264 Jul 30 17:17 vmlinuz-6.8.0-40-generic
lrwxrwxrwx 1 root root        24 Aug 21 12:21 vmlinuz.old -> vmlinuz-6.8.0-40-generic

Based on this, the vvmlinuz links to 5.15 and the 6.8.0 is linked to by vmlinuz.old. How is that possible?

Which information is correct? This is already after a fresh reboot.

And is it safe if I now drop (purge) at least all the kernel files for 4.19? That should free enough of disk space for distro upgrade...

Many thanks for your help!

shadyyx
  • 161

1 Answers1

5

Which information is correct? This is already after a fresh reboot.

If you're asking which kernel is currently running, then uname -r is always correct, because it asks the running kernel to report its own version.

The file name in /boot doesn't mean much, because you're booting through GRUB which has an (auto-generated) boot menu which may offer multiple kernels to boot from, and will order them by version rather than filename.

In fact, GRUB does not use the /boot/vmlinuz symlinks at all – its menu generator goes directly for the /boot/vmlinuz-*-generic files, so that it would be able to offer menu entries for all of them and not only the last two. This means that as soon as the 6.8.x kernel was installed, grub-mkconfig automatically chose 'vmlinuz-6.8.0-40-generic' as the "latest" kernel available.

You can see all of this either in /boot/grub/grub.cfg or by manually running grub-mkconfig and reading its output.

(That aside, many things are possible because the kernel doesn't actually look inside /boot during the boot process, as both vmlinuz & initrd are fully loaded into memory by the bootloader. So it's possible to boot kernels from other places besides /boot – or end up with situations where the bootloader and the /etc/fstab have different ideas as to what /boot is, so that "ls /boot" finds kernel A but GRUB finds kernel B. The latter is a common mixup with some DIY-like distros...)

And is it safe if I now drop (purge) at least all the kernel files for 4.19? That should free enough of disk space for distro upgrade...

Assuming that the current kernel works properly, you can safely remove all other kernels that you don't need (including even the 6.5.x if apt offers removing that).

In an emergency, the System.map files could be manually removed or gzipped to free up a few MB of space (the boot process doesn't need them, and any software which needs them – rare in itself – can use /proc/kallsyms for the currently-running kernel's symbols anyway).

grawity
  • 501,077