Solving the issue “not enough free space” during Ubuntu upgrades under LVM

Upgrading my xUbuntu OS (14.04 LTS), I sometimes have the following error message:

The upgrade needs a total of XXX M free space on disk
"/boot". Please free at least an additional YYY M of 
disk space on "/boot". Empty your trash and remove
temporary packages of former installations using
'sudo apt-get clean'.

notEnoughSpace

In my case, I am using LVM (Logical Volume Manager (click here for further informations and the directory /boot is mounted from a separate partition with a fixed limited size. The total free space available on this volume can be exceeded when too many versions of the linux kernel have been installed on the computer. Solving this issue is however very simple and only requires to remove the oldest kernels.

  1. first go the the directory /boot and check which version of the linux kernel have been installed (cd /boot and thenls). You should have something similar to this image:boot(well, maybe in your case, the colors are a bit less dreadful), which says that you can safely remove version 3.13.0-53 and 3.13.0-54 of the linux kernel at least.
  2. second, you have to find which version of the kernel you are using, which depends on your computer. This is obtained with
    uname -a
    

    In my case, the answer is:

    Linux NAME 3.13.0-57-generic #95-Ubuntu SMP 
      Fri Jun 19 09:28:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    

    The version of the kernel that I am using is thus the generic.

  3. finally, just remove the oldest linux image and header packages with:
    sudo apt-get remove --purge linux-image-3.13.0-54-generic
      linux-image-3.13.0-53-generic linux-headers-3.13.0-53-generic
      linux-headers-3.13.0-54-generic
    sudo apt-get clean
    

And that’s it! Be careful not to remove all linux images and kernels though: you would not be able to reboot your computer…!! This issue will be adressed in my next post 😉