deKernel
A simple Command Line Tool to help with removing old/unused kernels.
(Especially when they have built up over time and are wasting disk space.)
Simple Instructions:
-
With RubyGems:
gem install dekernel-
dekernel(ordekernel --dry-runto tell apt-get to only pretend to make changes.) - Follow the directions! It will confirm with you before making any changes.
-
Without rubygems:
git clone git@github.com:snarlysodboxer/deKernel.gitcd deKernel-
./bin/dekernel(or./bin/dekernel --dry-runto tell apt-get to only pretend to make changes.) - Follow the directions! It will confirm with you before making any changes.
Command line Options:
-
-s,--dry-runPass the '--dry-run' option to apt-get. This option can be used in combination with any of the other commands. -
-y,--assume-yesPass the --assume-yes option to apt-get. This option can be used in combination with any of the other commands. -
-n,--no-confirmSkip the "Are you sure?" step. Useful for scripting. Use this with caution. This option can be used in combination with any of the other commands. -
-x,--all-except NUMBERPass the number of latest kernels to leave installed, the rest are marked for removal. -
-k,--kernels-list 'LIST'Pass a quoted, space separated list of kernel numbers to be removed. I.E.--kernels-list '3.2.0-8 3.2.0-11'. This option is ignored if you pass the--all-exceptoption.
A few more advanced examples:
-
dekernel -x 3to auto-mark all but the latest three kernels. The marked kernels will be displayed and you will still be asked to confirm. -
dekernel -x 3 -y -n -sto simulate removing all but the three latest kernels without any confirmation. Remove the-sto actually use this command inside you're own program without user feedback. -
dekernel -k '3.2.0-11 3.2.0-8' -y -nto remove the '3.2.0-11' and '3.2.0-8' kernels without confirmation. Again, you could use this command inside you're own program without user feedback.
Notes:
- This is currently only tested on Ubuntu systems. I welcome pull requests to make it compatible with other releases.
- This code essentially automates three commands for you:
- We
ls /bootto gather a list of presentvmlinuzkernels. - We use
dpkg-query -f '${Package}\n' -W *[pass in each present kernel]*to find which installed packages belong to those present kernels. - We use
sudo apt-get purge [packages list]to remove those packages.
- We