Completely removing old kernels in Void Linux

I have been a happy Void Linux user for a long time now, but something has always been a little unclear to me.

Void Linux keeps old kernels around after installing a new kernel and this results in many kernels installed on your system. After a while this results in longer update times because of DKMS module updates.

Luckily Void comes with the handy vkpurge utility. But here's the thing: vkpurge only removes old kernels within a kernel series. If you have the kernel packages linux4.19 and linux5.1 installed on your system, you can only remove old kernels in both series with vkpurge. The linux4.19 and linux5.1 packages will not be removed. As a consequence, you keep on receiving updates for these packages, resulting in more old kernels.

So, how do you completely delete old kernel packages? Is there a special procedure?

The solution is quite simple!

Say you have removed all old kernels for the linux4.19 package with sudo vkpurge rm 4.19.* and you want to completely remove the kernel from your system, all you have to do is sudo xbps-remove -R linux4.19 linux4.19-headers.

This will remove all linux4.19 related packages and you will no longer receive updates for them. Be sure not to delete the kernel series you are currently using!