From d0d2117de9235652566c2b32127d5d26f7fbd9c4 Mon Sep 17 00:00:00 2001 From: Massimiliano Adamo <maxadamo@gmail.com> Date: Tue, 2 Feb 2021 20:19:50 +0100 Subject: [PATCH] fix README --- .gitignore | 1 - README.txt | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 README.txt diff --git a/.gitignore b/.gitignore index 0b67c38..7c0337f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ etc/ usr/ -README.txt diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..3feec7f --- /dev/null +++ b/README.txt @@ -0,0 +1,99 @@ +Remove Unused Ubuntu Kernel + +Purge unused Ubuntu kernels + +Setup + +I’ll wait for better days to come and create a proper release process. +Meanwhile I use Git LFS to upload the package inside the deb/ directory. + +You can download the package and install it: + + sudo dpkg -i ubuntu-kernel-cleanup_<VERSION>_all.deb + +if the dependencies are not met: + + sudo apt -y -f install + +How it works + +Script usage + +you can run the script using --real-run to remove the packages or use +--dry-run to show which package would have been removed. + +Example: + + ubuntu-kernel-cleanup.py --real-run + +or + + ubuntu-kernel-cleanup.py --dry-run + +Configuration file + +The script will look for its configuration file in the following +locations: + +1. /etc/ubuntu-kernel-cleanup.ini +2. $HOME/.ubuntu-kernel-cleanup.ini + +if both files are available, the 2nd one will win. + +The file content looks as following: + + [ubuntu-kernel-cleanup] + # you can get a list package prefixes and suffixes using "apt-cache search" + + # number of kernels packages to keep + count = 2 + + # prefix comes after the version number + kernel_prefixes = linux-tools, linux-headers, linux-modules, linux-modules-extra, linux-image, linux-image-unsigned + + # suffix come before the version number + kernel_suffixes = generic, aws + +How the script removes the kernels + +1st case + +you have 4 kernels installed and you use (count = 1): + +- kernel1: it’s old, it’s the running kernel and you cannot uninstall + this one +- kernel2: old, intermediate kernel version, it can be uninstalled +- kernel3: old, intermediate kernel version, it can be uninstalled +- kernel4: the latest, it is also the running kernel and it will be + kept + +the script will remove kernel2 and kernel3 + +2nd case + +If the running kernel does not belong to the list of the latest kernels, +obtained with the option “count”, then count + 1 will be kept. + +For instance, if you use count = 2 with the following kernels installed: + +- kernel1: old, it can be uninstalled +- kernel2: old, intermediate, but running kernel and it will be kept +- kernel3: old, intermediate kernel version, it can be uninstalled +- kernel4: the latest, it will be kept +- kernel5: the latest, it will be kept + +the script will remove kernel1 and kernel3 + +3rd case + +You reboot and you are running the latest kernel. + +If you use count = 2, 2 kernels will be kept: + +- kernel1: old, it can be uninstalled +- kernel2: old, intermediate, it can be uninstalled +- kernel3: old, intermediate kernel version, it can be uninstalled +- kernel4: the latest, it will be kept +- kernel5: the latest, running kernel, it will be kept + +the script will remove kernel1, kernel2 and kernel3 -- GitLab