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:

not-enough-space

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.

Credits:

I think the dpkg command came from here originally : http://ubuntugenius.wordpress.com/2011/01/08/ubuntu-cleanup-how-to-remove-all-unused-linux-kernel-headers-images-and-modules/

And there’s similar at : http://blog.hozzamedia.com/software/linux/xubuntu-not-enough-free-disk-space-on-boot/

23 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 https://bugs.launchpad.net/ubuntu/+source/update-manager/+bug/1183692. 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.

  14. 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).
    root@host:~#

    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 ?

  15. 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 Reply

Your email address will not be published.