Please help on patching & compiling Kernel...

General support questions including new installations
Farnsworth
Posts: 3
Joined: 2009/12/05 13:12:26

Please help on patching & compiling Kernel...

Post by Farnsworth » 2009/12/05 13:22:42

Hi everyone, I have been trying for few days on patching and compiling a Kernel, but got no success. I have been searching the web for pointers, but those I have found are very confusing. I did try them, yet same result. :-(

I am trying to patch and compile with the following:
--------------------------
Kernel: linux-2.6.31.6.tar.gz
(http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.6.tar.gz)

Patch: patch-2.6.31.6-rt19.gz
(http://www.kernel.org/pub/linux/kernel/projects/rt/patch-2.6.31.6-rt19.gz)
--------------------------

After modifying the Kernel options, I compile it by doing:
--------------------------
make clean
make bzImage
make modules
make modules_install
make install
--------------------------

And when booting with the Kernel, I get this issue:
--------------------------
insmod: error inserting '/lib/dm-region-hash.ko' : -1 File exists
mount: could not find filesystem '/dev'root' x83
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!
--------------------------

Any help would be appreciated.

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: Please help on patching & compiling Kernel...

Post by AlanBartlett » 2009/12/05 14:38:54

Have you read the introduction to the [i]CentOS[/i] wiki [url=http://wiki.centos.org/HowTos/Custom_Kernel]Custom Kernel article[/url]?

I should really say that you are on your own, as there is no support for kernels not built from the [i]CentOS[/i] sources. However . . .

Please try the following:

(1) Set up your own [i]rpm build environment / tree[/i] using your own ID. Do not use the [b]/usr/src/[/b] directory structure or [i]root[/i]'s ID. See: [url=http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment]Setup an RPM Build Environment[/url].
(2) Extract the sources from the tarball in an appropriate location.
(3) Extract the patches from the tarball in an appropriate location.
(4) Patch the sources.
(5) Copy the configuration file of the [i]CentOS[/i] kernel that you are currently running to the top directory of the source tree. i.e. [b]cd ~/linux-2.6.31.6; cp /boot/config-$(uname -r) .config[/b]
(6) Execute "[b]make oldconfig[/b]" and accept the defaults to all the new questions.
(7) Execute "[b]make menuconfig[/b]" and configure as you wish.
(8) Change directory to [b]~/linux-2.6.31.6/scripts/package/[/b] and append the following lines to the [b]mkspec[/b] file --

[code]
echo "%post"
echo "if [ \`uname -i\` == \"x86_64\" -o \`uname -i\` == \"i386\" ]; then"
echo " if [ -f /etc/sysconfig/kernel ]; then"
echo " /bin/sed -i -e 's/^DEFAULTKERNEL=kernel-smp$/DEFAULTKERNEL=kernel/' /etc/sysconfig/kernel || exit \$?"
echo " fi"
echo "fi"
echo "/sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install "$KERNELRELEASE" || exit \$?"
echo ""

echo "%preun"
echo "/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove "$KERNELRELEASE" || exit \$?"
echo ""
[/code]
(9) Change directory to [b]~/linux-2.6.31.6/[/b] and build the kernel as an [i]rpm package[/i] --

[code]
[b]make CONFIG_DEBUG_SECTION_MISMATCH=y binrpm-pkg 2> make-err.log | tee make-out.log[/b]
[/code]
(10) Assuming a successful build (check the log files), you will then find your new [i]kernel-2.6.31.6-1.*.rpm[/i] package in your [b]~/rpmbuild/RPMS/{i386|x86_64}/[/b] directory.
(11) (Optionally) Sign the package. (i.e. [b]rpm --addsign kernel-2.6.31.6-1.*.rpm[/b]).
(12) Install the package -- [b]rpm -ivh kernel-2.6.31.6-1.*.rpm[/b]
(13) Reboot, specifying the new kernel -- to [b]single user mode[/b], for the initial test.
(14) If the initial test proves to be satisfactory . . . :-D . . . just exit the single-user shell to go to your normal multi-user run-level and continue to test. If the initial test fails . . . :-x . . . you're on your own.

Farnsworth
Posts: 3
Joined: 2009/12/05 13:12:26

Re: Please help on patching & compiling Kernel...

Post by Farnsworth » 2009/12/18 23:21:28

Hi Alan,

Thank you so much for your kind reply. It is very informative. I really appreciate it.

I tried both your approach, and the one from the CentOS wiki. Unfortunately I didn't have any success.

Before coming back to this thread, I spent some time playing around with it and doing some more Google search, but still no luck. I then tried doing it on Debian and Ubuntu and I was able to compile my custom kernel, and it has been running fine for the past two weeks.

Yet I would like to learn how to use CentOS and I will post a more detailed info regarding the issues that I encountered with CentOS.

I hope you would give me some pointers when you have time.


Happy Holidays!! :-)

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: Please help on patching & compiling Kernel...

Post by AlanBartlett » 2009/12/19 14:03:41

[quote]
Happy Holidays!! :-)
[/quote]
Thank you.

Please be aware that everything I wrote in post #2, above, is [b]not[/b] [i]CentOS[/i]. I suspect your problem originates in applying steps (3) & (4) because I have recently performed steps (1), (2) & (5) to (14) with a perfectly satisfactory result for the mainline kernel-2.6.32.1 sources.

However I must stress, once again, that [b]no support[/b] is available for self-built kernels using the mainline kernel sources and that there is only [i]limited support[/i] available for self-built kernels using the latest [i]CentOS[/i] kernel sources, as detailed in the [url=http://wiki.centos.org/HowTos/Custom_Kernel]Custom Kernel[/url] article. (Kernel 2.6.18-164.9.1.el5 as of the date of this posting.)

helikaon
Posts: 55
Joined: 2008/12/10 14:30:04

Re: Please help on patching & compiling Kernel...

Post by helikaon » 2010/01/10 14:40:40

Hi there guys,
i'm in exactly same boat - same problem during boot as in the first post.
Trying to compile 2.6.32.2 kernel for my centos 5.4.
reason: laptop installation, would like to get support for my wifi card.

i went along this howto:
http://www.howtoforge.com/kernel_compilation_centos

I already used this howto couple of times successfully (basicly same steps like the post alan described) in post above. My last success was 2.6.31 kernel on x86 (old P4 machine) with root fs on lvm.
However, I can't get it working on my laptop. Somehow i simply doesn't read the / (root) on lvm.
I suspect (wild guess) perhaps version mkinitrd could be involved - or even the lvm (like placement of lvm binaries)?? Damn i spent last 4 days on it, no success so far...

Just letting you know, you're not alone in this ...

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: Please help on patching & compiling Kernel...

Post by AlanBartlett » 2010/01/10 15:17:06

[quote]
reason: laptop installation, would like to get support for my wifi card.
[/quote]
Please start a new thread for your WiFi card support and post the output returned by the following --

[code]
[b]for BUSID in $(/sbin/lspci | awk '{ IGNORECASE=1 } /net/ { print $1 }'); do /sbin/lspci -s $BUSID -m; /sbin/lspci -s $BUSID -n; done[/b]
[/code]
To go to the trouble of building your own kernel just to provide a driver module is somewhat analogous to using a sledgehammer to crack a peanut (using an English analogy).

The failure to build a working version the current stable mainline kernel (2.6.32.3, as of the date of this posting) seems to be rather common. A certain [b]NedSlider[/b] can also attest to the disk driver / not finding the root partition issue. Although there is [i][b]no[/b][/i] support for custom kernels built from the mainline sources and only limited support for custom kernels built from the latest [i]CentOS[/i] sources (2.6.18-164.10.1.el5, as of the date of this posting), I can confirm that I am [i]unable[/i] to reproduce the failure. :-o

Invoking [b]rpm -qa kernel\* | sort[/b] and [b]uname -a[/b] on my workstation results in the following output --

[code]
$ rpm -qa kernel\* | sort
kernel-2.6.18-128.el5
kernel-2.6.18-164.el5
kernel-2.6.18-53.el5
kernel-2.6.18-8.el5
kernel-2.6.18-92.el5
kernel-2.6.32.3-1
kernel-devel-2.6.18-164.el5
kernel-devel-2.6.18-8.el5
kernel-headers-2.6.32.3-1
kernel-PAE-devel-2.6.18-164.el5
kernel-PAE-devel-2.6.18-8.el5
kernel-xen-devel-2.6.18-164.el5
kernel-xen-devel-2.6.18-8.el5
$ uname -a
Linux stxsl 2.6.32.3 #1 PREEMPT Thu Jan 7 17:17:12 GMT 2010 i686 i686 i386 GNU/Linux
[/code]

adamos
Posts: 47
Joined: 2008/06/04 20:11:36
Location: nj
Contact:

Re: Please help on patching & compiling Kernel...

Post by adamos » 2010/01/22 23:40:31

I haven't been able to compile the latest kernel either. I get the same errors - cannot find /. I tried it in a vm, in my workstation and on my laptop but it was a no go.

If anyone has any details how to work around this issue I would really appreciate it.

-Adam

michaelnel
Posts: 1478
Joined: 2006/05/29 16:50:11
Location: San Francisco, CA

Re: Please help on patching & compiling Kernel...

Post by michaelnel » 2010/01/23 00:51:03

[quote]
AlanBartlett wrote:
To go to the trouble of building your own kernel just to provide a driver module is somewhat analogous to using a sledgehammer to crack a peanut (using an English analogy).[/quote]

The analogy I prefer is "swatting flies with a grand piano", but either one makes the point.

vanecka
Posts: 45
Joined: 2010/01/28 21:05:11
Location: University of the Free State - South Africa
Contact:

Re: Please help on patching & compiling Kernel...

Post by vanecka » 2010/01/28 22:16:01

Had the same problem with CentOS 5.4 and Kernel 2.6.32.5.
Seemed that the SAS or SCSI hard drive modules weren't initializing.

Fix:
Enable CONFIG_SYSFS_DEPRECATED_V2 in the kernel source configuration.
If you run "make menuconfig", browse to:
General Setup ---> enable deprecated sysfs features which may confuse old usersp, and enable this option.
Exit the menu configurator and save your changes.
Continue with kernel compiling as per usual eg:
make && make modules && make modules_install && make install
---OR---
Edit your .config file with a text editor and add/modify entry:
CONFIG_SYSFS_DEPRECATED_V2=y

Save the .config file
Continue with kernel compiling as per usual eg:
make && make modules && make modules_install && make install


Hope this helps

User avatar
toracat
Site Admin
Posts: 7518
Joined: 2006/09/03 16:37:24
Location: California, US
Contact:

Re: Please help on patching & compiling Kernel...

Post by toracat » 2010/01/28 23:52:35

[quote]
vanecka wrote:

Edit your .config file with a text editor and add/modify entry:
CONFIG_SYSFS_DEPRECATED_V2=y
[/quote]
Thank you. You are a genius. It immensely helped. :-)

I was able to build and boot kernel 2.6.32-4 with that change applied.

Post Reply