LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-14-2008, 02:42 PM   #1
original_jamingrit
LQ Newbie
 
Registered: Aug 2007
Location: Ottawa, Ont. Canada
Distribution: Slackware
Posts: 11

Rep: Reputation: 0
Removing remnants of old kernels


Hey all,

In the past week or so, I've compiled a lot of unsuccessful kernels in my attempts to get one that worked well for my system. It seemed that I was always forgetting to enable some thing while configuring. I've probably built about a dozen. :-P

To build and install, I was just using the basic method as described in the Slackbook, which goes:

Code:
cd /usr/src/linux
make mrproper
#insert fiddling with .config file here
make menuconfig
make bzImage; make modules

##This part was only done the first time;
cp /boot/vmlinuz /boot/vmlinuz.old; cp /boot/System.map /boot/Sysytem.map.old
# and then put a place for the default kernel in GRUB

##The rest was done every time;
cat arch/i386/boot/bzImage > /boot/vmlinuz; cp System.map /boot/System.map
make modules_install
poweroff
#cross fingers
So as you can see from the above, I continually overwrite the old kernels each time I create a new one. But the modules for old kernels remain, since I change the kernel version extension each time (really didn't need to, and probably shouldn't have). I want to know the proper and safest way of removing those by hand. Any advice or opinions?
 
Old 07-14-2008, 04:11 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Quote:
Originally Posted by original_jamingrit View Post

So as you can see from the above, I continually overwrite the old kernels each time I create a new one. But the modules for old kernels remain, since I change the kernel version extension each time (really didn't need to, and probably shouldn't have). I want to know the proper and safest way of removing those by hand. Any advice or opinions?
Each set of modules is in a directory in /lib/modules. The directory names in /lib/modules are the kernel version extension of the kernel that each set of modules corresponds to. So you can delete all of the directories in /lib/modules except the directory which corresponds to the kernel that you are actually using.

-------------------
Steve Stites
 
Old 07-14-2008, 11:37 PM   #3
GushpinBob
Member
 
Registered: Aug 2007
Distribution: File Server: Ubuntu 10.04
Posts: 56

Rep: Reputation: 15
This is how I clean up older kernels and kernel modules.

To remove modules:
Code:
rm -r /lib/modules/VERSION
where VERSION is the kernel's version of which I am removing

To remove the kernel itself:
Code:
rm -r /boot/KERNEL
where KERNEL is your old kernel whether it be named vmlinuz-VERSION or bzImage-VERSION or etc.

Remove the System.map-VERSION from the /boot directory (assuming if anyone still copies their System.map file into boot)

Remove or comment out the lines to boot that old kernel in lilo.conf or GRUB's menu.lst

Finally, remove the old kernel's source directory (though I'd recommend holding on to the sources that came with your distro-supplied kernel). Usually after extracting and building a kernel from source, you're left over with a kernel source directory that can be hundreds of megabytes large. So if your strapped for space look in your /usr/src directory for any old uncompressed kernel build directories .

EDIT: Don't delete the source dir for your current kernel. Some software that is custom compiled will often check (i.e if you're building 3rd party modules).

Last edited by GushpinBob; 07-14-2008 at 11:40 PM.
 
Old 07-21-2008, 03:14 PM   #4
original_jamingrit
LQ Newbie
 
Registered: Aug 2007
Location: Ottawa, Ont. Canada
Distribution: Slackware
Posts: 11

Original Poster
Rep: Reputation: 0
Okay, great! Old modules have been removed with no ill effects.

Thanks a lot!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Old Kernels carlosinfl Debian 7 03-03-2006 12:10 PM
Removing old kernels? carlosinfl Fedora 1 04-12-2005 09:58 AM
Removing old kernels mike270 Linux - Software 6 08-07-2004 09:05 PM
removing kernels? rakriege Linux - Newbie 1 11-09-2003 05:54 PM
removing old kernels in RH 8.0 bobterri Linux - General 2 12-02-2002 09:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration