Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.
/ ubuntu-purge-kernels Public archive

Remove all but the running and two installed installed kernels for an Ubuntu server

License

Notifications You must be signed in to change notification settings

EvanK/ubuntu-purge-kernels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Why is this necessary?

In most cases, it isn't -- running apt-get autoremove should identify and remove old packages (including old kernels).

Then when is this necessary?

Ubuntu's package manager has to read from and write to the /boot directory in order to autoremove old kernels, and if there is insufficient space to do this, the package manager will fail with rather cryptic error messages.

The sure fire remedy is to carefully find and remove the old kernels by hand and then update the boot loader, as explained in this Stack Exchange post.

Instead, you can run the included python script (requires root or sudo permission). By default, it will short circuit unless the /boot directory is 75% or more full:

root@localhost# ./purge-kernels.py
$ df -k /boot

$ du -ks /boot

Boot partition is only 74% full

You can override this by passing a minimum percentage as an argument:

root@localhost# ./purge-kernels.py 50
$ df -k /boot

$ du -ks /boot

$ dpkg --list "linux-image*"

$ uname -r

Found: 3.13.0-57

Found: 3.13.0-58

Found: 3.13.0-59

$ ls -1 /boot/*-3.13.0-57-*

Removing:
/boot/abi-3.13.0-57-generic
/boot/config-3.13.0-57-generic
/boot/initrd.img-3.13.0-57-generic
/boot/System.map-3.13.0-57-generic
/boot/vmlinuz-3.13.0-57-generic

$ rm -rf /boot/*-3.13.0-57-*

$ update-grub

About

Remove all but the running and two installed installed kernels for an Ubuntu server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages