ubuntu: clean full boot partition

If the your boot partition if full you won't be able to update, upgrade or install new packages (apt-get upgrade/update/install). You will get an error while trying to do this, the next step is to check if this is in fact happening.

You'll get something like:

root@aizary:~# df -h

Filesystem Size Used Avail Use% Mounted on
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 396M 520K 395M 1% /run
/dev/dm-0 16G 8.0G 6.7G 55% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda1 236M 236M 0 100% /boot

This is generally because you have multiple old Kernels that have been updated over time but the old files have not been removed. So the first thing you need to do is find what is your current install Kernel (so you don't delete this).

root@aizary:~# uname -r

3.13.0-92-generic

Once you know what your current Kernel is you list all the available Kernels on the boot folder following the next command:

root@aizary:~# dpkg -l | grep linux-image

linux-image-3.13.0-40-generic 3.13.0-40.69 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP
linux-image-3.13.0-43-generic 3.13.0-43.72 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP
linux-image-3.13.0-44-generic 3.13.0-44.73 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP
linux-image-3.13.0-46-generic 3.13.0-46.79 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP
linux-image-3.13.0-92-generic 3.13.0-92.139 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP
linux-image-extra-3.13.0-40-generic 3.13.0-40.69 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
linux-image-extra-3.13.0-43-generic 3.13.0-43.72 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
linux-image-extra-3.13.0-44-generic 3.13.0-44.73 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
linux-image-extra-3.13.0-46-generic 3.13.0-46.75 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
linux-image-extra-3.13.0-92-generic 3.13.0-92.139 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
linux-image-generic 3.13.0.92.99 amd64 Generic Linux kernel image

Now, you manually remove each Kernel using the following command:

sudo dpkg --purge --force-all PACKAGE NAME

Make sure you DO NOT delete the current Kernel (in my case 3.13.0-92-generic) otherwise you'll have all sorts of problems upon reboot.

Note that you have to remove the regular packages and the extra for example

linux-image-3.13.0-40-generic
linux-image-extra-3.13.0-40-generic

Once the packages are removed execute the following commands:

sudo apt-get autoremove

This will remove unused packages

sudo apt-get -f install

and finally

sudo update-grub

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *