Not enough free disk space for Ubuntu software updater

Sometimes the Ubuntu software updater finds it doesn’t have enough temporary space to download and apply updates – you get a message like this:


And even running the “sudo apt-get clean” doesn’t help.

Usually it means that there are too many old kernels on the boot partition (and the boot partition by default is only about 200MB, so fills up pretty fast).

You can see that by running “df -h /boot”:

Filesystem Size Used Avail Use% Mounted on
/dev/sda2 237M 141M 84M 63% /boot

To clear old kernels off the system, you need to do this:

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

That gets a list of installed kernels, filters out the one you’re currently running, and then passes the rest of the list to apt-get for removal.

Then run df again, and you should see more space in the boot partition:

Filesystem Size Used Avail Use% Mounted on
/dev/sda2 237M 54M 171M 24% /boot

Now run the updater again, and should all work.


I think the dpkg command came from here originally :

And there’s similar at :

23 thoughts on “Not enough free disk space for Ubuntu software updater”

  1. I noticed that the formatting of the command to clear old kernels in the original post meant that it was losing some characters when copied – I’ve corrected it in the post, hopefully that’ll work better now..

  2. Thank you very much! Very nice command and exactly what I was looking for – I was about to do this by hand while not being entirely confident what was safe to remove, very grateful for your expertise and facility with sed.

  3. thanks so much. no one elses solutions worked for me except for yours. I was going without updates for 3 months b/c of this problem. so thanks again you are a champ!

  4. Huge thanks! I was about to dump xubuntu and crawl back to Win7. You have the only working solution I’ve found thus far.

  5. I only came across this answer after hours of trying to figure it out.

    In case anyone else is getting stuck, here’s what I did. Ran gksudo nautilus, then went into /boot folder and manually deleted all but the most recent of any files with the word “generic” in their title.

    It could be that the suggested solution of this thread achieves the same thing with more finesse. I simply don’t know enough about Ubuntu to be able to comment.

  6. Thanks for a plain English and easy-to-follow post. Worked perfectly for me.

    I was amazed that although Linux/Ubuntu has become so much more user-friendly we still have to resort to this command-line magic just to get updates to continue working.

    Why are old kernels allowed to hang around and fill up the boot partition? Surely this is a common problem that needs fixing otherwise Linux/Ubuntu will never be adopted en masse?

  7. Thank you very much for this, it fixed my problem! I am thankful for people who know a lot more about computers than I do.

  8. this worked for me for awhile, but eventually got the same error message. I found the above code works along with janitor on ubuntu tweak and apt-get autoremove.. at least for now. Thanks

  9. Thanks for this amazing answer. I had stopped updating for months, until I found your blog post. This is the only one that clearly explains the situation AND provides a no-brainer script to fix it.

  10. Thanks so much for posting this. Just what I was looking for. Freed 575mb in my boot directory. Went from 65 to 25% used.

  11. If the Ubuntu 16.04 LTS autoupdate has taken your system to the point that you get the notification that looks like :

    An error occurred, please run package manager from the right click menu or apt-get in a terminal to see what is wrong.
    The error message was : ‘Error : BrokenCount > 0’. This usually means that your installed packages have unmet dependencies.

    When I run the command you recommend I get the following results :

    root@host:~# 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
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    You might want to run ‘apt-get -f install’ to correct these:
    The following packages have unmet dependencies:
    linux-image-extra-4.4.0-87-generic : Depends: linux-image-4.4.0-87-generic but it is not going to be installed
    linux-image-generic : Depends: linux-image-4.4.0-87-generic but it is not going to be installed
    E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).

    Of course ‘apt-get -f install’ won’t run because the /boot partition is full…

    So, I guess it is off to randomly delete a few files manually from /boot to free up some space to allow apt-get to run…

    This experience is definitely indicating that Ubuntu is NOT for the Non-Technical Linux user…

    I was quite surprised that this problem with the /boot partition and Ubuntu Update has been around for so long…

    Thanks ! Sorry to dump… Guess if I caught it before the /boot partition filled up, this solution would have worked great.

    Would you suggest putting this command into a cron job that runs daily ?

  12. I’d, try the janitor. I’m running 16.04 and no longer have this problem. I really think the occasional janitor and apt auto-remove helps to clear the boot. I’m no expert thou

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.