When your Ubuntu boot is full

Time to clean-up your boot partition


For any strange reasons, the boot folder get filled up by default with old kernel versions, and it's time to clean things up when your system keeps telling you it's getting full. Unless you are a unix guru, it is likely that you have no idea which commands to use - just like me. Thankfully we have askubuntu and stack overflow. I thought, however, that I would share the results from my search .. (and 2 hours of my life gone). 

Checking what kernels are there

your current running version can be found using :
uname -r
to see which versions are installed do:
sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'

to clean-up a specific kernel, or even better, many, in one command:
sudo rm -rf /boot/*-4.4.0-{41,51}-*

Making sure all is good

in case the last install was not working do:
sudo apt-get -f install

and if that fails to find the image, clean further with
sudo apt-get purge linux-image-4.4.0-xx-generic

finally, to make sure old dependencies and orphans are gone do:
sudo apt-get autoremove

Keep up to date

A good suggestion is to update everything now that y6ou have space
sudo apt-get update
sudo apt-get upgrade

Prevent this to happen again

The auto-remove can actually be set to run after any update! for this one needs to set to 'True' /etc/apt/apt.conf.d/50unattended-upgrades. Now you are asking me, ok how do I do that? well there is a package for that: unattended-upgrades package 

I also found useful to expend my boot partition to give it more space - this can be done easily using GParted (the live edition, ie booting from a USB you can edit any partition on your drive) 




Comments

Popular Posts