Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I try to do do-release-upgrade but then I get:

Not enough free disk space

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

Output of df:

                    237251272 214797108  10402504  96% /
udev                    488120         4    488116   1% /dev
tmpfs                   198676       668    198008   1% /run
none                      5120         0      5120   0% /run/lock
none                    496684         0    496684   0% /run/shm
/dev/sda1               233191    225867         0 100% /boot

How come there is no space left on boot? Here's the output of ls -as /boot:

total 221839
    4 .
    4 ..
  645 abi-2.6.32-34-generic-pae
  698 abi-2.6.35-30-generic-pae
  727 abi-2.6.38-12-generic-pae
  727 abi-3.0.0-12-generic-pae
  727 abi-3.0.0-13-generic-pae
  727 abi-3.0.0-14-generic-pae
  727 abi-3.0.0-15-generic-pae
  727 abi-3.0.0-16-generic-pae
  727 abi-3.0.0-17-generic-pae
  727 abi-3.0.0-19-generic-pae
  761 abi-3.0.0-20-generic-pae
  115 config-2.6.32-34-generic-pae
  128 config-2.6.35-30-generic-pae
  136 config-2.6.38-12-generic-pae
  140 config-3.0.0-12-generic-pae
  140 config-3.0.0-13-generic-pae
  140 config-3.0.0-14-generic-pae
  140 config-3.0.0-15-generic-pae
  140 config-3.0.0-16-generic-pae
  140 config-3.0.0-17-generic-pae
  140 config-3.0.0-19-generic-pae
  140 config-3.0.0-20-generic-pae
    5 grub
10773 initrd.img-2.6.32-34-generic-pae
13619 initrd.img-2.6.35-30-generic-pae
15365 initrd.img-2.6.38-12-generic-pae
16481 initrd.img-3.0.0-12-generic-pae
16487 initrd.img-3.0.0-13-generic-pae
16501 initrd.img-3.0.0-14-generic-pae
16476 initrd.img-3.0.0-15-generic-pae
16481 initrd.img-3.0.0-16-generic-pae
16478 initrd.img-3.0.0-17-generic-pae
   12 lost+found
  174 memtest86+.bin
  176 memtest86+_multiboot.bin
    2 vmcoreinfo-2.6.32-34-generic-pae
    2 vmcoreinfo-2.6.35-30-generic-pae
    2 vmcoreinfo-2.6.38-12-generic-pae
    2 vmcoreinfo-3.0.0-12-generic-pae
    2 vmcoreinfo-3.0.0-13-generic-pae
    2 vmcoreinfo-3.0.0-14-generic-pae
    2 vmcoreinfo-3.0.0-15-generic-pae
    2 vmcoreinfo-3.0.0-16-generic-pae
    2 vmcoreinfo-3.0.0-17-generic-pae
    2 vmcoreinfo-3.0.0-19-generic-pae
    2 vmcoreinfo-3.0.0-20-generic-pae
 4092 vmlinuz-2.6.32-34-generic-pae
 4347 vmlinuz-2.6.35-30-generic-pae
 4567 vmlinuz-2.6.38-12-generic-pae
 4675 vmlinuz-3.0.0-12-generic-pae
 4676 vmlinuz-3.0.0-13-generic-pae
 4681 vmlinuz-3.0.0-14-generic-pae
 4698 vmlinuz-3.0.0-15-generic-pae
 4700 vmlinuz-3.0.0-16-generic-pae
 4700 vmlinuz-3.0.0-17-generic-pae
 4703 vmlinuz-3.0.0-19-generic-pae
 4705 vmlinuz-3.0.0-20-generic-pae

Output of uname -a:

 Linux kitsch 3.0.0-17-generic-pae #30-Ubuntu SMP Thu Mar 8 17:53:35 UTC 2012 i686 i686 i386 GNU/Linux
share|improve this question
Add the output to ls -l /boot and uname -a to your question. – jippie May 27 '12 at 14:51
Also add the output to dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' to your question. – jippie May 27 '12 at 14:57
ls -as /boot might be useful instead. It will include just the sizes of the files. – adempewolff May 27 '12 at 15:01
the output of ls -l /boot is quite long too post here so here is a pastebin – clamp May 27 '12 at 15:02
No it is not. It is the cause of your problem. If your question is indeed getting too long someone will edit it. Use of external services like pastebin will break the value of the question for future reference. – jippie May 27 '12 at 15:03
up vote 133 down vote accepted

Your /boot partition is filled with old kernels. It does that sometimes, not sure why it is never fixed. You can easily remove the old kernels if you know which packages they came in.

First check uname -a to check your current version.

Then run the following command:

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

This command will list all packages that you no longer need. I don't like removing them automatically, I like to be in control when it comes to removing kernels. So for every package listed do the following:

sudo apt-get -y purge some-kernel-package


This intermezzo describes in more detail how the commands work and tries to fix an issue with linux-libc-dev:amd64. Most users can skip this paragraph.

  • dpkg -l 'linux-*' list all packages that have a name starting with 'linux-'
  • sed '/^ii/!d; remove all lines that do *not* start withii`
  • uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/" find the current running kernel version
  • /'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d Remove all lines, except the ones containing the current running kernel version number
  • s/^[^ ]* [^ ]* \([^ ]*\).*/\1/ For each line list only the package name
  • /[0-9]/!d Remove lines that do not contain numbers.

To fix Frederick Nord's issue I think the command can be amended as follows:

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

It basically adds an extra filter:

  • /^linux-(headers\|image)/!d Delete all lines that do not start with linux-headers or linux-image


Where some-kernel-package can be replaced with one of the packages listed. Just beware that you don't remove the kernel packages that are in current use (as listed by the uname -a) eg. sudo apt-get purge -y linux-headers-3.0.0-12 etc.

It can be automated further using the xargs command, but I don't like that. It is a personal thing. However, here's the command to do so:

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

This is what my /boot looks like, one spare kernel (2.6.38-11) just in case and 3.2.0-24 being current:

$ ls -l /boot
total 59388
-rw-r--r-- 1 root root   730545 Sep 13  2011 abi-2.6.38-11-generic
-rw-r--r-- 1 root root   791023 Apr 25 13:51 abi-3.2.0-24-generic
-rw-r--r-- 1 root root   130326 Sep 13  2011 config-2.6.38-11-generic
-rw-r--r-- 1 root root   140341 Apr 25 13:51 config-3.2.0-24-generic
drwxr-xr-x 3 root root     5120 May 27 17:46 grub
-rw-r--r-- 1 root root 20883146 Oct  1  2011 initrd.img-2.6.38-11-generic
-rw-r--r-- 1 root root 22474219 May  5 09:04 initrd.img-3.2.0-24-generic
drwxr-xr-x 2 root root    12288 Apr 16  2009 lost+found
-rw-r--r-- 1 root root   176764 Nov 27 11:00 memtest86+.bin
-rw-r--r-- 1 root root   178944 Nov 27 11:00 memtest86+_multiboot.bin
-rw------- 1 root root  2656297 Sep 13  2011
-rw------- 1 root root  2884358 Apr 25 13:51
-rw------- 1 root root     1369 Sep 13  2011 vmcoreinfo-2.6.38-11-generic
-rw------- 1 root root  4526784 Sep 13  2011 vmlinuz-2.6.38-11-generic
-rw------- 1 root root  4965776 Apr 25 13:51 vmlinuz-3.2.0-24-generic

And file system usage:

$ df -h /boot
Filesystem Size Used Avail Use% Mounted
/dev/sda5  228M  63M  154M  29% /boot
share|improve this answer
This solution was heavily inspired on an article by OzzyFrank at… – jippie May 27 '12 at 15:37
Yes, why is this an issue is the question? This shouldn't be on the user to handle. – Elijah Lynn Nov 1 '13 at 20:58
Great answer, thanks – Sebastian Sastre Dec 3 '13 at 18:16
FWIW: This also matched linux-libc-dev:amd64 for me. So it may very well be a little too generous. – Frederick Nord May 1 '14 at 13:30
It does that sometimes, not sure why it is never fixed Ubuntu has made the decision, for better or worse, to provide regular new kernels as new packages rather than as upgrades to existing packages, to give the option of having multiple kernels installed and switching between them at will. I agree that this assumption doesn't suit the 95% of people who just want the latest kernel (and maybe one fallback in case of new boot problems), and who don't want to manage the installed kernels themself. Perhaps in the future Ubuntu will change this behaviour. For now, make sure your /boot is huge. – thomasrutter Jul 30 '14 at 11:19

sudo apt-get autoremove

did the trick for me, it cleaned up successfully all the unused kernel packages.

share|improve this answer
this is not correct. from man apt-get autoremove is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed. a kernel would not be installed to satisfy dependencies, they are installed during upgrades. – dward May 30 '14 at 21:44
@neon_overload I just posted it because it did the trick, for me. – topless Jul 30 '14 at 14:20
@dward It did free some space for me : before autremove : /dev/sda1, 240M total, 171M used, 57M free, 75% used /boot after: /dev/sda1, 240M total, 129M used, 98M free, 57% used /boot – clickstefan May 8 '15 at 8:39
@clickstefan the first answer is correct. see also… – dward May 14 '15 at 12:39
This should be the selected answer. – opengrid Sep 4 '15 at 9:13

Another (possibly) easier way is to install the ubuntu-tweak tool, it can be downloaded from here. Go to "Janitor", and select "Old Kernel" to clean. It can be done in a few clicks. (tested on 14.04 desktop)

enter image description here

share|improve this answer
Situation with lack of space on /boot happens all the time so this is my favourite solution - easy to run application that does the job with one click. – s3m3n Dec 28 '15 at 12:33

protected by Community Jul 30 '14 at 18:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.