174

I'm getting an error in software updater when I try and do my daily updates. it says:

The upgrade needs a total of 25.3 M free space on disk `/boot`.
Please free at least an additional 25.3 M of disk space on `/boot`.
Empty your trash and remove temporary packages of former installations 
using `sudo apt-get clean`.

I tried typing in sudo apt-get clean into the Terminal but I still get the message. All of the pages I read seem to be for experienced Ubuntuers. I'm running Ubuntu 12.10. I want to upgrade to 13.04 but understand I have to finish these first.

This is the output from typing in cat /etc/fstab into the Terminal:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=fa55c082-112d-4b10-bcf3-e7ffec6cebbc /boot           ext2    defaults        0       2
/dev/mapper/ubuntu-swap_1 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
matty@matty-G41M-ES2L:~$ 

Output of df -h:

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu-root  915G   27G  842G   4% /
udev                     984M  4.0K  984M   1% /dev
tmpfs                    397M  1.1M  396M   1% /run
none                     5.0M     0  5.0M   0% /run/lock
none                     992M  1.8M  990M   1% /run/shm
none                     100M   52K  100M   1% /run/user
/dev/sda1                228M  222M     0 100% /boot
matty@matty-G41M-ES2L:~$ 

And dpkg -l | grep linux-image gives:

ii linux-image-3.5.0-17-generic 3.5.0-17.28 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
ii linux-image-3.5.0-18-generic 3.5.0-18.29 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
ii linux-image-3.5.0-19-generic 3.5.0-19.30 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
ii linux-image-3.5.0-21-generic 3.5.0-21.32 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
ii linux-image-3.5.0-22-generic 3.5.0-22.34 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
ii linux-image-3.5.0-23-generic 3.5.0-23.35 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
ii linux-image-3.5.0-24-generic 3.5.0-24.37 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
ii linux-image-3.5.0-25-generic 3.5.0-25.39 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
ii linux-image-3.5.0-26-generic 3.5.0-26.42 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
iF linux-image-3.5.0-28-generic 3.5.0-28.48 i386 Linux kernel image for version 3.5.0 on 32 bit x86 SMP
12
  • 1
    Also, the contents of your /etc/fstab might be helpful. What it seems like is that /boot is mounted on a separate partition.
    – Chuck R
    May 22, 2013 at 5:37
  • 1
    Like says @Githlar your fstab can give us information about your hd partitions.
    – ssoto
    May 22, 2013 at 7:11
  • 1
    fstab is a file that contains information on the partitions that are mounted when you boot up your computer. To show the contents of this file, type cat /etc/fstab in a terminal. Copy the output and add it to your question (you can edit your question). Also, copy the output of df -h and dpkg -l | grep linux-image.
    – Alaa Ali
    May 23, 2013 at 5:38
  • 1
    Your problem is all the extra linux-image... files in the /boot partition using up space - you only have 6MB free on the partition. sudo dpkg -P purge 'older_linux_image_filename' to remove all but the latest versions = 3.5.0-28.48 and 3.5.0-26.42 This should allow you to update/upgrade.
    – douggro
    May 23, 2013 at 6:57
  • 3
    I just had to run sudo apt-get autoremove to fix this.
    – Juampy NR
    Mar 1, 2016 at 10:07

10 Answers 10

235

Note: this answer is meant to be more of an 'explanation' than providing the best/easiest way to remove old kernels. For the best/easiest way to remove old kernels, please review the other answers.

Okay, so from the output of /etc/fstab you posted, it seems that your /boot is mounted on a separate partition, and from the output of df -h, that partition is full. This is because there are old kernels installed that are not needed; you can tell that by looking at the output of dpkg -l | grep linux-image that you posted, where you can see more than one "linux-image" with different versions. We need to remove the old versions.

First, I want you to run the command uname -r in a terminal, this will show you the kernel version you are currently using. We never want to remove that kernel version. The command will say something like this 3.5.0-26-generic. Take a note of that number, 26! The following commands will assume that that's the kernel you're running.

The command to remove an old kernel version is:

sudo apt-get purge linux-image-x.x.x-xx-generic

...where the x characters are numbers. So, in your case, because you have a lot of old versions (17, 18, 19, etc...), we would have to run this command for each of the versions, like this:

  • sudo apt-get purge linux-image-3.5.0-17-generic
  • sudo apt-get purge linux-image-3.5.0-18-generic
  • sudo apt-get purge linux-image-3.5.0-19-generic

...and so on. But, there's a way to do all of this through one command. The command is this (DO NOT RUN THE COMMAND YET! Read the following. ):

sudo apt-get purge linux-image-3.5.0-{17,18,19,21,22,23,24}-generic

This command will remove the versions mentioned in the brackets. I didn't include versions 25, 26 and 28 because of the following reasons:

  • Didn't include 26 obviously because that is the kernel version you are currently running! That's the version we got from the command uname -r, remember? We never want to remove that!
  • Didn't include 28 because that's the one that your upgrade was trying to upgrade to (you can tell that from the iF status next it, meaning that it's "half configured").
  • Didn't include 25 because it is usually good practice to leave at least one old version. So since you're running 26, we'll keep 25, so we won't include it in the command above.

So if the last number in uname -r is 26 (or 28, or even 25), then it's safe to run the above command. Enter your password when prompted, and type y when asked. This will show a bunch of lines, and will eventually go back to the command prompt (in your case, matty@matty-G41M-ES2L:~$), hopefully without errors. When it's done, do df -h and look at the last line, the one that starts with /dev/sda1. You should find that it now has more space, and that the percentage used is less than 100% like it was before. You can now proceed with your update again.

18
  • 1
    It worked!!! Thanks so much! Bonus question: when I first dowloaded Ubuntu, I accidentaly deleted the "pictures" folder in home area. Becasue of this, there's no "pictures" tab on the side. I've gotten around this by just creating a folder called "pictures" but it doesn't show up in the side bar. Do you know how to get it there? I tried clicking and dragging, but to no avail. @Alaa
    – carmatt95
    May 24, 2013 at 3:30
  • 3
    You're welcome! For the other question, create another question and I'll answer it. This way, people that are searching for that problem can find it.
    – Alaa Ali
    May 24, 2013 at 14:22
  • 16
    I wish I could upvote this every time I come back to reference it... it'd have a lot by now. Feb 24, 2014 at 1:41
  • 4
    yep, back here again to reference the same thing. You'd think I would remember it by now. Jul 18, 2014 at 1:33
  • 5
    A more concise command to purge all old kernels is: sudo apt-get autoremove --purge
    – ctrueden
    Jul 29, 2016 at 14:28
41

You can install Ubuntu-Tweak.To install follow the following steps:

Open the terminal. Add the required repository with the command:

sudo add-apt-repository ppa:tualatrix/ppa

Update the software list with the command:

sudo apt-get update

Finally, install Ubuntu Teak with the command:

sudo apt-get install ubuntu-tweak

After that, open dash and type "ubuntu tweak".

And then go to janitor tab and select Apps , Personal and System check boxes and click clean button at bottom right.

6
  • 9
    Much better than messing with command line and trying to delete all kernels but not current when they have even different versions (not only -32 at the end) and also -extra packets. Ubuntu tweak saved me 5 minutes, thanks!
    – POMATu
    Sep 27, 2014 at 21:29
  • Much more convenient. Oct 29, 2014 at 18:39
  • I Couldn't add the PPA but, I downloaded the .deb from the proyect's website ubuntu-tweak.com
    – Luigi Siri
    Oct 30, 2014 at 13:06
  • no need to add PPA on ubuntu 14.04
    – Alex Jones
    Dec 17, 2014 at 16:13
  • 1
    @edwardtorvalds Of course you can install it without adding its PPA on 14.04 and also 14.10 by its .deb package, but it's not the most preferable. The reason that you want to install that via its PPA is because it ensures updates. Dec 17, 2014 at 18:16
25

A quick way to remove all unused kernels and headers (excluding the current running kernel) has been pointed out by @Lekensteyn in his answer to the question How do I free up more space in /boot?:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')") 

This should free up enough space for you to upgrade.

8

There is a bug report on the issue here: https://bugs.launchpad.net/ubuntu/+source/update-manager/+bug/1183692

Feel free to tell if "this bug affects you too", so that it might get more attention.

2
  • And if you're not sure how to indicate "this bug affects me too", since it's not very obvious, see my answer here: askubuntu.com/questions/521105/…. Feb 7, 2022 at 8:43
  • This bug has been marked as a duplicate. And the other bug report has been closed as fixed.
    – Flimm
    May 26, 2022 at 8:38
6

On my home Ubuntu system I follow a similar method to that posted, but it's a little simpler and clears more space inc kernel headers, etc.

  1. I check what running kernel I'm using as it is imperative not to interfere with that.

    uname -a
    
  2. Then, I look at /boot with the aim of removing all kernel related files that are not related directly to the running kernel. This gives me a list of all the kernel versions I want to remove, for example: 3.5.0-17, 3.5.0-18

    ls -l /boot
    
  3. Now I take the first kernel version in my purge list and find all the packages related to it.

    dpkg -l | grep 3.5.0-17
    
  4. Purge them from the system

    sudo apt-get purge <list of packages separated by spaces>
    
  5. go back to 3 and select the next kernel version in my purge list.

  6. Done

1

I was getting this error, this article helped.

I used df -h to identify that boot was full, uname -r for version, then used the purge string listed above to remove old kernels. single kernel purge worked, multi did not (for me).

I found the files in the windows thing; I could not delete them, had to use the terminal, but it did show me the old versions I had in there.

I have no idea why /boot (sda2) is partitioned at all and why its so small. but now I can use Ubuntu updater again.

I did have some minor success with sudo apt-get update,sudo apt-get upgrade, sudo apt-get clean, also tried free software Bleachbit. Use the purge string but not on your current version. Hope this helps someone.

1
  • edit: i don't think you have to add"-generic" to the purge string
    – Brian P
    Aug 13, 2014 at 2:55
1

The answer of marianoju really helped, except that I got an error using apt purge. I couldn't find a force option.

Combining the lower level dpkg allowed me to proceed:

sudo dpkg -r $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' \
               | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
1
  • Excellent! I had to add modules-extra to end up with {image,headers,modules-extra} for more recent versions of Ubuntu :) Oct 22, 2023 at 23:40
0

Do you have any old kernel image packages installed, which aren't being used? Those can take up space on /boot. I'd recommend reviewing the set of installed kernel packages with a command such as the following:

dpkg -l "linux-image*" | grep "^i"

That should provide an overview of the set of kernel image packages installed. For those linux-image packages that are not being used and that would not be expected to be needed for recovery purposes -- for example, e.g. I like to keep at least one kernel version behind the active version installed, for recovery -- otherwise, you could remove any such unused packages, using your favorite packaging tool, such as aptitude.

I'd also recommend taking a look at the related inux-headers, linux-image-extras (if applicable), also linux-source, and linux-tools packages, such that may be installed together with any unused linux-image packages.

0

I doubt many, if any, people will run into this issue but I'm putting it up here for documentation in case anyone needs it.

My issue is that I was compiling different custom kernels until I ran out of space. The way I had to clean up the space was to enter each kernel directory I had been working in and run a sudo make clean.

  • $ cd /usr/src Directory where kernel source is
  • $ cd linux-image-custom_kernel_name
  • $ sudo make clean
0

You can try with below command to remove old kernel image packages if you are having those things.

sudo apt autoremove

After that you can able to do update

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .