Feb 24, 2014

Awesome Script To Remove All Unused Kernel Images In Ubuntu to Free Disk Space in /boot

Tux, the Linux penguin
(Photo credit: Wikipedia)
I thought I had written about this in the past, but I guess I didn't as I couldn't find any posts about it here on Bauer-Power... I digress.

Anyway, the other day I had to install a kernel update on my work laptop that is running Xubuntu, and it wouldn't download because I had run out of space in /boot. That's almost always caused from having too many kernel image files saved there from previous updates.

Well I found a really cool one-line command that removes all kernel images except the current one. That command is:
export KERNEL="$(uname -r | grep -Po '([0-9\.\-]*[0-9])?')"; dpkg --get-selections | grep -E "linux-(header|image).*" | grep -iw install | sort | grep -v "$KERNEL" | grep -v "lts" | sed 's/install//g' | xargs dpkg -P
You can put that in a convenient script if you like for future use!

[Via Raymii]



Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | stopping spam