Partition Resizing Plan

Drac Noc drac.noc at
Sun Dec 15 13:27:39 UTC 2013

On Friday 13 Dec 2013 15:32:24 Tommy Trussell wrote:
> On Fri, Dec 13, 2013 at 9:29 AM, Barry Premeaux 
<bpremeaux at> wrote:
> > >I have seen this command suggested as a way to get rid of all 
old kernels
> > >
> > >sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed
> > >'/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'
> > >/d;s/^[^ ]*
> > >[^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
> > >
> > >but have never had the courage to try it.  This answer on 
> > >[1] suggests some other ways to clean them up.
> > 
> > I read through the same article, but didn't care for the possible 
> > factor.  I am more comfortable with picking each kernel I want to
> > remove, even if it is a little more time consuming.
> I did this recently. I don't think this is EXACTLY the same script I 
> but it was the same idea. I, too, didn't trust it, but fortunately you 
> 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 
> until I was comfortable it was working right. HOWEVER in my 
situation* I
> had to modify it slightly....
> *My situation was this -- for some reason in the distant past I made 
> root partition 10GB and the /home partition fills the rest of the drive. 
> 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, 
> filled up... I at first thought with something in /var/log or /var/cache,
> but it turns out it was old kernels.
> The way I found out was an LTS kernel update broke... one of the 
> 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, 
> can no longer use apt-get remove, because apt-get is too "smart" to 
> you to proceed until you fix the broken package.
> 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.
> ALL THAT TO SAY, "trust, but verify."

This is the one I used for Ubuntu 13.10 - can confirm it works 

sudo 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

It's an ugly looking thing but it works
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 665 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the ubuntu-users mailing list