42

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

Zanna
  • 70,465
user924731
  • 421
  • 1
  • 4
  • 3
  • It really depends on how you installed Ubuntu on your machine. Can you "sudo fdisk -l" in terminal and check whether there is a small partition which is almost full? – psukys Nov 18 '12 at 09:50
  • 4
    Better still, please run the command 'df -H -x tmpfs -x devtmpfs' without the quotes and paste the output here. – fabricator4 Nov 18 '12 at 10:12
  • This question and answers are related to the problem, and may help. – elomage May 25 '15 at 05:09
  • apparently a known issue for encrypted partition. answer https://askubuntu.com/a/230942/231504 is great -- works for me. Also, though, please increment the count of affected users in the ubuntu tracker: https://bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/1357093 – pestophagous Sep 20 '17 at 18:05

4 Answers4

63

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

artxur
  • 103
  • 4
  • 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 05 '15 at 11:53
  • 1
    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
  • 5
    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 '18 at 18:10
  • @jacob Run uname -r to know what kernel is currently being used. – zanbri Mar 09 '23 at 14:58
30

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.

Selah
  • 2,905
9

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.

elomage
  • 1,400
3

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
PKumar
  • 2,952