LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-19-2003, 02:48 AM   #1
praveen_2003
Member
 
Registered: Apr 2003
Location: india
Posts: 144

Rep: Reputation: 15
remove kernel


i have installed different versions of kernel on one distro.but if i want to remove any one of those is there any command to uninstall it?these days i was removing the modules manually from /lib/modules and i'll remove some files from /boot.i want to know whether is there any command to make clean uninstall?or else how to remove it completely.
 
Old 07-19-2003, 03:08 AM   #2
Thetargos
Senior Member
 
Registered: Mar 2003
Location: Mexico City
Distribution: Fedora, Ubuntu & Mint
Posts: 1,679

Rep: Reputation: 45
You may use a script you make with the recursive option of rm. For example if the kernel version you want to remove is 2.4.21, you'd put in your script:
Code:
!#/bin/bash
rm -rf /lib/modules/2.4.21
rm -f /boot/*2.4.21
Asuming you installed the kernel with the make install method, thus using vmlinuz and initrd<kernel>.img (sysimage, etc).

You may even have the script to "read" from the console the version you type in, for example: rmkernel 2.4.21 and it will remove that version (without having to "code" the version in the script) How to do that is something I've been wrestling with myself, but as soon as I have the solution, I'll let you know
 
Old 07-19-2003, 03:29 AM   #3
Thetargos
Senior Member
 
Registered: Mar 2003
Location: Mexico City
Distribution: Fedora, Ubuntu & Mint
Posts: 1,679

Rep: Reputation: 45
Got your solution: Just make a script like this:
Code:
#!/bin/bash

#Script to recursively erase a kernel install
rm -rf /lib/modules/"$1"
echo "Deleting direcotry /lib/modules/$1"
rm -f /boot/*"$1"
echo "Deleting kernel $1 from boot"
I can't make any promisses about the functionality of this script, it is VERY basic. Anyway it is a good idea to read about bash scripts before attemptint to use it.

Remember that you'd need to make executable by chmod u+x <scriptname>

You'd run it:
# <script> <kernel version to remove>

Hope this helps.

EDIT: Remember normally only root has write access to /boot and /lib/modules, so it would be advisable to save the file in /sbin or /usr/sbin

PS: This method works (as stated in the previous post) if you installed a kernel using the vmlinuz-<kernel version> way (make install) otherwise (bzImage) you would still need to manually remove the bzImage file.

Last edited by Thetargos; 07-19-2003 at 03:37 AM.
 
Old 07-19-2003, 05:48 AM   #4
Thetargos
Senior Member
 
Registered: Mar 2003
Location: Mexico City
Distribution: Fedora, Ubuntu & Mint
Posts: 1,679

Rep: Reputation: 45
I hope you find this script useful It tooke me a while to figure out how to polish it a little, there's still much functionality to add... but geee!! Look at the hour
Code:
#!/bin/bash 

# Shell script designed to erase a kernel from the system. It will prevent you remove any
#currently running kernel version via the 'uname -r' command. It could use a lot of refinement,
#since it does not check whether the calling user has or not write permission on the target
#directories, besides a lot of style polish. Also I would have wanted the script to run untill
#a valid option was entered, and add a "usage:..." echo statemen. But it is REALLY late and I am
#about to fall asleep on the keyboard :)
#Script made by Gian Paolo Mureddu on july 19th 2003@4:46 CST (10:46 GMT)


echo "Kernel version you want to delete?"
read KERNVER

TRY=`uname -r`

LIST=`ls /lib/modules/ | grep $KERNVER`

if [ "$LIST" != "$KERNVER" ]
   then
	echo "Kernel version does not exist!"
	exit 1
fi

if [ "$KERNVER" = "$TRY" ]
   then
	echo "You are trying to delete your currently running kernel!!"
	echo "aborting"
	exit 1
   else
	echo "Deleting modules for kernel $KERNVER"
	rm -rf /lib/modules/"$KERNVER"
	echo "Deleting kernel from /boot"
	rm -f /boot/*$KERNVER
	
fi


echo "Kernel removal concluded"
I hope this helps

Last edited by Thetargos; 07-19-2003 at 05:50 AM.
 
Old 07-19-2003, 10:58 PM   #5
camelrider
Member
 
Registered: Apr 2003
Location: Juneau, Alaska
Posts: 251

Rep: Reputation: 32
Very nice.
 
Old 07-20-2003, 01:53 AM   #6
praveen_2003
Member
 
Registered: Apr 2003
Location: india
Posts: 144

Original Poster
Rep: Reputation: 15
thank you very much thetargos.it helped me.but i ran this script which u posted earlier.i ran it without specifing the kernel's version to remove which ended in ^^^^.i did "#<script>" that's all.all the files in my /boot and modules folder disappeared.this is what the script i ran.
#!/bin/bash
#Script to recursively erase a kernel install
rm -rf /lib/modules/"$1"
echo "Deleting direcotry /lib/modules/$1"
rm -f /boot/*"$1"
echo "Deleting kernel $1 from boot"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel compilation : to remove a kernel which files should be deleted b0nd Linux - Newbie 2 08-17-2005 12:35 PM
remove old kernel laurentwahl Linux - General 5 05-14-2005 02:55 PM
how to remove a kernel lucs Slackware 5 05-03-2005 01:42 AM
how do I remove new kernel? jmral23 Linux - Newbie 1 02-09-2005 06:48 PM
remove kernel collimate Linux - Newbie 4 12-03-2003 03:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:03 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