Bembel-B Blog


Rebuilding an FC5 Kernel Optimized for AMD Athlon K7

Filed under: Athlon,build,compile,Fedora,Fedora Core,K7,Kernel,rebuild,RPM,rpmbuild — FrankZabbath @ 23:02

Fedora doesn’t ship with an x86 Athlon (K7 series i.e. Athlons up to Athlon XP) optimized Kernel, so I wanted to build one (the standard one w/o xen etc.) myself. I didn’t find any info on the web about this, except that MK7 has to be enabled in the kernel config.

Fedora Core Logo

Phew, MK7! Sounds scaringly like MI5, MI6 or even MKULTRA.. :))

WARNING: I’m not very familiar with compiling Kernels nor with the Kernel RPMs of Fedora. I once did a vanilla Kernel compile from source and some simple rebuilds of Fedora Kernel RPMs. The described procedure seems to be working for me. But be warned!

0.) Setup non-root rpmbuild environment

Don’t build as root! Be sure to have rpmdevtools RPM installed. Then as the user you want to build with, issue fedora-buildrpmtree. This will setup your rpmbuild environment including a directory ~/rpmbuild.

1.) Get original FC5 Kernel source

Download latest Fedora Kernel source RPM. In my case that is kernel-2.6.17-1.2174_FC5.src.rpm.
Extract the RPM with fedora-extract kernel-2.6.17-1.2174_FC5.src.rpm.

2.) Enable Athlon RPM builds

Create a Kernel config file for Athlon K7 architecture. Do this by copying the kernel-*-i686.config to kernel-*-athlon.config (of course with the * replaced by the Kernel version) and changing that copy like shown in the diff below:

[scheff@p512o kernel-2.6.17-1.2174_FC5]$ diff kernel-2.6.17-athlon.config kernel-2.6.17-i686.config
< # CONFIG_M686 is not set
> CONFIG_M686=y
> # CONFIG_MK7 is not set

This defines an architecture K7 instead of i686.

Edit the kernel-2.6.spec file like shown in this diff:

[scheff@p512o kernel-2.6.17-1.2174_FC5]$ diff kernel-2.6.spec kernel-2.6.spec.orig
< %define buildxen 0
> %define buildxen 1
< %define buildkdump 0
> %define buildkdump 1
< %define release %(R="$Revision: 1.2175 $"; RR="${R##: }"; echo ${RR%%?})_FC5
> %define release %(R="$Revision: 1.2174 $"; RR="${R##: }"; echo ${RR%%?})_FC5
< %define all_x86 i586 i686 athlon
> %define all_x86 i586 i686
< %ifarch athlon
< %define all_arch_configs $RPM_SOURCE_DIR/kernel-%{kversion}-athlon*.config
< %define image_install_path boot
< %define signmodules 1
< %endif
< ExclusiveArch: noarch %{all_x86} x86_64 ppc ppc64 ia64 athlon
> ExclusiveArch: noarch %{all_x86} x86_64 ppc ppc64 ia64
< Source77: kernel-%{kversion}-athlon.config

To sum it up, I enabled building for the Athlon architecture by expanding the i686 entries, defined the aforementioned config file, disabled building of kdump and xen Kernels and increased the revision number.
I increased the revision so I wouldn’t have to replace my recent official Kernel and for better distinguishabilty, but this also means that eventually needed kernel module RPMs have to be rebuilt.

3.) Build the RPMs

Create symbolic links in ~/rpmbuild/SOURCES to the diretory’s content of the extracted RPM e.g. like this:

[scheff@p512o kernel-2.6.17-1.2174_FC5]$ ln -s /home/scheff/src/kernel-2.6.17-1.2174_FC5/* /home/scheff/rpmbuild/SOURCES/

Build the binary and and source RPMs with:

[scheff@p512o kernel-2.6.17-1.2174_FC5]$ rpmbuild -ba --target=athlon ~/rpmbuild/SOURCES/kernel-2.6.spec

The building process will take a very long time (for me about an hour or so). But once successfully finished (exit 0) you should find these RPMs:

Now you could delete the symlinks in the ~/rpmbuild/SOURCES diretory, to keep it clean.

4.) Installing the RPMs

Well, if you dared to build the Kernel RPMs you shouldn’t need assistance in intalling them, but just for the sake of completeness:

[root@p512o ~]# rpm -ihv /home/scheff/rpmbuild/RPMS/athlon/kernel-2.6.17-1.2175_FC5.athlon.rpm /home/scheff/rpmbuild/RPMS/athlon/kernel-devel-2.6.17-1.2175_FC5.athlon.rpm

Reboot and check if your homegrown Kernel behaves nicely. For me it did very well and a bit faster me thinks.
And don’t forget that you need to build the matching kernel modules, if the kernel revision number was changed. For me that is kernel-module-ntfs-2.6.17-1.2175_FC5-2.1.27-0.rr.10.5 (see linux-ntfs homepage for build instructions) and kmod-fglrx-8.27.10- (see my previous posting for build instructions) both with Athlon optimizations.


One thing that makes me wonder, is that uname -m still shows i686, but I’m not sure if this is normal.
The kernel config shows 3D Now is enabled and Machine is indeed set to K7.
It would certainly have been better to do a menuconfig with the 2.6.17-1.2174_FC5 config in the kernel source tree. Here’s the config diff:

[scheff@p512o boot]$ diff config-2.6.17-1.2175_FC5 config-2.6.17-1.2174_FC5
< # Linux kernel version: 2.6.17-1.2175_FC5
< # Fri Aug 25 01:03:12 2006
> # Linux kernel version: 2.6.17-1.2174_FC5
> # Tue Aug  8 15:26:05 2006
< # CONFIG_M686 is not set
> CONFIG_M686=y
> # CONFIG_MK7 is not set

If you find any errors or nonsense please comment. Feel free to ask questions, too. This posting is prone to change, as this was my very first and dirty attempt.


[070429 Fix minor typos. Fix some markup. Add logo image.]



  1. This helped for me with a centos plus 4.4 linux kernel. Thanks for your instructions :)

    Many quotes of commands in your explanation are not readable and truncated when this page is seen with firefox 1.5, opera 9.02 and konqueror.

    [scheff@p512o kernel-2.6.17-1.2174_FC5]$ diff kernel-2.6.spec kernel-2.6.spec.

    [scheff@p512o kernel-2.6.17-1.2174_FC5]$ ln -s /home/scheff/src/kernel-2.6.17-

    [scheff@p512o kernel-2.6.17-1.2174_FC5]$ rpmbuild -ba –target=athlon ~/rpmbuild

    Which renders your fine help a bit harder to use :(

    Comment by Max Heise — 2006/09/27 @ 15:37 | Reply

  2. Hey Max! Nice to hear it helped you. I was aware of the trunctated lines, but I didn’t bother to switch the WordPress theme until yesterday. Sorry for this inconvenience. Now too long lines will even break out of the posting column overlappeng the right sidebar. Cheers!

    Comment by FrankZabbath — 2006/09/28 @ 21:32 | Reply

  3. Frank,

    I was able to build a stock kernel-2.6.18-1.2200 using your guide, but when I make the changes to the spec file and create a new kernel-2.6.18-athlon.config file, the build fails with a message that it can’t find ./configs/kernel-2.6.18-athlon.config. For some reason, my new athlon config file is not getting copied to the rpmbuild/BUILD/kernel-2.6.18/linux-2.6.18.athlon/configs subdirectory like all the other configs. Any idea what’s going on?

    BTW, anyone who’s getting gpg segfaults during builds can workaround it by setting all occurances of signmodules to zero in the spec file %define signmodules 0

    Thanks much!

    Comment by Cal — 2006/11/03 @ 21:11 | Reply

  4. Cal,

    Did you forget the “Source” entry to the .spec file.


    Comment by Doug — 2006/11/19 @ 01:17 | Reply

  5. Egad, what’s with wordpress truncating my comment? Probably didn’t like the leading less-than after the 237,238d230, sigh. Trying that again …


    Source77: kernel-%{kversion}-athlon.config

    Comment by Doug — 2006/11/19 @ 01:20 | Reply

  6. Frank,

    I could be wrong, but methinks the change to ExclusiveArch is unnecessary as all_x86 has been patched to include athlon.

    Comment by Doug — 2006/11/19 @ 01:21 | Reply

  7. Hey Doug,

    you’re probably right. That ExclusiveArch edit looks redudant and could be dropped.
    I had already contacted Cal and he said the athlon config file Source is set. He wanted to come back here and comment if he solved his problems. But he was also thinking about switching to Gentoo. So, we’ll see.

    Comment by FrankZabbath — 2006/11/20 @ 02:54 | Reply

  8. > Did you forget the “Source” entry to the .spec file.
    Thanks, Doug, but I’m pretty sure it was in there. I’ve since deleted the file but may try the spec file edits again one day. I’ve just been doing FC5 (and now FC6) i686 builds for now. GPG still segfaults in FC6 on my system and requires disabling it. Also playing with Gentoo.

    Comment by Cal — 2006/11/30 @ 10:09 | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: