Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I know number of ways to remove old kernel versions manually. Is there any way to remove old kernel versions automatically? Automatically, in the sense i don't have to do the same thing each time the kernel gets updated.

share|improve this question
1  
Or, to expand the question. Is there a way to keep only two versions of the kernel installed (the new one and the last one, just in case) automatically?. – Javier Rivera Feb 15 '12 at 9:29
possible duplicate of Is there a way to remove/hide old kernel versions? – Jorge Castro Feb 17 '12 at 21:43

1 Answer

You can follow the Using the "unattended-upgrades" package section of Automatic Security Updates article on Ubuntu Wiki to perform this.

You need to change the following line in /etc/apt/apt.conf.d/50unattended-upgrades file;

//Unattended-Upgrade::Remove-Unused-Dependencies "false";

with

Unattended-Upgrade::Remove-Unused-Dependencies "true";

to automatically remove old packages, including kernels.

Also remove or comment the line

"^linux-image.*"; 

in the "NeverAutoRemove" section of the file /etc/apt/apt.conf.d/01autoremove.

share|improve this answer
I did this but it was still collecting 3+ old kernels consuming 100's of MBs. So I added apt-get autoremove to my daily cron job that actually does the upgrades, since it doesn't always go through built-in update-manager. – Marcos Aug 24 '12 at 12:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.