After a recent update, I'm getting an alert saying:

The volume boot has only 0 bytes disk space remaining

But my computer has plenty of HD space free. Does anyone know how I resolve this. (If it's relevant, I'm using the whole disk encryption feature of the alternate install image for Ubuntu 12.04).

To list all kernel:
dpkg --get-selections | grep "linux-image-[[:digit:]].*" | tr "\t" ";" | cut -d ";" -f1

The results looks somewhat like this:

linux-image-3.19.0-7-generic 
linux-image-3.18.0-13-generic  
linux-image-3.16.0-23-generic

Don't delete all kernels, only old ones!

Next let's remove the 3.16 kernel,
sudo apt-get purge linux-image-3.16.0-23-generic

and then all unused packages from the system:
sudo apt-get autoclean && sudo apt-get autoremove

  • I have some called extra too, eg both linux-image-3.13.0-40-generic and linux-image-extra-3.13.0-40-generic. Can I delete the ones with extra? – Mads Skjern Mar 5 '15 at 11:53
  • This was extremely helpful, but didn't completely solve my problem (purging an old kernel was still failing). I had to manually remove some old kernel files. I found a few large ones using find /boot/ -type f | xargs du | sort -n. My currently running kernel is 3.13.0-66-generic, so I'm careful not to delete anything related to that, but I did remove the following : sudo rm /boot/initrd.img-3.13.0-63-generic /boot/initrd.img-3.13.0-65-generic /boot/vmlinuz-3.13.0-65-generic /boot/vmlinuz-3.13.0-63-generic. Finally, running purge on an old kernel succeeds. – blong Nov 10 '15 at 14:35
  • 4
    if you really have 0 bytes free, this won't work as @blong said. you have to manually remove some old vmlinuz file before, because the purge process needs to create some files and, if 0 bytes are left, this fails. – pomarc Jun 21 '17 at 15:30
  • 1
    How do I know which kernels are old? My output is linux-image-4.10.0-42-generic linux-image-4.13.0-26-generic linux-image-4.13.0-32-generic linux-image-4.13.0-37-generic linux-image-4.13.0-38-generic linux-image-4.13.0-39-generic linux-image-4.13.0-41-generic linux-image-4.13.0-43-generic linux-image-4.8.0-36-generic – jacob May 29 at 18:10

The cause was indeed old kernel images.
To clean up all I had to do was run one line:

sudo apt-get autoclean && sudo apt-get autoremove

This automatically recognized old kernals and removed them.

It might be that your /boot partition has accumulated too many kernel versions while doing upgrades over time. This partition is likely to be separate from your large disk partition (mounted as /). You can check the /boot partition space like this (look for the line with /boot):

df -h

There is a nice page on how to remove old kernels.

In short, check your current kernel version, get the list of what is installed, and then apt-get remove the old versions. There is also a "magic" one-liner command on the page that will do all that for you. But use it at your own risk.

Instructions in more detail:

  1. Get the current kernel version, the one you want to keep:

    uname -r
    
  2. Get the list of all kernels installed:

    dpkg -l | grep linux-image-
    
  3. Run apt-get remove on the kernels you want to remove. Not on the latest one! For example:

    sudo apt-get remove linux-image-2.6.32-22-generic
    

More notes:

  • dpkg -l will tell you the status of the (kernel) package before the package name. For example:

    rc  linux-image-3.13.0-39-generic  ...
    ii  linux-image-3.13.0-40-generic  ...
    
    • "rc" means that the package is removed and has configuration files. These you do not need to remove any more.
    • "ii" means that the package is marked for installation and is installed

    Based on this, you could list only the kernel packages that are installed:

    dpkg -l | grep "ii.*linux-image-"
    

Alternative solution, using GUI tool Ubuntu Tweak.

Install and go to Computer Janitor, check the System->Old Kernel and System->Unneeded packages, and press Clean.

Use this script so that will remove all other old kernels leaving current version and previous (last 1 kernel version)

KERNELMAGES=`ls -lRt /boot/vmlinuz-*| awk -F/ '{print $3}' | grep -v $(uname -r) | sed 1d | sed -e 's/vmlinuz/linux-image/g'`

KERNELHEADERS=`ls -lRt /boot/vmlinuz-*| awk -F/ '{print $3}' | grep -v $(uname -r) | sed 1d | sed -e 's/vmlinuz/linux-headers/g'`

for PURGEKERNEL in `echo $KERNELMAGES $KERNELHEADERS`; do

apt-get autoremove -y && apt-get purge $PURGEKERNEL -y

done
  • Worked perfect, even when I could not do "Paradiesstaub"s answer from the command line. – bulltorious Aug 29 '17 at 21:25
  • I am getting "Permission denied"... – Richard Hardy Jul 1 at 5:55

protected by Community Jun 20 '16 at 9:14

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.