Today’s one of those days where you start with a clear plan of what you want to do, and then you end up fixing something entirely different. Since I’ve built most of my virtual machines based on a small set of templates, at some point I got bored by having to keep them updated manually (and there’s a lot of them). So one day I switched them all to automatic updates.
Now’s the other day where all of them decided to throw errors. Basically, my boot drive was chosen to small, and the automated update process didn’t remove older kernel images.
Easy to fix, though I’ve to find a way to automate that (you’ve to make sure you’re running on the latest kernel, i.e. a reboot), if you use this script from the command shell (I found it somewhere on the net but have lost track):
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
Little update here: I just had that again. So instead of using apt-get at the end, I ended up using dpkg -r:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo dpkg -r