---
title: 'sudo purge-old-kernels: Recover some disk space!'
description: If you have long-running Ubuntu systems (server or desktop), and you
  keep those systems up to date, you will, over time, accumulate a lot of Linux kernels.Canonical’s
  Ubuntu Kernel Team regularly (about once a month) provides kernel updates, patching
  s […]
url: https://canonical.com/blog/sudo-purge-old-kernels-recover-some-disk-space-2?format=md
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[Dustin Kirkland](https://canonical.com/blog/author/kirkland "More about Dustin Kirkland")

16 June 2016

# sudo purge-old-kernels: Recover some disk space!

[kernel](https://canonical.com/blog/tag/kernel)

---

Share the article

If you have long-running Ubuntu systems (server or desktop), and you keep those systems up to date, you will, over time, accumulate a lot of Linux kernels.

Canonical’s [Ubuntu Kernel Team](https://wiki.ubuntu.com/KernelTeam) regularly (about once a month) provides kernel updates, patching security issues, fixing bugs, and enabling new hardware drivers.  The [apt](http://manpg.es/apt) utility tries its best to remove unneeded packages, from time to time, but kernels are a little tricky, due to their version strings.

Over time, you might find your */boot* directory filled with *vmlinuz* kernels, consuming a considerable amount of disk space.  Sometimes, *sudo apt-get autoremove* will clean these up.  However, it doesn’t always work very well (especially if you install a version of Ubuntu that’s not yet released).

*What’s the safest way to clean these up?*  (This question has been asked numerous times, on the [UbuntuForums.org](http://ubuntuforums.org/showthread.php?t=2240697) and [AskUbuntu.com](http://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu).)

The definitive answer is:

```
sudo purge-old-kernels
```

You’ll already have the *purge-old-kernels* command in Ubuntu 16.04 LTS (and later), as part of the *byobu* package.  In earlier releases of Ubuntu, you might need to install *bikeshed*, you can grab it directly from *[Launchpad](http://bazaar.launchpad.net/~kirkland/byobu/trunk/view/head:/usr/bin/purge-old-kernels)* or *[Github](https://raw.githubusercontent.com/dustinkirkland/byobu/master/usr/bin/purge-old-kernels)*.

Here, for example, I’ll save almost 700MB of disk space, by removing kernels I no longer need:

```
$ sudo purge-old-kernels
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  linux-headers-4.4.0-10-generic* linux-headers-4.4.0-12-generic* linux-headers-4.4.0-15-generic* linux-headers-4.4.0-16-generic*
  linux-headers-4.4.0-17-generic* linux-headers-4.4.0-18-generic* linux-image-4.4.0-10-generic* linux-image-4.4.0-12-generic*
  linux-image-4.4.0-15-generic* linux-image-4.4.0-16-generic* linux-image-4.4.0-17-generic* linux-image-4.4.0-18-generic*
  linux-image-extra-4.4.0-17-generic* linux-image-extra-4.4.0-18-generic*
0 upgraded, 0 newly installed, 14 to remove and 196 not upgraded.
After this operation, 696 MB disk space will be freed.
Do you want to continue? [Y/n]
```

From the [manpage](http://manpg.es/purge-old-kernels):

> *purge-old-kernels will remove old kernel and header packages from the system, freeing disk space. It will never remove the currently running kernel. By default, it will keep at least the latest 2 kernels, but the user can override that value using the –keep parameter. Any additional parameters will be passed directly to [apt-get](http://manpages.ubuntu.com/manpages/xenial/en/man8/apt-get.8.html)(8).*

Full disclosure: I’m the author of the purge-old-kernels utility.

Original post

[Get in touch

Interested in running Ubuntu in your organization?](https://ubuntu.com/about/contact-us/form)

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

By submitting this form, I confirm that I have read and agree to [Canonical's Privacy Policy](https://canonical.com/legal/dataprivacy).

Sign up

## Share on

---

## Related posts

[### Mythbusting the scope of Livepatch protection](https://canonical.com/blog/mythbusting-the-scope-of-livepatch-protection)

The purpose of this article is to share the technical realities of security patching for the Linux kernel, and the intended scope of the Linux kernel’s livepatch capability....

[Rajan Patel](https://canonical.com/blog/author/rajanpatel927)

24 September 2025

[### Ubuntu 22.04 FIPS 140-3 modules available for preview](https://canonical.com/blog/ubuntu-22-04-fips-140-3-modules-available-for-preview)

Canonical has been working with our testing lab partner, atsec information security, to prepare the cryptographic modules in Ubuntu 22.04 LTS (Jammy Jellyfish) for...

[Henry Coggill](https://canonical.com/blog/author/henrycoggill)

7 December 2023

[### An overview of live kernel patching](https://canonical.com/blog/an-overview-of-live-kernel-patching)

Learn how Canonical improves security on Linux with live kernel patching. Track Livepatch activity over time in Landscape.

[Rajan Patel](https://canonical.com/blog/author/rajanpatel927)

28 February 2022

[### Low latency Linux for industrial embedded systems – Part III](https://canonical.com/blog/industrial-embedded-systems-iii)

Welcome to the concluding chapter of this three-part blog series on the low latency Linux kernel for industrial embedded systems. Each blog is standalone and can be read...

[Edoardo Barbieri](https://canonical.com/blog/author/edoardo-barbieri)

14 February 2022
