PDA

View Full Version : Compile i686 kernel simplified


tcrop
2007-02-03, 05:40 AM CST
Many have attempted to build an i686 kernel only to end up with a i386 kernel instead. The following steps will allow you to build the i686 kernel without jumping through a lot of hoops.

We will build a 2.6.19 kernel, which is the most current version at this time [02-03-2007].

1. Download the kernel source rpm: wget ftp://distro.ibiblio.org/pub/linux/distributions/fedora/linux/core/updates/6/SRPMS/kernel-2.6.19-1.2895.fc6.src.rpm

2. Install source rpm. We will be compiling as root and using the rpm-build directory sturcture. You could of course build as a user by installing fedora-rpmdevtools, then as a user, running fedora-buildrpmtree to create the build directory structure under you home directory and then installing the source package:
rpm -ivh kernel-2.6.19-1.2895.fc6.src.rpm

3. Edit the kernel-2.6.spec file and make changes according to your needs. The following changes work for me.

I turn off Xen kernels because I don't use the feature. What are Xen kernels? "Xen is a paravirtualising virtual machine monitor (VMM), or `hypervisor', for the x86 processor architecture." It is a way to run multiple virtual machines on a single physical machines.

I also don't do kernel dumps.

If you need to build a kernel with the same name as the release then the last modification
will give you what you need. If you know of a better way to accomplish this then please let us know.


Change: %define buildxen 1
To: %define buildxen 0

Change: %define buildkdump 1
To: %define buildkdump 0

Change: perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -prep/" Makefile
To: perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -1.2895.fc6/" Makefile


4. Executes the "%prep" stage from the spec file. This involves unpacking the sources and applying any patches.:
rpmbuild -bp --target i686 /usr/src/redhat/SPECS/kernel-2.6.spec

5. Change to our BUILD directory so we can customize our kernel build.
cd /usr/src/redhat/BUILD/kernel-2.6.19/linux-2.6.19.i686/

6. Delete the current configuration, and all generated files. Were going to start clean here.
make mrproper

7. Copy the i686 config file to .config
cp /usr/src/redhat/SOURCES/kernel-2.6.19-i686.config .config

If you have a customized .conf from a previous build then copy it in to place instead of the above. Then run 'make oldconfig' to update any new functionality.
make oldconfig


8. If you need to customize the kernel do it now by running 'make menuconfig' or 'make xconfig'. make xconfig has options, under options menu, which allow you to see any hidden functionality that are may not be active due to parent features being turned off.
make xconfig

9. Begin compile:
make UTS_MACHINE=i686 rpm

You should then see "Building target platforms: i686" in the build console.

The above process will build a i686 RPM and a SRPM. It does not build initrd - you may need to do that with mkinitrd.
The below names may vary according to your kernel-2.6.spec modifications.

mkinitrd /boot/initrd-2.6.19-prep.img 2.6.19-prep

xen
2007-02-03, 05:45 AM CST
Nice, I'm gonna give this a try and see if I can clear up some of my previous hardware difficulties with patches, thanks!

tcrop
2007-02-03, 06:22 AM CST
I did a uname after booting to the kernel compiled with the above instructions --- I'm not sure what to think about the following:

$ uname -m -p -i
i686 athlon i386

machine: i686
processor: athlon
hardware-platform: i386

sideways
2007-02-03, 07:03 AM CST
I did a uname after booting to the kernel compiled with the above instructions --- I'm not sure what to think about the following:

$ uname -m -p -i
i686 athlon i386

machine: i686
processor: athlon
hardware-platform: i386

That's what you want (assuming you haven't got a really ancient athlon)
Modern athlons support i686 instructions

xen
2007-02-04, 05:28 AM CST
bash: rpmbuild: command not found

Am I missing something obvious? Couldn't find the solution by searching the forum! I have the following installed:

kernel-2.6.19-1.2895.fc6.i686
kernel-devel-2.6.19-1.2895.fc6.i686
kernel-headers-2.6.19-1.2895.fc6.i386

leigh123@linux
2007-02-04, 06:31 AM CST
Am I missing something obvious? Couldn't find the solution by searching the forum! I have the following installed:

Yum install rpm-build


I would also recommend not building a kernel as a root user ;)

dllahr
2007-02-07, 10:23 PM CST
Thank you! I followed the steps and was able to build succesfully on my laptop, running FC 5. Thanks again.

WNorfleet
2007-02-22, 01:44 PM CST
Thanks for this information! I'm curious: After copying /boot/config-2.6.18-1.2257.fc5 to .config in the source tree, running make oldconfig, running make clean, compiling, and installing, /lib/modules/<stock> is 49M in size, whereas /lib/modules/<new> is 363M, where <stock> is the collection of modules in the original installation, and <new> is from the compilation I just performed. Why are "my" modules so numerous/large? Isn't /boot/config-2.6.18-1.2257.fc5 supposed to depict the configuration of the "stock" kernel/modules so that "make oldconfig" based on it should reproduce the original kernel/modules?

Paprika
2007-06-26, 11:42 PM CDT
I need some help with this guide please!

I tried it and got the following error(s):
(this is just the tail end from when it started to look bad)
gcc: vfork: Resource temporarily unavailable
make[3]: *** [arch/i386/kernel/reboot.o] Error 1
make[3]: *** Waiting for unfinished jobs....
CC arch/i386/kernel/cpu/cpufreq/powernow-k8.o
CC arch/i386/kernel/cpu/cpufreq/longrun.o
CC arch/i386/kernel/cpu/cpufreq/speedstep-ich.o
CC arch/i386/kernel/cpu/cpufreq/speedstep-lib.o
CC arch/i386/kernel/cpu/cpufreq/speedstep-smi.o
CC arch/i386/kernel/cpu/cpufreq/speedstep-centrino.o
CC [M] arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.o
CC [M] arch/i386/kernel/cpu/cpufreq/p4-clockmod.o
CC arch/i386/kernel/cpu/mcheck/mce.o
gcc: vfork: Resource temporarily unavailable
make[5]: *** [arch/i386/kernel/cpu/cpufreq/powernow-k7.o] Error 1
make[5]: *** Waiting for unfinished jobs....
CC arch/i386/kernel/cpu/mcheck/k7.o
gcc: vfork: Resource temporarily unavailable
make[5]: *** [arch/i386/kernel/cpu/cpufreq/speedstep-ich.o] Error 1
make[4]: *** [arch/i386/kernel/cpu/cpufreq] Error 2
make[4]: *** Waiting for unfinished jobs....
CC arch/i386/kernel/cpu/mcheck/p4.o
CC arch/i386/kernel/cpu/mcheck/p5.o
CC arch/i386/kernel/cpu/mcheck/p6.o
CC arch/i386/kernel/cpu/mcheck/winchip.o
CC arch/i386/kernel/cpu/mcheck/therm_throt.o
gcc: vfork: Resource temporarily unavailable
make[5]: *** [arch/i386/kernel/cpu/mcheck/mce.o] Error 1
make[5]: *** Waiting for unfinished jobs....
gcc: vfork: Resource temporarily unavailable
make[5]: *** [arch/i386/kernel/cpu/mcheck/k7.o] Error 1
make[4]: *** [arch/i386/kernel/cpu/mcheck] Error 2
make[3]: *** [arch/i386/kernel/cpu] Error 2
make[2]: *** [arch/i386/kernel] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.52742 (%build)


RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.52742 (%build)
make[1]: *** [rpm] Error 1
make: *** [rpm] Error 2


How can i fix this?