<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Dec 13, 2013 at 9:29 AM, Barry Premeaux <span dir="ltr"><<a href="mailto:bpremeaux@gmail.com" target="_blank">bpremeaux@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br></div><div class="im">
>I have seen this command suggested as a way to get rid of all old kernels<br>
<br>
>sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed<br>
>'/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'<br>
>/d;s/^[^ ]*<br>
>[^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')<br>
<br>
>but have never had the courage to try it.  This answer on askubuntu<br>
>[1] suggests some other ways to clean them up.<br>
<br>
<br>
</div>I read through the same article, but didn't care for the possible oops<br>
factor.  I am more comfortable with picking each kernel I want to<br>
remove, even if it is a little more time consuming.<br>
<div class="HOEnZb"><div class="h5"></div></div></blockquote></div><br></div><div class="gmail_extra">I did this recently. I don't think this is EXACTLY the same script I used, but it was the same idea. I, too, didn't trust it, but fortunately you can copy and paste PORTIONS of it into the terminal. I started with the right-most pipe and worked my way to everything past the left-most pipe, until I was comfortable it was working right. HOWEVER in my situation* I had to modify it slightly....</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">*My situation was this -- for some reason in the distant past I made my root partition 10GB and the /home partition fills the rest of the drive. I think the drive has been replaced and it's now 2TB, but for some reason I kept the 10GB partition, which even though I only run LTS releases, it filled up... I at first thought with something in /var/log or /var/cache, but it turns out it was old kernels. </div>
<div class="gmail_extra"><br></div><div class="gmail_extra">The way I found out was an LTS kernel update broke... one of the packages wouldn't install, complaining the drive was out of space (even though it said it was only 89% full). As it turns out, once this happens to you, you can no longer use apt-get remove, because apt-get is too "smart" to allow you to proceed until you fix the broken package.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">SO after I verified that I was happy with what the command was selecting, I changed the script to use dpkg -r instead of apt-get remove, knowing that dpkg is more "stupid" compared to apt-get. It won't let you remove INDIVIDUAL packages that have cross-dependencies, but if you pass it a big list that satisfies the dependencies it will happily comply.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">ALL THAT TO SAY, "trust, but verify."</div><div class="gmail_extra"><br></div></div>