Skip to content

Dead simple script to remove "unused" kernels in Pop_OS!

License

Notifications You must be signed in to change notification settings

sigg3/clean_old_kernels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

clean_old_kernels

Dead simple script to remove (apt remove --purge) "unused" kernels in Pop_OS!

Usage: /bin/bash clean_kernels.sh

What does it do?

  1. Gets current kernel (uname -r)
  2. Searches for kernels installed in /boot
  3. Searches for symlinks named vmlinuz* in /boot
  4. apt remove --purge kernels that are not current or symlinks* (* unless PURGE set to 1. Then only current is reserved.)

Then it asks user for permission to purge the "unused" kernels from the system with apt.

Pop_OS symlinks current (vmlinuz) and previous kernel (vmlinuz.old).

User can create symlink of kernels they want to keep, e.g. sudo ln -s /boot/vmlinuz-5.13.0-7614-generic /boot/vmlinuz.keep.

Exit codes

0 ) Success

1 ) Too few or can't determine number of kernels

2 ) All installed kernels are reserved

3 ) User aborted

TODOs

  • Allow CLI args to control it. Args are: use_sudo, remove_all, no_prompts, keep
  • Implement keep, which is number of kernels to keep (e.g. 4) ./clean_kernels.sh keep=4
  • quiet mode (no_prompts, just goes aheads and deletes)

This is dumb

Yes. It's a dumb task I find myself googling once too often. So I created this script instead :)

Warning

clean_kernels.sh is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

About

Dead simple script to remove "unused" kernels in Pop_OS!

Topics

Resources

License

Stars

Watchers

Forks

Languages