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 :

21 Replies to “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. Much grass! It worked flawlessly, especially appreciated after minimal results from other suggested solutions.

  7. 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?

  8. 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.

  9. I agree with Barnaby Knowles that there should be an automatic way of clearing space in the boot partition when a kernel upgrade chokes on insufficient space. A bug has been filed for Ubuntu on this point; see You might want to register yourself as also being affected by this bug, first creating a Launchpad account if necessary, to help increase its importance.

  10. Good call, Teemu – I’ve done that, and would suggest anyone else who’s affected does so too.

  11. 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

  12. 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.

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

Leave a Reply

Your email address will not be published.