Ubuntu boot partition running out of space….

Problem: /boot partition begins to fill and even after manual clean up, the problem reoccurs.

Solution: Initially clean the partition. The solution we have used is documented here and summarised below.

  1. Get the current kernel version by executing
    • uname -r
  2. List the kernels available, except the kernel currently in use
    • dpkg –list ‘linux-image*’|awk ‘{ if ($1==”ii”) print $2}’|grep -v uname -r
  3. Based on the list returned by the command above, execute
    • apt-get purge linux-image–generic
  4. Remove orphaned packages
    • apt-get autoremove
  5. Did it work? The command in step 2 should return no results. Check boot partition space with
    • df -h | egrep “boot|Mounted on”

Once that’s done, it’s recommended to setup Automatic Maintenance as below:

  1. Install the package unattended-upgrades
    • apt-get install unattended-upgrades
  2. Configure unattended-upgrades
    • dpkg-reconfigure -plow unattended-upgrades
  3. Make sure /etc/apt/apt.conf.d/50unattended-upgrades contains line Unattended-Upgrade::Remove-Unused-Dependencies “true”;cat /etc/apt/apt.conf.d/50unattended-upgrades | grep Remove-Unused-Dependencies

    If the result is //Unattended-Upgrade::Remove-Unused-Dependencies “false”;, then use your prefered editor to remove the // and change false to true.