Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ubuntu-kernel-cleanup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Massimiliano Adamo
ubuntu-kernel-cleanup
Commits
d0d2117d
Unverified
Commit
d0d2117d
authored
4 years ago
by
Max Adamo
Browse files
Options
Downloads
Patches
Plain Diff
fix README
parent
2d1d5ada
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+0
-1
0 additions, 1 deletion
.gitignore
README.txt
+99
-0
99 additions, 0 deletions
README.txt
with
99 additions
and
1 deletion
.gitignore
+
0
−
1
View file @
d0d2117d
etc/
usr/
README.txt
This diff is collapsed.
Click to expand it.
README.txt
0 → 100644
+
99
−
0
View file @
d0d2117d
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment