User Tools

This is an old revision of the document!


remove old debian kernels

source in #proxmox@irc.freenode.net

peetaur2> ssm2017: I wrote a script that cleans it up... debian and ubuntu always has that problem. Also I think newer ubuntu has a package to do it.
[2016-09-06 14:14:40]  ssm2017: you can simply rm the files in /boot that are for kernels you don't care about, then use apt-get to remove them properly
[2016-09-06 14:16:54]  FYI here's my script which you may test and use... maybe don't run without testing :)  https://bpaste.net/show/2a1351e92ed9 

#!/usr/bin/env bash

current=$(uname -r | grep -Eo "[0-9][0-9\.-]+[0-9]")
latest=$(dpkg -l linux-image* | awk '$1=="ii"{print $2}' | grep -Eo "[0-9][0-9\.-]+[0-9]" | sort -u | tail -n1)

# remove all kernels except the currently booted one, and the latest one
apt-get purge -y $(dpkg -l 'linux-image*' | grep -E "linux-image-[0-9\.-]+" | awk '$1 == "ii" {print $2}' | grep -vE "$current|$latest")

# remove all kernel headers packages except the currently booted one, and the latest one
apt-get purge -y $(dpkg -l 'linux-headers*' | grep -E "linux-headers-[0-9\.-]+" | awk '$1 == "ii" {print $2}' | grep -vE "$current|$latest")

alternative

apt-get remove $(dpkg -l | egrep  '^ii  (pve-)?kernel-' | awk '{print $2}' | grep -v `uname -r`)

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information