What is the best way to remove old kernel modules?

Discuss the security implications of the various flavors of linux and unix

What is the best way to remove old kernel modules?

Post by -Ninjex- on Tue Jan 29, 2013 11:01 pm
([msg=72960]see What is the best way to remove old kernel modules?[/msg])

I never post a question without researching first..

Earlier today, I was looking up a tutorial on how to remove old kernel headers/modules and when I followed the tutorial (This is hypothetical, and I had older kernel headers previously that I purged) which was similar to the following code

Code: Select all
:~$ dpkg -l | grep linux-headers
ii  linux-headers-3.2.0-36                 3.2.0-36.57                             Header files related to Linux kernel version 3.2.0
ii  linux-headers-3.2.0-36-generic         3.2.0-36.57                             Linux kernel headers for version 3.2.0 on 32 bit x86 SMP
ii  linux-headers-3.2.0-36-generic-pae     3.2.0-36.57                             Linux kernel headers for version 3.2.0 on 32 bit x86 SMP
ii  linux-headers-generic                  3.2.0.36.43                             Generic Linux kernel headers
ii  linux-headers-generic-pae              3.2.0.36.43                             Generic Linux kernel headers



Code: Select all
sudo apt-get purge [3.2.0-36-generic-pae]


Needless to say, it starting purging everything from /* and beyond and I knew I was fucked; kinda...
I spent the next three hours re-installing ubuntu 11.10, and upgrading it. Then I had to recover the corrupted partition which took forever, and mount it and copy all my files, and then free the old partition space, and add it to the new one.

My question is what is the methods that you use, that is safe?
I ask because in the future, I do not want to risk having to do this again.

Thanks in advance,
- Ninjex
If you're not willing to learn, no one can help you. If you're determined to learn, no one can stop you.⠠⠵
The absence of evidence is not evidence of absence.
I can explain it for you, but I can't understand it for you.
User avatar
-Ninjex-
Addict
Addict
 
Posts: 1344
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)


Re: What is the best way to remove old kernel modules?

Post by centip3de on Thu Jan 31, 2013 4:40 pm
([msg=73081]see Re: What is the best way to remove old kernel modules?[/msg])

-Ninjex- wrote:I never post a question without researching first..

Earlier today, I was looking up a tutorial on how to remove old kernel headers/modules and when I followed the tutorial (This is hypothetical, and I had older kernel headers previously that I purged) which was similar to the following code

Code: Select all
:~$ dpkg -l | grep linux-headers
ii  linux-headers-3.2.0-36                 3.2.0-36.57                             Header files related to Linux kernel version 3.2.0
ii  linux-headers-3.2.0-36-generic         3.2.0-36.57                             Linux kernel headers for version 3.2.0 on 32 bit x86 SMP
ii  linux-headers-3.2.0-36-generic-pae     3.2.0-36.57                             Linux kernel headers for version 3.2.0 on 32 bit x86 SMP
ii  linux-headers-generic                  3.2.0.36.43                             Generic Linux kernel headers
ii  linux-headers-generic-pae              3.2.0.36.43                             Generic Linux kernel headers



Code: Select all
sudo apt-get purge [3.2.0-36-generic-pae]


Needless to say, it starting purging everything from /* and beyond and I knew I was fucked; kinda...
I spent the next three hours re-installing ubuntu 11.10, and upgrading it. Then I had to recover the corrupted partition which took forever, and mount it and copy all my files, and then free the old partition space, and add it to the new one.

My question is what is the methods that you use, that is safe?
I ask because in the future, I do not want to risk having to do this again.

Thanks in advance,
- Ninjex


I actually had to do something like this not too long ago, because the new NVidia drivers fucked up my GUI/Xorg configuration/Linux Headers and did it manually, like you (except I didn't delete my root folder ;) ). Anyway, there's an automated way to do it. Found this in a simple Google search. I think you need to do your homework a bit better, my friend.

TL;DR:
Code: Select all
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
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rick Cook
User avatar
centip3de
Moderator
Moderator
 
Posts: 1428
Joined: Fri Aug 20, 2010 5:46 pm
Blog: View Blog (0)


Re: What is the best way to remove old kernel modules?

Post by 0phidian on Thu Jan 31, 2013 5:52 pm
([msg=73084]see Re: What is the best way to remove old kernel modules?[/msg])

I have always just removed them with synaptic.
User avatar
0phidian
Poster
Poster
 
Posts: 270
Joined: Sat Jun 16, 2012 7:04 pm
Blog: View Blog (0)


Re: What is the best way to remove old kernel modules?

Post by -Ninjex- on Thu Jan 31, 2013 7:10 pm
([msg=73087]see Re: What is the best way to remove old kernel modules?[/msg])

centip3de wrote: I think you need to do your homework a bit better, my friend.


That wasn't the factor...
I did some research, and the one I read seemed trustworthy. You live and you learn, and you don't actually know if something works or not until you try it. I seen the post from stackoverflow with like 8 thumbs up, so I figured it was legit.
If you're not willing to learn, no one can help you. If you're determined to learn, no one can stop you.⠠⠵
The absence of evidence is not evidence of absence.
I can explain it for you, but I can't understand it for you.
User avatar
-Ninjex-
Addict
Addict
 
Posts: 1344
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)


Re: What is the best way to remove old kernel modules?

Post by centip3de on Thu Jan 31, 2013 7:15 pm
([msg=73089]see Re: What is the best way to remove old kernel modules?[/msg])

-Ninjex- wrote:That wasn't the factor...
I did some research, and the one I read seemed trustworthy. You live and you learn, and you don't actually know if something works or not until you try it. I seen the post from stackoverflow with like 8 thumbs up, so I figured it was legit.


That was referring to when you said, "I never post a question without researching first..". Most, if not all Google results I found were pointing to that command. Either way, yes, you generally do live and learn... Except in my case, I suppose. It took about 30 separate times of a program crashing for me to finally realize that I should probably not be reusing bugged code...
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rick Cook
User avatar
centip3de
Moderator
Moderator
 
Posts: 1428
Joined: Fri Aug 20, 2010 5:46 pm
Blog: View Blog (0)



Return to *nix

Who is online

Users browsing this forum: No registered users and 0 guests

cron