I'm running Ubuntu 12.04, and two active linux images 3.2.0-37 and 3.2.0-36. In the /usr/src/ directory i find:

linux-headers-3.2.0-23    
linux-headers-3.2.0-23-generic    
linux-headers-3.2.0-26    
linux-headers-3.2.0-26-generic
linux-headers-3.2.0-29    
linux-headers-3.2.0-29-generic
linux-headers-3.2.0-31    
linux-headers-3.2.0-31-generic    
linux-headers-3.2.0-32    
linux-headers-3.2.0-32-generic    
linux-headers-3.2.0-33    
linux-headers-3.2.0-33-generic    
linux-headers-3.2.0-34    
linux-headers-3.2.0-34-generic    
linux-headers-3.2.0-35    
linux-headers-3.2.0-35-generic    
linux-headers-3.2.0-36    
linux-headers-3.2.0-36-generic     
linux-headers-3.2.0-37     
linux-headers-3.2.0-37-generic

Today I sudo apt-get purge linux-image-x.x.x.x-generic *34 and *35

I have to add that /boot contains only *36 and *37.

Is it safe to remove all of these except *37 and *36 ? Thank you in advance.

share|improve this question
up vote 18 down vote accepted

Those are header files are contained in the linux-headers-* and linux-headers-*-generic packages. It should be safe to remove them through apt-get. Maybe apt-get autoremove will already suggest that to you. Please do not remove them manually!

share|improve this answer
2  
apt-get autoremove did not remove the header files for me – user12345 Oct 17 '14 at 23:51
2  
Except sometimes apt-get autoremove can't run because of an out of disk space error, due in part to /usr/src/linux* taking up 2G of space on a small drive. – Mark Stosberg Feb 22 '16 at 21:12
1  
Yap. Sometimes it is not the disk space, but no more inodes being left -> if df -i shows 100% usage, you are de facto left with no space whatsoever. Only solution is then to delete some /usr/src/linux* stuff, to get apt to work again. – Christian Ulbrich Apr 6 '17 at 0:48

I just had this issue, and the suggestion to use apt-get autoremove did not work for me.

I resolved it by doing:

sudo apt-get purge linux-headers-3.2.0-23

on such linux headers that lived in /usr/src. I did not remove the headers that correspond to the kernel currently being used.

Restarted the server successfully.

share|improve this answer
1  
A oneliner to automate this: ubuntugenius.wordpress.com/2011/01/08/… Works like a charm. (I had to modify it a little for my situation.) – Reinier Post Sep 29 '15 at 15:18

To anyone coming in off a Google search years later: You can also uninstall old kernels in the Synaptic Package Manager. Just double check which one you're currently using by typing 'uname -a' into the terminal.

share|improve this answer
    
Your answer should explain how to do this, specifically. – Elijah Lynn Mar 3 '17 at 20:08

16.04 and newer versions of Ubuntu

sudo apt-get autoremove

This command removes packages that were automatically installed to resolve a dependency, but are now no longer depended on.

share|improve this answer
    
But still doesn't work if /boot is full or out of inodes, as mentioned in the comments above. – Soren A Dec 8 '17 at 8:46

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.