Once you have Fedora running for while you’ll gather a bunch of kernel updates on your harddrive – and it’s likely you’ll need none of the old ones anymore. So from time to time I tend to clean up and remove old kernel packages keeping only the two latest updates. This procedure involves checking for installed kernel packages and possible related packages and then removing them – but keep the current and running kernel (of course! 😉 ). Inspired by aptosid‘s and siduction‘s kernel-remover package I wanted an automated process. This resulted in a little script which until now seems to work fine. Don’t get me wrong, this is no big deal and it’s definitively not as sophisticated as the one from aptosid/siduction, but I don’t have to think anymore when trying to remove old kernel packages! 😉
What it does:
- check’s for installed kernel packages
- figures out the currently running kernel
- prompts to remove kernel packages skipping the currently running kernel
- if you opted to uninstall a kernel package it’ll be removed including dependent packages (i.e. kmod-nvidia for that specific kernel) and will also remove a kernel-devel package (and dependent packages) if installed
- needs to be run as root
- of course “yum“
- Fedora 🙂
- … or a Red Hat based distro (can be overridden with “-f” to force)
As root copy the script where ever you like. I’d recommend /usr/local/bin. Then run as root “kernel-remover.sh”.
If you find this useful and like to download this script, you may do so here (you’ll find a gpg signed md5sum within the tar archive. My key can be found here):
Download: kernel-remover (Updated to version 1.1 on May, 2nd 2012)
I’ve tested this script and it seems to work fine. It may work on other Red Hat based distros as well but I tested on Fedora 16 only. So, it *should* do no harm, but: as always you should know what you’re doing and I give no warranty what so ever! Use at your own risk!