I get fed up occasionally of the million…
I get fed up occasionally of the million and one old kernels I have installed after multiple updates and upgrades of my Ubuntu install, so I have the following shell script snippet to sort it out for me:
|
1 |
sudo aptitude -F '%p' search linux-{image,headers,restricted}-2.6~i | grep -v `uname -r | sed -r 's/-[a-z0-9A-Z]+$//'` |
That pumps out a list of all the installed kernels and associated images/modules/etc apart from the one you are currently using. It also keeps around suffixed kernels at the same version as your current one (so if you have the -pae, -rt, -smp, -generic and -preempt kernels installed, it will leave the ones that match the version number of your current kernel).
Now, if you want to be dangerous and not check the output, you can bin them all with a single command, like so:
|
1 |
sudo aptitude -F '%p' search linux-{image,headers,restricted}-2.6~i | grep -v `uname -r | sed -r 's/-[a-z0-9A-Z]+$//'` | xargs sudo aptitude purge -y |
Et voila! Goodbye superfluous kernels!
Ralph Corderoy 10:08 am on May 10, 2011 Permalink
Don’t think the searching aptitude needs the sudo?
Dark Liquid 11:33 am on May 10, 2011 Permalink
I think you’re probably right.
Dru 11:26 am on March 23, 2012 Permalink
bash: syntax error near unexpected token `newline'
Penny:~$ sudo aptitude -F '%p' search linux-{image,headers,restricted}-2.6~i | grep -v
uname -r | sed -r 's/-[a-z0-9A-Z]+$//'bash: syntax error near unexpected token `newline’
Dru 9:57 am on March 25, 2012 Permalink
Ignore that last comment, wordpress fucked with the code snippet, and inserted bits that shouldn’t be there.