How can I clean up the old Linux kernel

I often update my computer, and then it has many version kernels. How can i clean up the old Linux kernel?

The kernels should overwrite each other. Where are you seeing the kernel versions.

What is the output of pacman -Q | grep "^linux"

1 Like
 pacman -Q | grep "^linux"
linux 5.18.6.arch1-1
linux-api-headers 5.17.5-2
linux-firmware 20220610.7b71b75-1
linux-firmware-whence 20220610.7b71b75-1
linux-headers 5.18.6.arch1-1
linux-zen 5.18.6.zen1-1
linux-zen-headers 5.18.6.zen1-1

But when I start up my computer, I can see that there are many versions of kernel to choose.

You have two kernels:

  1. linux kernel and kernel headers
  2. linux-zen kernel and kernel headers

Which one do you want to keep? You can remove the other using

sudo pacman -Rs <kernel-name>  <kernel-header-name>
1 Like

Where do you see lots of kernel versions? In grub?

Thank you all, I love endeavourOS !
It is simpler than arch Linux and faster than manjaro!
This forum has a lot of enthusiastic people!

yes, I can see a lot of options in grub.

Does running sudo grub-mkconfig -o /boot/grub/grub.cfg fix it?

1 Like

The answer here marked as the solution is misleading.

It does not remove any “old Linux kernels”, it removes the current version of a package installed (which is the only one that exists on the system).

1 Like

step 1:
list all of linux kernels:

pacman -Q | grep "^linux"

step 2:
select it and remove it:

sudo pacman -Rs <kernel-name>  <kernel-header-name>

but you have to keep a linux kernel.

The thing is that in Arch (-based) systems, there are no “old kernels” to be cleaned up.
What you have installed are only the latest versions of some kernel “types” if you so will.
See >> https://wiki.archlinux.org/title/Kernel

So the title of the topic is somewhat erroneous. It should read instead some thing like:

How can I uninstall kernels (I don’t use)?

So you might want to consider editing the title of the topic to better reflect the issue at hand.

@Kresimir wants to say, that your approach isn’t the fix for the initial problem. You had multiple version entries inside GRUB, which should be removed by running the command @dalto shared.

You now removed a kernel and GRUB was most likely updated due to that. The solution you are providing is removing kernels, not removing multiple version entries in GRUB.

OK, i got it.
I’m sorry , because I used linux mint before, It provides tools to clean up old kernels.
So I asked a stupid question.

1 Like

No problem! It takes some time to find out and get used to how things are done in a different distro when they are actually done differently as in this case. In many other cases you will find much more similarities between different distros than what set them apart.

Yes, you are right.I think I’ll be using endeavouros Linux for a long time to come!!

2 Likes

No it’s not a stupid question. As @pebcak says things are little bit different around here. Apart from that you’ll find several underlying things like systemd etc. to be the same as mint.

1 Like

Sounds great!
Wish you the best of luck!
And don’t hesitate to ask the forum any questions or any doubts you might have.

:enos_flag: :handshake:t5:

I like this forum, thank you all.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.