reflexdemon
3/30/2019 - 10:30 PM

recover /boot space

recover /boot space

I recently was trying to boot my old linux mint laptop and got a error message that my /boot was full. I did google for he solution and finally found a way to claim the space by removing old and unused space by just using the below script.

#!/usr/bin/env bash

OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
YELLOW="\033[1;33m"
RED="\033[0;31m"
ENDCOLOR="\033[0m"
sudo apt-get purge $OLDKERNELS

Just put this in a file say, cleanup_kernal.sh and runas root. That is it! Enjou