Why doesn't Ubuntu remove old kernels automatically?


My boot partition is on a SSD, so it doesn't have room for more than about 8 installed kernel versions, and eventually some kernel update will fail to install because my boot partition is full of old versions. There are many questions out there about how to remove old versions (even how to automate the process), but my question is simply this: Why doesn't apt-get autoremove detect and remove them automatically, and is there a way I can make it do so? I mean, apt-get is what installed them anyway, so it knows about them, so why does it choose to leave all old versions around?

As to answer why , refer to the file /etc/apt/apt.conf.d/01autoremove-kernels

As you can see, apt is told to never autoremove the kernels , as told by another (script) file, /etc/kernel/postinst.d/apt-auto-removal. And here it is:

If your script-fu is good enough you could edit it to save only couple kernels, though I can't help you there as my script fu isn't that...

0 0

LVM installs and encrypted installs use a separate /boot partition. The partition by default is capable of holding only four or five kernels, and can fill to capacity quickly. To prevent your /boot partition from getting full, you need to configure automatic removal of old kernels, or manually remove old kernels regularly.

Changing the kernel providing packages on your system requires commands with root access, so please read RootSudo.

Removing old kernels is easy to do on a system with sufficient free space in your root parition or separate boot partition. You can remove them manually, or configure unattended-upgrades to do it automatically. If you receive or have received an error from a package management tool, manual removal may not work until the problem is fixed. See Problems section.

Manual Maintenance

Using Apt

You can remove old kernels with a simple autoremove command in a terminal:

sudo apt-get autoremove --purge

Note: In...

0 0

Is there a reason why Ubuntu wont do this automatically?

I can see only 1 reason: it does not work flawlessly; there is no clean way to currently decide what the definition of "old kernels" is. "old" does not mean "unused" nor does it mean "unwanted". And any mistake in this will kill a users' machine.

So up to now the manual method is preferred since this puts the power of removing into the users' hands.

Resources for this conclusion:

Ubuntu WIKI: Proposal for removing old kernels

Last-good-boot is implemented fully in Intrepid/8.10 final, however it has been disabled because it was not considered stable enough. The setting is a single line in the file /etc/default/kernel-helper-rc.

Launchpad: Should aptitude provide a way to remove old kernel versions ?

apt-get has an autoremove feature that uninstalls all packages that are not needed as dependencies and have not been installed manually. Since Ubuntu 14.04 all obsolete kernels...

0 0
Thanks for your replies, I'm juggling some other problems at the minute so will look at this more again in the morning. Here's what I've found so far - although I started writing this response before the last couple of suggestions...

I've been doing some testing...

the test system is up to date with everything installed by apt-get update && apt-get upgrade (at the point I took the snapshot)
the output at this point is:


The following packages have been kept back: landscape-common linux-generic-pae linux-headers-generic-pae linux-image-generic-pae 0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.uname -r gives

I'm not sure why this is, as other servers have updated to 2.6.32-40 using only apt-get update and apt-get upgrade

if I run:


apt-get purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^...
0 0

For LVM, encrypted, or limited-storage systems, you need to regularly remove old kernels to prevent your computer (/boot partition) from running out of storage space.

Removing old kernels is easy. You can do it manually, or set unattended-upgrades to do it automatically. For details, open terminal from App Launcher or via Ctrl+Alt+T shortcut keys, and follow the steps below:

Remove Automatically Installed Kernels:

1. To remove the kernels that were automatically installed via regular system updates, open terminal and run:

sudo apt autoremove --purge

It will ask you to type in user password and then remove old kernels as well as other automatically installed packages that are no longer needed.

2. To enable automatic removing of old kernels:

Enable Kernel autoremoving may cause problems if your package management is broken, see

this bug


Run command to enable unattended upgrades. For Desktop Ubuntu 16.04, this...
0 0

After installing a new Linux kernel, old kernels are not automatically deleted. They remain in your disk (/boot partition). You have to delete them manually. Why?

The main reason is to save disk space, which occupied by old kernels. Some systems may become unusable if not enough disk space is available in /boot partition. However, disk space is not a problem in modern systems.

An other reason is to clean up Grub boot menu. In Ubuntu, Grub boot menu is hidden by default. You can display it by pressing "SHIFT" continuously at boot time. More details in this post.

You will never delete your current kernel, of course. It is recommended to keep at least one or two older kernels, so you can boot your system in an emergency situation (hardware or software compatibility issues with the current kernel).

After removing old kernels, new grub boot menu will be available in next reboot.

In a healthy Debian system, each time you install a...

0 0

Today, for the first time I encountered a strange behaviour on a machine with Ubuntu 15.10 . The problem itself was quite strange and rendered the machine unusable with default boot settings.

The problem

As I went to power up the machine this was the message when booting with default options. The user operating this machine had told me that he had

performed an update

prior to this problem. So I initially thought it was some kind of


with a newer kernel. So I went and use the precedent kernel, but nothing. And here the strange thing, I went and boot the third kernel in the list and

boom! It booted!

Now I decided to take a side trip to the solution and issued:

Everything went fine, however, I noticed the


was missing for some entries in the list. Then I tried listing files inside the boot partition and verified what I suspected: the initrd image for the last two kernels was nowhere to be found in the boot...

0 0

> On Wed, Oct 15, 2014 at 1:44 AM, Tom H

[hidden email]

> wrote:

>> On Mon, Oct 13, 2014 at 8:59 AM, Andrew Langhorn

[hidden email]

> wrote:


>>> Using sed, uname and apt, I am trying to ensure that all kernels older than

>>> the current and one behind are uninstalled from my machines. I keep the

>>> current one, for obvious reasons, and the previous kernel in case I need to

>>> roll back.


>>> To do this, I'm using `dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed

>>> "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' |

>>> xargs sudo apt-get -y purge`, which pipes the output of `uname -r ` to sed,

>>> ignores any lines beginning with `ii` to ensure installed kernels aren't

>>> removed, and applies that to the ouput of `dpkg -l 'linux-*`.


>>> This ensures that all previous kernels present are removed.


>>> Can I...

0 0

A while back I wrote a post on how to remove old kernels from your Ubuntu system. While that process works just fine, it is a four step process. One person who read that post left a comment with a nice command line one-liner that removes all but the currently running kernel. And while that one-liner works quite well, I must admit that I don't understand all the regular expressions used in it, so I decided to try and come up with my own one-liner to remove the old kernels from my system.

I'm going to take you through this step by step so you can see how the individual commands in this one-liner tie together. If you're impatient, you can skip to the end to see the final command.

Step 1) List all packages that start with "linux-"

We'll use the dpkg command with the -l switch to list the packages, whether installed or not, that start with the string linux-.

dpkg -l linux-*

Step 2) Filter that list to show only installed packages

To filter...

0 0

Question: I have upgraded the kernel on my Ubuntu many times in the past. Now I would like to uninstall unused old kernel images to save some disk space. What is the easiest way to uninstall earlier versions of the Linux kernel on Ubuntu?

In Ubuntu environment, there are several ways for the kernel to get upgraded. On Ubuntu desktop, Software Updater allows you to check for and update to the latest kernel on a daily basis. On Ubuntu server, the unattended-upgrades package takes care of upgrading the kernel automatically as part of important security updates. Otherwise, you can manually upgrade the kernel using apt-get or aptitude command.

Over time, this ongoing kernel upgrade will leave you with a number of unused old kernel images accumulated on your system, wasting disk space. Each kernel image and associated modules/header files occupy 200-400MB of disk space, and so wasted space from unused kernel images will quickly add up.

GRUB boot manager...

0 0

Delete old kernels in Ubuntu 16.04. Remove Ubuntu kernels you don’t need. Clean Ubuntu and remove old kernel versions. How to delete old Linux Kernels (purge-old-kernels). Terminal commands for Ubuntu to remove old Kernels automatically.

Purge Old Kernels

You can easily remove the old unused kernels, i.e. purge-old-kernels that have been automatically installed via regular Ubuntu system update. To purge-old-kernels run the following command in terminal:

sudo apt autoremove --purge
sudo purge-old-kernels

Enable Automatic Removal of Old & Unused Kernels

You can easily enable unattended upgrades using System Settings. To do so, open System Settings and navigate to Software & Updates > Updates Tab. Here, check the box for *-security (and/or any other repositories you wish) Automatically check for updates: Set to any frequency (except ‘Never’) When there are security updates: Set to Download and Install Automatically.

You can...

0 0

Suddenly, my Ubuntu update failed, and after checking my machine, I found that /boot partition is full, which caused this issue. I noticed that old kernel still exists in my system. In this mini post, your will find the answer for these question on Debian/Ubuntu Linux systems:

Why doesn’t Ubuntu remove old kernels automatically? How do I delete old unused kernel images to free disk space. How to remove unused old kernel images on Ubuntu Linux safely?

You need to delete and/or remove old kernels from system manually. Ubuntu and Debian based system keeps old kernel images so that system can be booted if newer kernel failed. The safest way to purge and remove old kernel is as follows. In this tutorial you will learn how to delete unused old kernel images on Ubuntu or Debian Linux to free disk space as well as the various state of linux-image package.


Boot into the newly installed kernel “the one you’ll keep”, and run the following command: $...
0 0

I update Ubuntu with a very simple script I call apt-update that looks like this:

$ cat ./apt-update sudo apt-get update; sudo apt-get dist-upgrade; sudo apt-get autoremove

Nothing too crazy there. It updates the apt-get cache, performs the upgrade, and then removes all the residual junk that’s laying around. Well, almost all. If you do this enough, eventually you’ll see the following (assuming you’ve got the default motd Ubuntu script running and you’re logging in from a terminal):

=> /boot is using 86.3% of 227MB

This is because that script I mentioned doesn’t consider old kernel images to be junk. However, unless you’ve got an abnormal /boot partition, it doesn’t take too many old images to fill it up.

A quick Google search found Ubuntu Cleanup: How to Remove All Unused Linux Kernel Headers, Images and Modules. The solution on the page had exactly what I’m looking for, however, I couldn’t take it at face value. While the article offers an adequate solution,...

0 0

I notice when i do system update which includes new kernel version, the new version gets installed but the old versions are not remove automatically. My grub list is getting longer by the update!! I have 2.6.32-38 to 2.6.32-45 now. The common practice I’m taught is to just leave 2 versions. The latest and greatest and another one which is the version prior to it. This avoids clutter as well as keep one backup in case the new one fails. So it is necessary to do a cleanup.

For the past few rounds of cleanups, I used the method found in Tux Tweaks. I found it useful and I customize it for myself. Here’s my step by step instruction. I list them down here for my own reference. Copy command and edit as necessary.

1. Check kernel version I am currently running. I want to keep this version as well as the older version as backup.

$ uname -r

2. List all available kernels in my system.

$ ls /boot | grep vmlinuz | cut -d’-‘ -f2,3


0 0

The Ubuntu community was informed by Dustin Kirkland, Ubuntu Product and Strategy at Canonical, about a simple method that helps the users to remove the old kernels from Ubuntu Linux, and thus frees up lot of disk space.

Ubuntu is basically a very good Operating system but the problem with is that it stores too many previous versions on the partition in which it was installed.When you have updated the OS for some times, you will eventually run out of space.

If you’re a starter, you will start wondering what’s going on, and asking questions like “Why’s my disk space disappearing?” same happens even if you are running Ubuntu in an SSD or an Hard disk (HDD).

If you are a long time Ubuntu user, you will know some tricks that you can to do from time to time, in the command-line, to remove these unwanted old kernels that APT package manager’s command “apt-get autoremove” usually fails to remove after installing new ones.

How to remove old kernels and free...

0 0

‘m a new Ubuntu Linux user and noticed that old kernel still exists in my system. Why doesn’t Ubuntu remove old kernels automatically? How do I delete old unused kernel images to free disk space. How to remove unused old kernel images on Ubuntu Linux safely?

You need to delete and/or remove old kernels from system manually. Ubuntu and Debian based system keeps old kernel images so that system can be booted if newer kernel failed. The safest way to purge and remove old kernel is as follows. In this tutorial you will learn how to delete unused old kernel images on Ubuntu or Debian Linux to free disk space as well as the various state of linux-image package.

Step #1: Boot into new kernel

First, boot into newly installed kernel. Verify this with the following command:
$ uname -mrs
$ uname -a
Sample outputs:

Linux server1 3.13.0-68-generic #111-Ubuntu SMP Fri Nov 6 18:17:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

To list all installed...

0 0

run uname -a to verify you are running the right kernel

sudo apt-get remove '.*2.6.31-14.*' sudo apt-get remove '.*2.6.31-19.*'

should do the trick... it will remove the kernel and any other related packages for that version. Give it a look over to make sure that only kernel related stuff matches before you enter 'y'.. I don't know of any packages that would have a version of 2.6.31-14 that are not kernel related, but it doesn't hurt to check.

I'd leave the previous kernel for a while until you are sure that the latest one is stable.


running apt-get clean will remove all of the old .debs you have on your system.

you can install debian-goodies and run dpigs to see what packages are the biggest.

justin@eee:~$ dpigs 111836 openoffice.org-core 88128 linux-image-2.6.31-19-generic 71556 linux-headers-2.6.31-19 48516 google-chrome-unstable 44848 openoffice.org-common 44044 wireshark-common 37776 libgl1-mesa-dri 33976 gimp-data 33012 smbclient...
0 0

Each time Ubuntu installs a new Linux kernel (upgrade), it leaves the old one installed. It means if you update/upgrade regularly, the Grub boot menu will be filled with all the Linux kernels you installed on your system, even those you no longer need. Btw, this is done purposely to make sure that you can boot to a previous kernel in case you have problems with the new installed kernel. However, if the new kernel works for you, you can uninstall and remove the older kernels to clean up the Grub boot menu. Today, I’m gonna show you how to remove old Ubuntu kernels.

In older versions of Ubuntu you can just open a terminal or hit Alt+F2 and type in this command: gksu gedit /boot/grub/menu.lst. The thing is, in newer versions of Ubuntu (9.4+) the menu.lst file was replaced by /boot/grub/grub.cfg which is a read-only file and is not supposed to be edited, making that solution obsolete.

The best and safest way to clean up the Grub boot menu is to use the Synaptic Package...

0 0

solved how to manually remove old kernels ubuntu

Get current kernel version
Start an LXTerminal session enter:

uname -r
This will report back something along the lines of 2.6.32-24-generic This is your current kernel, as you are advised to keep the most recent previous version, you will also want to keep 2.6.32-23-generic (The last digits are incremented on each release).

Remove old kernels
From your LXTerminal session enter:

dpkg -l | grep linux-image-
This will show the installed kernels. Each will have the 2.6.xx-yy numbers in them. For this tutorial I am going to assume that your system has 2.6.32-24-generic, 2.6.32-23-generic, 2.6.32-22-generic and 2.6.32-21-generic. (Obviously your system will be different). As you need to keep the current one (2.6.32-24-generic) and the most recent previous one (2.6.32-23-generic), you can remove 2.6.32-22-generic and...

0 0

I am very, very new to Linux. My son set it up, and is not available now. He had the kernals automatically updating, which eventually totally filled up /boot/. With the help of Experts I was able to delete older kernels and have working room in /boot/. I have a separate question posted to increase /boot/ to 500MB.

What I need is to arrange for new kernel updates to be installed, then the oldest image to be deleted. Right now I seem to have three images under /boot/, so if I automatically deleted the oldest I would always have three, which would be fine. This is a pure ubuntu 14.04 machine, no Windows, no dual boot.

I am very new, so please don't quote processes and procedures; I need exact command lines I can type...

0 0

The Ubuntu Kernel team will release new Kernel updates, bug fixes, and security patches every month. If you are a long-time Ubuntu user, and regularly updating your Ubuntu system, then it might be accumulated with lot of unused and old Kernels. So, there are chances that the /boot partition in your hard disk will run out of disk space over a period of time. If your /boot partition is full, you can’t upgrade the system or you can’t even upgrade your Kernel to any latest available version. This is no good, and it is very important to regularly update your Kernel and softwares. To do so, You should have enough free space in the /boot partition. This is why it is always a good practice to remove unused Kernels, unnecessary packages, dependencies, and system cache periodically. Keep in mind that in order to function Ubuntu system properly, you must have enough free space in /boot and /root partitions.

Of course, We can easily wipe out the system cache, unneeded packages and...

0 0

Without the Linux kernel, Ubuntu (and all the other Linux distros) would not exist. Despite this, most Linux users don’t know what a kernel is nor understand that the reason that Ubuntu is a Linux distro is because the kernel is Linux. All most users of any Linux distro is likely to know is that they will eventually have a large number of kernels installed on their system cluttering up their boot menu.

Describing what a kernel is and what it does is beyond the scope of this post. I do highly recommend that you first read the Wikipedia article on computer kernels followed by the article on the Linux kernel itself. I’d really like to do a post explaining what a kernel is in simple terms so that readers can gain a better appreciation for it and what it does for your distro. Please leave a comment letting me know if you are interested in this writeup.

Anyways, back to the topic at hand. What do we do with all these kernels that litter our boot menu? How do we remove them...

0 0

I've written a new POST that shows a one-Liner bash command that will remove the kernels from your Old System in one STEP. Co., Food Check it out here .
I wrote an article, shows a bash command line, teach you step delete your system with the old kernel. You can see here .

If you've been using Ubuntu Linux for a while, then you probably have a number of Linux kernel updates that have been installed on your system. (I've got a total of 3 kernels in my Karmic system already.) In all likelihood , these updates get installed and you boot into the latest kernel, never to use the older kernels again. But these old kernels are still hanging around on your system, cluttering up your grub boot screen and taking up space on your hard drive.
If you have been using for some time, Ubuntu Linux, then you might have when updating your system installed on several Linux kernel (in my Karmic version I have a total of three versions of the kernel). A strong possibility that these...

0 0

In our last article, we’ve explained how to delete old unused kernels in CentOS/RHEL/Fedora. In this article, we will explain how to delete old unused kernels in Debian and Ubuntu systems, but before moving further, you may want to install the latest version in order to take advantage of: security fixes, new kernel functions, updated drivers and so much more.

To upgrade your kernel to latest version in Ubuntu and Debian, follow this guide:

How to Upgrade Kernel to Latest Version in Ubuntu

Important: It is advisable to keep at least one or two old kernels to fall back to in case there is a problem with an update.

To find out the current version of Linux kernel running on your system, use the following command.

$ uname -sr Linux 4.12.0-041200-generic

To list all installed kernels on your system, issue this command.

$ dpkg -l | grep linux-image | awk '{print$2}' linux-image-4.12.0-041200-generic linux-image-4.8.0-22-generic...
0 0

There was a case when we have multiple, obsolete Linux Kernels exist on our Ubuntu system. In longer time, this can cause a problem when the /boot directory gets full. This tutorial will show you how to remove any old kernels using several methods.

To see the Linux Kernel on your system use this command


abi-4.4.0-22-generic config-4.4.0-36-generic initrd.img-4.4.0-42-generic System.map-4.4.0-72-generic
abi-4.4.0-31-generic config-4.4.0-38-generic initrd.img-4.4.0-47-generic System.map-4.4.0-75-generic
abi-4.4.0-34-generic config-4.4.0-42-generic initrd.img-4.4.0-51-generic vmlinuz-4.4.0-22-generic
abi-4.4.0-36-generic config-4.4.0-47-generic initrd.img-4.4.0-72-generic vmlinuz-4.4.0-31-generic
abi-4.4.0-38-generic config-4.4.0-51-generic lost+found vmlinuz-4.4.0-34-generic
abi-4.4.0-42-generic config-4.4.0-72-generic System.map-4.4.0-22-generic vmlinuz-4.4.0-36-generic
abi-4.4.0-47-generic config-4.4.0-75-generic...

0 0
EFI-Booting Ubuntu on a Mac

Originally written: 1/2011; Last Web page update: 6/17/2013 (last major update: 5/4/2012)

I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!

Note: This page is written using a rather elderly 32-bit Mac Mini as a reference, and using Ubuntu 12.04 as a reference. Developments in the last year have rendered certain of the procedures on this page sub-optimal. I've tried to point these out, but I haven't fully researched better replacements, and I lack the modern hardware on which to test some of the better methods on more recent 64-bit Macs. Thus, you may need to deviate from these instructions on modern computers.

The Problem

When installing...

0 0


Lately, Linux has been receiving quite a bit of notice. Between the ASUS EeePC, the One Laptop Per Child project, Dell’s new Ubuntu line, Intel’s Classmate PC, and Everex’s Green PC, Linux has been getting a lot of attention from computer manufacturers. It seems every new computer in the last year has had Linux, but to most people that doesn’t mean anything. It probably leaves you wondering, “what’s this Linux thing everyone’s talking about?”

So, what is this Linux thing?

Linux is an operating system, just like Windows and OSX are operating systems. It talks to the computer’s hardware, makes sure everything’s going OK, and then you run programs on top of it. Because it pretty much always comes with a standard set of tools (the GNU tools) which are very similar to the tools found on big UNIX systems, it is sometimes called GNU/Linux. If you’ve ever used a UNIX system, you’ll feel right at home.

When someone says they use Linux, what they...

0 0
XTerm – Frequently Asked Questions (FAQ)

Copyright © 1997-2016,2017 by Thomas E. Dickey

Here is the latest version of this file.

From the manual page:

The xterm program is a terminal emulator for the X Window System. It provides DEC VT102/VT220 and selected features from higher-level terminals such as VT320/VT420/VT520 (VTxxx). It also provides Tektronix 4014 emulation for programs that cannot use the window system directly. If the underlying operating system supports terminal resizing capabilities (for example, the SIGWINCH signal in systems derived from 4.3bsd), xterm will use the facilities to notify programs running in the window whenever it is resized.

That is, xterm (pronounced "eks-term") is a specific program, not a generic item. It is the standard X terminal emulator program.

This FAQ presents various useful bits of information for both the specific program as well as other...

0 0