I have a Void linux VM which only gets turned on once in every month. Today, when I booted up and updated the packages on this VM, I noticed that there are many old kernels installed. As a seasonal Void user, I had no clue on how to remove older kernels.

Fortunately, a quick Google search pointed me to a video: VOID Linux: Removing old kernels with vkpurge. Basically, Void comes with a pre-installed utility program called vkpurge. (man vkpurge for more info.)

Here is a demonstration on how this command is used:

[root@void ~]# vkpurge list
4.15.12_1
4.15.15_1
4.15.15_2
4.16.12_1
4.16.14_1
4.17.19_1
4.18.7_2
4.19.46_1
4.19.59_1
4.19.143_1
4.19.163_1
5.8.8_1

To remove all kernel with version 4.15, we can run:

[root@void ~]# vkpurge rm 4.15.*
...
[root@void ~]# vkpurge list
4.16.12_1
4.16.14_1
4.17.19_1
4.18.7_2
4.19.46_1
4.19.59_1
4.19.143_1
4.19.163_1
5.8.8_1

According to its manpage, we can also use this command to remove all kernels that are not currently loaded (i.e. removablae kernel).

Let’s try that.

[root@void ~]# vkpurge rm all
...
[root@void ~]# vkpurge list
[root@void ~]# 

I think this pretty cool. Does anyone know if Ubuntu or Fedora has similar command to clean up all removable kernel?