Howto: Free disk space when /boot is full

Updated . Posted . Visible to the public.

Easy mode

This method will remove automatically installed packages that no other packages depend on any more. This, of course, includes obsolete kernel versions, with the explicit exception of the currently running kernel, the kernel version that was installed on the system before that and, of course, the latest updated version of the kernel. However, it will also remove any and all other packages that have been marked as installed automatically but have no other packages depending on them. This could lead to unexpected removal of packages. So please check the output of sudo apt-get autoremove closely.

One-shot, manual method

sudo apt-get autoremove

Automatically remove unused packages

Edit /etc/apt/apt.conf.d/50unattended-upgrades and un-comment the line Unattended-Upgrade::Remove-Unused-Dependencies "true";.

Hard mode (for old Ubuntus)

uname -r prints currently used kernel version. You should not remove the current kernel, linux-image-generic and linux-image.

sudo apt-get clean
dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V
uname -r
sudo apt-get purge linux-image-x.y.z-generic
sudo apt-get autoremove

Removing multiple kernel versions with one command (long and short version):

sudo apt-get remove linux-image-1.2.4-generic
sudo apt-get remove linux-image-1.2.7-generic
sudo apt-get remove linux-image-1.2.8-generic
sudo apt-get remove linux-image-1.2.9-generic
sudo apt-get remove linux-image-1.2.{4,7..9}-generic

We have a tool, called geordi Show archive.org snapshot , which helps you to remove old kernels (available in geordi < 1.7.0). You need to run this command as root.

# rvm
gem install geordi
rvmsudo geordi purge-kernels
# rbenv
sudo gem install geordi
sudo geordi purge-kernels
Last edit
Daniel Straßner
Keywords
delete, remove, old, kernel, versions, boot, partition
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2016-12-05 09:12)