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 02-20-2006, 10:18 AM   #1
solarblast
LQ Newbie
 
Registered: Nov 2004
Posts: 21

Rep: Reputation: 15
Backing Out of a Kernel Build


Is there some standard procedure for backing out of a kernel build? I built a realtime kernel on top of a regular Linux kernel from instructions provided by the creators or rt linux. I would like to remove rtlinux and start again without re-installing Linux.

The build takes place in /usr/src/linux and /usr/src/rtlinux. Is it possible that it's as easy as running "make clean" in each of these two directories?

I know not everything takes place in these two directories, since there's a LILO modification, but mainly those two carry the weight of the install. Here's how the procedure starts off:

2. Installation of RTLinux 3.2-pre2
===================================

2.1 Source
----------
* Linux-Kernel 2.4.20
http://www.kernel.org/pub/linux/kern...-2.4.20.tar.z2
* RTLinux 3.2-pre2
http://www.rtlinux-gpl.org/
http://www.opentech.at/pub/rtlinux/r...2-pre2.tar.bz2



2.2 Extracting
--------------
# cd /usr/src/

* Remove existing links
# rm linux
# rm linux-2.4

* Copy the files into the directory /usr/src/
# cp /tmp/linux-2.4.20.tar.bz2 .
# cp /tmp/rtlinux-3.2-pre2.tar.bz2 .

* Test the files
# tar -tjf linux-2.4.20.tar.bz2
# tar -tjf rtlinux-3.2-pre2.tar.bz2

* Extract the files
# tar -xjf linux-2.4.20.tar.bz2
# tar -xjf rtlinux-3.2-pre2.tar.bz2

* Change owner
# chown -R root:root linux-2.4.20/
# chown -R root:root rtlinux-3.2-pre2/

2.3 Patching
------------

patches are to be found in the patches directoy in the source tree of rtlinux-3.2-pre2 or on the web at http://www.rtlinux-gpl.org -> Brrowse -> rtlinux-3.2-pre2 -> patches. Check the current development tree for the latest patches.

* Create new links
# mv linux-2.4.20/ linux-2.4.20-rtl3.2-pre2
# ln -s linux-2.4.20-rtl3.2-pre2/ linux
# ln -s rtlinux-3.2-pre2/ rtlinux
# cd linux/

* Test kernel patch
# patch -p1 --dry-run < ../rtlinux/patches/kernel_patch-2.4.20-rtl3.2-pre2

* Perform patch
# patch -p1 < ../rtlinux/patches/kernel_patch-2.4.20-rtl3.2-pre2

2.4 Kernel Configuration
------------------------
# cd /usr/src/linux/
# make menuconfig
...
 
Old 02-20-2006, 11:41 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
You need to be a little clearer about what you need to back out of. From the instructions you posted, it doesnt' look like you ever made or installed the new kernel. Could you provide a few more details?
 
Old 02-20-2006, 11:47 AM   #3
solarblast
LQ Newbie
 
Registered: Nov 2004
Posts: 21

Original Poster
Rep: Reputation: 15
Oh, I made the full install. I only copied part of the install procedure, since it's two pages long. I figured that the part that didn't include work in /usr/src/linux and /usr/src/rtlinux might be sufficient to deal with issues outside those to directories. Here are all the steps, step 2.10 is unnecessary:

2. Installation of RTLinux 3.2-pre2
===================================

2.1 Source
----------
* Linux-Kernel 2.4.20
http://www.kernel.org/pub/linux/kern...-2.4.20.tar.z2
* RTLinux 3.2-pre2
http://www.rtlinux-gpl.org/
http://www.opentech.at/pub/rtlinux/r...2-pre2.tar.bz2



2.2 Extracting
--------------
# cd /usr/src/

* Remove existing links
# rm linux
# rm linux-2.4

* Copy the files into the directory /usr/src/
# cp /tmp/linux-2.4.20.tar.bz2 .
# cp /tmp/rtlinux-3.2-pre2.tar.bz2 .

* Test the files
# tar -tjf linux-2.4.20.tar.bz2
# tar -tjf rtlinux-3.2-pre2.tar.bz2

* Extract the files
# tar -xjf linux-2.4.20.tar.bz2
# tar -xjf rtlinux-3.2-pre2.tar.bz2

* Change owner
# chown -R root:root linux-2.4.20/
# chown -R root:root rtlinux-3.2-pre2/

2.3 Patching
------------

patches are to be found in the patches directoy in the source tree of rtlinux-3.2-pre2 or on the web at http://www.rtlinux-gpl.org -> Brrowse -> rtlinux-3.2-pre2 -> patches. Check the current development tree for the latest patches.

* Create new links
# mv linux-2.4.20/ linux-2.4.20-rtl3.2-pre2
# ln -s linux-2.4.20-rtl3.2-pre2/ linux
# ln -s rtlinux-3.2-pre2/ rtlinux
# cd linux/

* Test kernel patch
# patch -p1 --dry-run < ../rtlinux/patches/kernel_patch-2.4.20-rtl3.2-pre2

* Perform patch
# patch -p1 < ../rtlinux/patches/kernel_patch-2.4.20-rtl3.2-pre2

2.4 Kernel Configuration
------------------------
# cd /usr/src/linux/
# make menuconfig
* Configure the Kernel

# cp .config my_config
# make mrproper
# cp my_config .config
# make oldconfig
# make dep
# make

2.5 Kernel Installation
-----------------------
* Create a kernel image
# make bzImage

* Copy the image into the boot partition
# cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.20-rtl3.2-pre2

* Make and install kernel modules
# make modules modules_install

2.6 LILO Configuration
----------------------
* Add an entry for rtl:
# vi /etc/lilo.conf
+ image=/boot/vmlinuz-2.4.20-rtl3.2-pre2
+ label=rtlinux
+ read-only
+ root=/dev/hda2

* Update changes
# lilo

2.7 RTLinux Configuration
-------------------------
# cd /usr/src/rtlinux/
# make menuconfig
* Configure RTLinux

# cp .config my_config
# make clean
# cp my_config .config
# make oldconfig
# make dep
# make

2.8 RTLinux Installation
------------------------
# make modules modules_install

2.9 Reboot
----------
# lilo -R rtlinux
# reboot

2.10 Regression test
--------------------
# cd /usr/src/rtlinux/
# scripts/regression.sh
* Testing multiple loads of rtl.o
* Testing multiple loads of rtl_time.o
* Testing multiple loads of rtl_posixio.o
* Testing multiple loads of rtl_fifo.o
* Testing multiple loads of rtl_sched.o
- Testing RTLinux fifos
. Testing thread wait times
* Testing that Linux time progresses
* Testing that Linux time is monotonically increasing
* Testing ping flood
. Testing floating-point support
* Removing rtl_sched.o
. Testing periodic timer
. Testing oneshot timer
 
Old 02-20-2006, 11:56 AM   #4
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
OK, I'm still not entirely clear on what you want to do, but here are a couple of things to think about

- If you are just looking to clean up the source code, you're proabably best just deleting the directories you've been using in /usr/src and re-extracting the tarballs. I don't think there is a way to unpatch source code so if you want clean source code, re-extracting is probably the way to go.

-If you need to use your old kernel, you may be in luck if you've only done one compile. Usually, the kernel (vmlinuz) is renamed with a .old extension (vmlinuz.old) during the make install step. You can just add a LILO entry for that kernel and boot to it. However, if you have run more than one make install, you've effectively wiped out the original kernel and you probably need to re-install from your distro CD. Or use the clean source code and compile a new one.
 
Old 02-20-2006, 12:17 PM   #5
solarblast
LQ Newbie
 
Registered: Nov 2004
Posts: 21

Original Poster
Rep: Reputation: 15
Thanks. I a little surprised that the kernel builders don't provide for some way to back out. BTW, what's distroclean in the Makefiles? I think that's the entry. Sounds like it might take out everything, including Linux itself!

Interesting remark about "make install". Notice that it's missing from the procedure. It's found in the application user's manual for the app I'm using. I'm surprised the creators haven't caught it. I only entered "make install" once, so I think I'll be OK. Well, I haven't got much to lose on trying to remove the rtlinux kernel. My app hangs the machine when I try to start it: rtlinux start (a script), then smodule.o follows it on the next line of the Maekfile to start it up. The last thing I see is "rtlinux start" before the hang.

To remove the two directories, I would think I would run something like the following as root:

rmdir -f -r /usr/src/linux
rmdir -f -r /usr/src/rtlinux

-f = force", -r - recursive

I'm pretty much an end (app) user, so that seems like the right command.
 
Old 02-20-2006, 01:09 PM   #6
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Those commands should do the trick, however one thing I personally do before using the -rf as root is actually get into the directory I'm deleting. That way typos have less of a chance of having a nuclear effect. For example, all you need is an accidental space between / and usr and your system is toast.
 
Old 02-20-2006, 06:07 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
It may be a little late but ...

(1) Before making any patches to your kernel, you should make a separate backup copy of the entire /usr/src/linux tree, including any hidden files such as .config. I use zip for that... and put the resulting file far away.

(2) You should also make a corresponding backup copy of the /boot directory.

(3) A kernel-build begins by compiling all of the materials. If all of the compiles are successful, a new kernel-image file is built (first in arch/i386/boot). If those steps didn't work, then nothing has happened to your system, but then again you also have a non-compileable kernel source file (unless you made that backup).

(4) When you install the kernel, a copy is placed in /boot and the appropriate boot-loader control files are updated. You need to make it your business to be certain that you have a copy of the old, "known good", kernel, and the means (and the know-how) to boot it.

(5) When dealing with the kernel, in any capacity, you need to carefully think through your "what happens if this doesn't work" strategy. Alas, I'm not sure that you did that. You've probably got the same kernel you once did, and crufted, uncompileable kernel-source.
 
Old 02-20-2006, 11:09 PM   #8
solarblast
LQ Newbie
 
Registered: Nov 2004
Posts: 21

Original Poster
Rep: Reputation: 15
Good comments all. I'm printing this thread directly as I would a web page. Maybe there's some facility here for making a better looking print out?

(P.S. I've noted the thread below about backing up the kernel, in addition to the post above.)
 
  


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
Backing up my kernel. Synt4x_3rr0r Slackware 15 01-11-2006 03:44 PM
10.1 install kernel and kernel-source different - build fails Feebles Mandriva 2 06-10-2005 06:58 PM
kernel-source-2.6.5-7.src.rpm requires kernel-dummy to build!? fizzdandantilus SUSE / openSUSE 5 12-02-2004 12:48 PM
New FAQ topic: Should I edit my kernel configuration?/Should I build a custom kernel? chort *BSD 10 09-10-2004 11:15 PM
Unable to build NVIDIA kernel module / determin kernel version Night Ink Fedora 2 05-31-2004 04:54 PM

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

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