Is it safe to remove old kernels ?

chudak

Active Member
May 11, 2019
302
14
38
Just to make sure if I use the command line

dpkg -l | grep '^rc'| awk '{print $2}' | xargs sudo apt purge -y

is it safe to remove old kernels ?

I see now this list:

root@pve:~# dpkg -l | grep '^rc'| awk '{print $2}' pve-kernel-5.4.101-1-pve pve-kernel-5.4.60-1-pve pve-kernel-5.4.65-1-pve pve-kernel-5.4.73-1-pve pve-kernel-5.4.78-1-pve pve-kernel-5.4.78-2-pve pve-kernel-5.4.98-1-pve python
 
Yes, but a simple apt autoremove is the preferred method.
See below:

root@pve:~# apt autoremove Reading package lists... Done Building dependency tree... Done Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. root@pve:~# dpkg -l | grep '^rc'| awk '{print $2}' bsdmainutils pve-kernel-5.4.101-1-pve pve-kernel-5.4.103-1-pve pve-kernel-5.4.106-1-pve pve-kernel-5.4.114-1-pve pve-kernel-5.4.119-1-pve pve-kernel-5.4.60-1-pve pve-kernel-5.4.65-1-pve pve-kernel-5.4.73-1-pve pve-kernel-5.4.78-1-pve pve-kernel-5.4.78-2-pve pve-kernel-5.4.98-1-pve python

apt autoremove does not seem doing the same as other command !
 
If I remember right the pve package will prevent autoremove from removing the X latest kernels. But that is a wanted feature and not a bug because you might encounter problems and PVE isn't booting anymore. Then you can still boot from an older kernel already installed.
 
Last edited:
  • Like
Reactions: chudak
See below:


apt autoremove does not seem doing the same as other command !

Sorry, yes, that is correct. Technically, the kernels are already "removed" (the "r" in the dpkg status), but some local configuration remains (the "c" in the dpkg status). Therefore, it will be necessary to use apt purge to git rid of that.
 
What if
Code:
ls -l /boot

Shows that there are some old kernels, but
Code:
apt autoremove
doesn't remove them?
 
then you can remove them manually.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!