Please help on patching & compiling Kernel...

General support questions including new installations

Please help on patching & compiling Kernel...

Postby 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/ ... 1.6.tar.gz)

Patch: patch-2.6.31.6-rt19.gz
(http://www.kernel.org/pub/linux/kernel/ ... .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.
Farnsworth
 
Posts: 3
Joined: 2009/12/05 13:12:26

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

Postby AlanBartlett » 2009/12/05 14:38:54

Have you read the introduction to the CentOS wiki Custom Kernel article?

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

Please try the following:

(1) Set up your own rpm build environment / tree using your own ID. Do not use the /usr/src/ directory structure or root's ID. See: Setup an RPM Build Environment.
(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 CentOS kernel that you are currently running to the top directory of the source tree. i.e. cd ~/linux-2.6.31.6; cp /boot/config-$(uname -r) .config
(6) Execute "make oldconfig" and accept the defaults to all the new questions.
(7) Execute "make menuconfig" and configure as you wish.
(8) Change directory to ~/linux-2.6.31.6/scripts/package/ and append the following lines to the mkspec file --

Code: Select all
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 ""

(9) Change directory to ~/linux-2.6.31.6/ and build the kernel as an rpm package --

Code: Select all
[b]make CONFIG_DEBUG_SECTION_MISMATCH=y binrpm-pkg 2> make-err.log | tee make-out.log[/b]

(10) Assuming a successful build (check the log files), you will then find your new kernel-2.6.31.6-1.*.rpm package in your ~/rpmbuild/RPMS/{i386|x86_64}/ directory.
(11) (Optionally) Sign the package. (i.e. rpm --addsign kernel-2.6.31.6-1.*.rpm).
(12) Install the package -- rpm -ivh kernel-2.6.31.6-1.*.rpm
(13) Reboot, specifying the new kernel -- to single user mode, 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.
User avatar
AlanBartlett
Forum Moderator
 
Posts: 8975
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk

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

Postby 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!! :-)
Farnsworth
 
Posts: 3
Joined: 2009/12/05 13:12:26

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

Postby AlanBartlett » 2009/12/19 14:03:41

Happy Holidays!! :-)

Thank you.

Please be aware that everything I wrote in post #2, above, is not CentOS. 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 no support is available for self-built kernels using the mainline kernel sources and that there is only limited support available for self-built kernels using the latest CentOS kernel sources, as detailed in the Custom Kernel article. (Kernel 2.6.18-164.9.1.el5 as of the date of this posting.)
User avatar
AlanBartlett
Forum Moderator
 
Posts: 8975
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk

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

Postby 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 ...
helikaon
 
Posts: 55
Joined: 2008/12/10 14:30:04

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

Postby AlanBartlett » 2010/01/10 15:17:06

reason: laptop installation, would like to get support for my wifi card.

Please start a new thread for your WiFi card support and post the output returned by the following --

Code: Select all
[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]

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 NedSlider can also attest to the disk driver / not finding the root partition issue. Although there is no support for custom kernels built from the mainline sources and only limited support for custom kernels built from the latest CentOS sources (2.6.18-164.10.1.el5, as of the date of this posting), I can confirm that I am unable to reproduce the failure. :-o

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

Code: Select all
$ 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
User avatar
AlanBartlett
Forum Moderator
 
Posts: 8975
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk

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

Postby 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
adamos
 
Posts: 47
Joined: 2008/06/04 20:11:36
Location: nj

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

Postby michaelnel » 2010/01/23 00:51:03

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).


The analogy I prefer is "swatting flies with a grand piano", but either one makes the point.
michaelnel
 
Posts: 1479
Joined: 2006/05/29 16:50:11
Location: San Francisco, CA

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

Postby 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
vanecka
 
Posts: 27
Joined: 2010/01/28 21:05:11
Location: University of the Free State - South Africa

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

Postby toracat » 2010/01/28 23:52:35

vanecka wrote:

Edit your .config file with a text editor and add/modify entry:
CONFIG_SYSFS_DEPRECATED_V2=y

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.
User avatar
toracat
Forum Moderator
 
Posts: 6695
Joined: 2006/09/03 16:37:24
Location: California, US

Next

Return to CentOS 5 - General Support

Who is online

Users browsing this forum: No registered users and 5 guests