"The volume boot has only 0 bytes disk space remaining"
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
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:
-
Get the current kernel version, the one you want to keep:
uname -r
-
Get the list of all kernels installed:
dpkg -l | grep linux-image-
-
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