LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-02-2007, 01:37 AM   #1
ankit4u1
Member
 
Registered: Apr 2006
Distribution: Red Hat, Fedora
Posts: 97

Rep: Reputation: 15
Help building a kernel


Hi,

I have RHEL 5(kernel 2.6.18-8)
I did make menuconfig in /usr/src/kernels/2.6..../ and selected the modules I wanted to.

Now, I did make....and I got the following error

Code:
CHK  include/linux/version.h
CHK  include/linux/utsrelease.h
make[1]: ***No rule to make target `init/make.o`, needed by `init/built-in.o`.
Stop
make: *** [init]Error 2
Where am I going wrong ? How should I proceed further in building the kernel ?

I would appreciate your help as I am pretty much new to linux. Thanks

 
Old 08-02-2007, 01:52 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Did you install the headers as well as the source?
 
Old 08-02-2007, 01:57 AM   #3
ankit4u1
Member
 
Registered: Apr 2006
Distribution: Red Hat, Fedora
Posts: 97

Original Poster
Rep: Reputation: 15
The source was by default when I installed RHEL 5. This is the default built in Kernel source with the RHEL 5. I did not configure another kernel.

I mean, after I installed RHEL 5, there was source in this folder:

/usr/src/kernels/2.6.8-18.el5-i686/

Then I installed Openswan and OCF. So, I had to select IPSec and OCF modules by doing "make menuconfig". And then as described in above post, I did 'make' and got the error.
 
Old 08-02-2007, 02:14 AM   #4
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Ah... if you intend only to compile new modules, you can try:

make modules
make modules install

You don't need to recompile the whole kernel.

However, you should realize that the entire set of kernel headers may not be installed by default. Look for kernel related stuff with up2date.
 
Old 08-02-2007, 02:21 AM   #5
ankit4u1
Member
 
Registered: Apr 2006
Distribution: Red Hat, Fedora
Posts: 97

Original Poster
Rep: Reputation: 15
I did 'make modules' and I got following errors:

Code:
CHK  include/linux/version.h
CHK  include/linux/utsrelease.h
make[1]: ***No rule to make target `arch/i386/kernel/msr.c`, needed by `arch/1386/kernel/msr.o'. Stop
make: *** [arch/i386/kernel] Error 2
Do I need to do make modules from the same directory? /usr/src/kernels/2.6..../ ?
 
Old 08-02-2007, 02:27 AM   #6
ankit4u1
Member
 
Registered: Apr 2006
Distribution: Red Hat, Fedora
Posts: 97

Original Poster
Rep: Reputation: 15
My up2date file is as follows: I am a newbie, so do not understand much: Is there any good tutorial on linux and rebuilding kernel, making modules...etc ?


# Red Hat Update Agent config file.
# Format: 1.0

debug[comment]=Whether or not debugging is enabled
debug=0

Code:
systemIdPath[comment]=Location of system id
systemIdPath=/etc/sysconfig/rhn/systemid

serverURL[comment]=Remote server URL
serverURL=https://xmlrpc.rhn.redhat.com/XMLRPC

enableProxy[comment]=Use a HTTP Proxy
enableProxy=0

versionOverride[comment]=Override the automatically determined system version
versionOverride=

httpProxy[comment]=HTTP proxy in host:port format, e.g. squid.redhat.com:3128
httpProxy=

noReboot[comment]=Disable the reboot actions
noReboot=0

networkRetries[comment]=Number of attempts to make at network connections before giving up
networkRetries=5

disallowConfChanges[comment]=Config options that can not be overwritten by a config update action
disallowConfChanges=noReboot;sslCACert;useNoSSLForPackages;noSSLServerURL;serverURL;disallowConfChanges;

sslCACert[comment]=The CA cert used to verify the ssl server
sslCACert=/usr/share/rhn/RHNS-CA-CERT
 
Old 08-02-2007, 03:30 AM   #7
ankit4u1
Member
 
Registered: Apr 2006
Distribution: Red Hat, Fedora
Posts: 97

Original Poster
Rep: Reputation: 15
I read in another post that, RHEL 4 does not have full kernel source with it. so, it won't allow to do make.

Would this be the same case with RHEL 5 ? May be because of that, I am getting error, while doing make.

See the last post of this thread:

http://www.linuxquestions.org/questi...hreadid=377497

If I need to compile a new kernel, can anybody suggest a good tutorial for this...I am newbie..so please help ! Thanks
 
Old 08-02-2007, 04:48 AM   #8
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Correct - neither redhat nor fedora ship with the source or headers. Unless you have reason to believe they have been installed for you by someone else, then they haven't. Sorry, I misread post #3 to mean that you had installed RHEL from source.

To install source and headers, you use the up2date utility ... man up2date (you enter up2date in the commandline). You are, of course, using a registered installation?
 
Old 08-02-2007, 06:09 AM   #9
cdcshu
Member
 
Registered: Jul 2006
Location: Shanghai
Distribution: Fedora, OpenSUSE
Posts: 31

Rep: Reputation: 16
One way to download and compile EL kernel

Hello,

Although I have no experience on EL5 custom kernel compiling, I did do that on EL4 with my PC. So the following may help you out.

Part One : Download && Install RED HAT EL src rpm.

1. EL5 Kernel Source Code URL[Maybe right:-(]
ftp://ftp.redhat.com/pub/redhat/linu...t/en/os/SRPMS/

Download the kernel version as the one on your PC by "uname -r".

2. Install the SRC RPM;
rpm -ivh kernel-2.6.x-xx.EL.src.rpm

Part Two : Re-install the Kernel Source Code Tree.

1. The installed kernel SRC RPM was defaultly put at /usr/src/redhat/SOURCES;

2. Switch to kernel source code rpm SPEC location - /usr/src/redhat/SPECS;

3. Edit SPEC file - kernel-2.6.spec to build source code tree with RPM sth like as
follows to enable kernel source build.

8 %define buildsource 1

49 %ifarch noarch
50 %define builddoc 1
51 %define buildsource 1

4. Execute as root:
#rpmbuild -ba --target=`uname -m` ./kernel-2.6.spec
[Note : The time should be very long for a newbie:-) Pls be patient and go out for some tea if really boring. Me - one hour]

5. The final build source code tree was placed at /usr/src/redhat/BUILD/

Part Three : Compile the installed kernel code as you like.

The final build source code tree was placed at /usr/src/redhat/BUILD/.

However, a safe process would be like this for a newbie. Firstly, pls use the default kernel config for the kernel compiling practice. Once familar with it, switch to compile the kernel at will.

One recommeded process for build a default kernel could be :
[As EL4 as an example]

1. Switch to kernel source code location.

[root@test kernel]# cd /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9

2. Check kernel config file whether same as the local default one.

[root@test linux-2.6.9]# ls
arch CREDITS drivers init lib mm REPORTING-BUGS
sound configs crypto fs ipc MAINTAINERS net scripts
usr COPYING Documentation include kernel Makefile README security
[root@test linux-2.6.9]# ls configs/
kernel-2.6.9-i686.config kernel-2.6.9-ppc64-largesmp.config
kernel-2.6.9-i686-hugemem.config kernel-2.6.9-ppc.config
kernel-2.6.9-i686-smp.config kernel-2.6.9-s390.config
kernel-2.6.9-ia64.config kernel-2.6.9-s390x.config
kernel-2.6.9-ia64-largesmp.config kernel-2.6.9-x86_64.config
kernel-2.6.9-ppc64.config kernel-2.6.9-x86_64-largesmp.config
kernel-2.6.9-ppc64iseries.config kernel-2.6.9-x86_64-smp.config
[root@test linux-2.6.9]#
[root@test linux-2.6.9]# diff -purN /boot/config-2.6.9-34.ELsmp configs/kernel-2.6.9-i686-smp.config
--- /boot/config-2.6.9-34.ELsmp 2006-02-25 06:01:39.000000000 +0800
+++ configs/kernel-2.6.9-i686-smp.config 2007-07-03 10:27:18.000000000
+0800
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.9-34.ELsmp
-# Fri Feb 24 16:52:54 2006
+# Linux kernel version: 2.6.9-prep
+# Tue Jul 3 10:27:18 2007
#
CONFIG_X86=y
CONFIG_MMU=y
[root@test linux-2.6.9]#

Obviously, they are the same. So let's go on to compile it.

3. Edit the Makefile with a special tag.
#EXTRAVERSION = -prep
EXTRAVERSION = -test-2.6.9-34

4. Config the kernel with the default config file.

[root@test linux-2.6.9]# cp configs/kernel-2.6.9-i686-smp.config .config
[root@test linux-2.6.9]# make menuconfig

Just quit with save optional.

[root@test linux-2.6.9]# make
[Note : The process may take half an hour or so. It depends on your HW configuration]
[root@test linux-2.6.9]# make modules_install
[root@test linux-2.6.9]# make install

Finally, check the grub config file - /etc/grub.conf and by default the compiled
kernel valid as the default item. [Optional]

Uh, still one thing. You'd better not remove the default workable kernel configuration from grub.conf to avoid later new kernel crash by switching to it for system recovery.

OK, now reboot your computer:-)

Have fun,

cdcshu

Last edited by cdcshu; 08-02-2007 at 09:57 PM.
 
Old 08-02-2007, 06:57 AM   #10
ankit4u1
Member
 
Registered: Apr 2006
Distribution: Red Hat, Fedora
Posts: 97

Original Poster
Rep: Reputation: 15
No, it is not a registered version ! The procedure of recompiling seems to be very long. I am doing it.....Thanks for this wonderful reply....Seems to be all new technical terms and complex but the explanation is awesome...

I am carrying on..Hopefully everything goes right
 
Old 08-02-2007, 07:52 PM   #11
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Quote:
Originally Posted by ankit4u1
No, it is not a registered version !
That makes a difference... if you had registered you could have bypassed a great deal of the setup using up2date. Not registered, you cannot use up2date and you should consider your distro to be unsupported! You still have access to GPL code though.

Strongly urge you use a supported distro - CentOS is closest (read: "identical") and fedora is well set up too.
Quote:
The procedure of recompiling seems to be very long. I am doing it.....Thanks for this wonderful reply....Seems to be all new technical terms and complex but the explanation is awesome...
That's what you get for using an unsupported distro... you gets to support it yourself

Don't worry, it's not as long as it looks.
 
Old 08-02-2007, 11:17 PM   #12
ankit4u1
Member
 
Registered: Apr 2006
Distribution: Red Hat, Fedora
Posts: 97

Original Poster
Rep: Reputation: 15
When I did

rpm -ivh kernel.......
I got this error

Code:
warning: group brewbuilder does not exist: using root
I logged in as a root only, yet it shows me this error. I then saw the SOURCES and SPECS directory. The SOURCES is having lots of patches and SPECS has kernel-2.6.spec

I am not proceeding as I don't want to go wrong anywhere..

Also, in case something goes wrong, what are the things to back up, so that i can revert back to the original one....

I have saved /usr/src/redhat , /usr/src/kernels, /lib/modules/ folders...

What else would you recommend to back up?
 
Old 08-03-2007, 12:25 AM   #13
cdcshu
Member
 
Registered: Jul 2006
Location: Shanghai
Distribution: Fedora, OpenSUSE
Posts: 31

Rep: Reputation: 16
Why not go ahead?

Hi ankit4u1,

warning is not error to me. It just gave you a note that the process you did is not
the recommended way[Here I guess the rpm execution way]. But not a big deal. Anyway, you have installed the src rpm.

To make your compiling safety, you'd better back up /boot folder as /boot-old and /etc/grub.conf as /etc/grub.conf.old as my preferred way.

Then go ahead as the doc says and post the problem with detailed info if had. I am interested with the result on EL5.

Good luck,

cdcshu
 
Old 08-03-2007, 02:39 AM   #14
ankit4u1
Member
 
Registered: Apr 2006
Distribution: Red Hat, Fedora
Posts: 97

Original Poster
Rep: Reputation: 15
Ok going ahead...I tried with %no arch...but that gave me errors in rpmbuild. So, I

1) deleted the kernel directory in /BUILD/
2) removed lines 8 49 50 51 from SPEC file
3) did rpmbuild again

Its going on now without any errors...I'll update you if I get any errors in detail !!! Thanks buddy for the help.
 
Old 08-03-2007, 03:10 AM   #15
cdcshu
Member
 
Registered: Jul 2006
Location: Shanghai
Distribution: Fedora, OpenSUSE
Posts: 31

Rep: Reputation: 16
I missed one note:-(

Uh, sign... I missed one key note in the doc.

The key point of edit kernel-2.6.spec is to enable build source. So you need to change "%define buildsource 0" to "%define buildsource 1". By default, EL won't install the full kernel source for you because of this - build source is disabled by default.

OK, just wait to see whether the kernel source tree is installed
at /usr/src/redhat/BUILD after the build process.

If not, pls recover the spec file and edit it to support build source and replay the game:-)

Nice weekend:-)

cdcshu

Last edited by cdcshu; 08-03-2007 at 03:11 AM.
 
  


Reply

Tags
build, kernel, module


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 panic after building custom kernel for macbook sparrott Linux - Laptop and Netbook 1 06-29-2007 06:06 PM
Building kernel module from multiple source file in 2.6 kernel yogeshwar_s Programming 1 12-20-2004 10:31 AM
Problems building a simple kernel module for kernel 2.6.7 atticman Linux - Software 2 12-13-2004 04:35 PM
building a kernel mindcry Linux - Software 2 05-11-2004 01:06 PM
Building kernel mods for an existing kernel ugenn Linux - Software 2 10-06-2003 02:25 PM


All times are GMT -5. The time now is 01:14 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration