-
Notifications
You must be signed in to change notification settings - Fork 1
kernel_remove: init script to remove a specified kernel #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mainline
Are you sure you want to change the base?
Conversation
Could you add a check for making sure you're not deleting the running kernel? Additionally could you add an Entry to the ReadMe explaining this and the expected use case and limitations? Otherwise thanks this will be helpful for full systems or those that don't treat their VM's as disposable (i know this is important to some) |
32285f0
to
82c4907
Compare
Some extra documentation that I am not sure goes in the README. Trying to remove a kernel installed as an RPM$ uname -r
4.18.0-ciqlts8_6-83208b00c+
$ ls -alh /lib/modules/
total 16K
drwxr-xr-x. 6 root root 161 Jul 14 21:56 .
dr-xr-xr-x. 40 root root 4.0K Jul 14 17:59 ..
drwxr-xr-x. 6 root root 4.0K Jul 14 21:57 4.18.0-372.32.1.el8_6.86ciq_lts.12.1.x86_64
drwxr-xr-x. 6 root root 4.0K Jul 14 21:57 4.18.0-372.32.1.el8_6.x86_64
drwxr-xr-x. 3 root root 19 Jul 14 17:42 4.18.0-372.9.1.el8.x86_64
drwxr-xr-x. 3 root root 4.0K Jul 14 20:56 4.18.0-ciqlts8_6-83208b00c+
$ ./kernel_remove.sh 4.18.0-372.32.1.el8_6.86ciq_lts.12.1.x86_64
+ requested_kernel_to_remove=4.18.0-372.32.1.el8_6.86ciq_lts.12.1.x86_64
++ dnf repoquery --latest-limit=1 --queryformat '%{version}-%{release}' kernel-core
+ latest_rpm_kernel=4.18.0-372.32.1.el8_6.86ciq_lts.12.1
++ uname -r
+ current_kernel=4.18.0-ciqlts8_6-83208b00c+
+ '[' -z 4.18.0-372.32.1.el8_6.86ciq_lts.12.1.x86_64 ']'
+ '[' 4.18.0-372.32.1.el8_6.86ciq_lts.12.1.x86_64 == 4.18.0-372.32.1.el8_6.86ciq_lts.12.1 ']'
++ uname -m
+ '[' 4.18.0-372.32.1.el8_6.86ciq_lts.12.1.x86_64 == 4.18.0-372.32.1.el8_6.86ciq_lts.12.1.x86_64 ']'
+ echo 'ERROR: Will not remove the *latest kernel* installed as an RPM package'
ERROR: Will not remove the *latest kernel* installed as an RPM package
+ exit 1 Trying to remove the current kernel$ uname -r
4.18.0-ciqlts8_6-83208b00c+
$ ./kernel_remove.sh 4.18.0-ciqlts8_6-83208b00c+
+ requested_kernel_to_remove=4.18.0-ciqlts8_6-83208b00c+
++ dnf repoquery --latest-limit=1 --queryformat '%{version}-%{release}' kernel-core
+ latest_rpm_kernel=4.18.0-372.32.1.el8_6.86ciq_lts.12.1
++ uname -r
+ current_kernel=4.18.0-ciqlts8_6-83208b00c+
+ '[' -z 4.18.0-ciqlts8_6-83208b00c+ ']'
+ '[' 4.18.0-ciqlts8_6-83208b00c+ == 4.18.0-372.32.1.el8_6.86ciq_lts.12.1 ']'
++ uname -m
+ '[' 4.18.0-ciqlts8_6-83208b00c+ == 4.18.0-372.32.1.el8_6.86ciq_lts.12.1.x86_64 ']'
+ '[' 4.18.0-ciqlts8_6-83208b00c+ == 4.18.0-ciqlts8_6-83208b00c+ ']'
+ echo 'ERROR: Will not remove the current kernel'
ERROR: Will not remove the current kernel
+ exit 1 |
82c4907
to
3d2ed68
Compare
This script basically cleans up all the possible paths that might be populated from a `make modules_install` and `make install`. Given that the kernel is removed, the grub entry is also removed with the help of `grubby`. This is an ad-hoc script created to quickly remove a kernel without much fuss about it.
3d2ed68
to
7f763d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
A new Bash script to remove a specified kernel version by cleaning up its modules, boot files, and grub entry, along with documentation of its usage.
- Added
kernel_remove.sh
to automate removal of development and older RPM kernels - Updated
README.md
with a usage section and example trace output
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
kernel_remove.sh | New script to delete /lib/modules , /boot artifacts for a given kernel and update grub |
README.md | Documentation for kernel_remove.sh , including description of development kernels and example usage |
Comments suppressed due to low confidence (1)
README.md:84
- Add a note that this script requires sudo privileges to remove files and update grub entries, since it runs
sudo rm
andsudo grubby
commands.
### kernel_remove.sh
This script basically cleans up all the possible paths that might be populated from a
make modules_install
andmake install
. Given that the kernel is removed, the grub entry is also removed with the help ofgrubby
.This is an ad-hoc script created to quickly remove a kernel without much fuss about it.
The script only accepts the kernel version and is used like following:
And that's all. It will remove all installed files and even remove the grub entry.