Learning about OpenSuse Tumbleweed and Linux
I ran
zypper dist-upgrade
and the result is a bit surprising to me. It wants to remove the main kernel in use. Is it normal behavior ? I mainly use Yast but though would see what this command line would return.
The following 3 packages are going to be REMOVED:
kernel-default-5.14.14-1.1 kernel-default-devel-5.14.14-1.1 kernel-devel-5.14.14-1.1
Normally, it leaves the old kernel when a new one is installed. And cleanup occurs later.
However there is a special case, and I think that’s what you saw. You were using 5.14.14-1.1. But a new kernel (version 5.14.14-1.3, if I recall) was being installed. When just the last digit changes, this is usually a recompile of the same sources.
The reason this happens, is that although the kernel version is [FONT=monospace]5.14.14-1.1, file name for kernel and related files just uses [/FONT][FONT=monospace][FONT=monospace]5.14.14-1 (without the last “.1”). So you would then have two kernels with the same file name – one overwrites the other. And you would get a file conflict message. So zypper dup removes the previous kernel to avoid this issue.[/FONT]
[/FONT]
Yes, I agree with mrmazda that you should leave it to “zypper” to handle the kernel removal.
But I want to add that you should only use zypper dist-upgrade (or zypper dup) for updating Tumbleweed. Yast is likely to miss some of what “zypper” does.
How did you install? Normally, the “purge-kernels” service is enabled, and should automatically clean up the older kernels. But it is possible that it is not enabled for some people. There was a time when it was broken, but that was maybe a year ago.
[/noparse], not quotes, when posting computer output. Otherwise text you posted is not included in reply and it is impossible to comment it in context.
Anyway, rpm only removes directories when they are empty; so you have some files in all these directories that are not part of kernel rpm. You need to check these files.
what would be the simplest way to purge old kernels in /usr/lib/modules/ ?
If you look inside those “/usr/lib/modules” directories for older kernels, you will probably find that they are mostly empty.
I used to see that on an older computer with an Nvidia graphics card. The module used by the Nvidia driver does not come with the kernel. So when the kernel is removed, the corresponding “/usr/lib/modules” directory is not empty so not removed.
I also saw that back when my network card required a driver that did not come with the kernel.
The answer then – those old directories are not actually using much space. And you get to decide whether it is save to manually remove them.
They are taking some space on my disk. The reason is I need to optimize my disk space as much as I can.
If something is not of use, it needs to be removed.
From what I gather, they weren’t removed because not empty ? Looks like I am going to have to use the ‘rm’ command which I do not like very much as it nukes everything. As a user (not an admin or IT guy) I did make mistakes removing stuff I should not have Learnt the hard way that the ‘rm’ command has no mercy