<---- template headericclude ----->
Compile a kernel for i686, i586 and others (NO i386)
FedoraForum.org - Fedora Support Forums and Community
Page 1 of 8 123 ... LastLast
Results 1 to 15 of 111
  1. #1
    alpha645 Guest

    Thumbs up Compile a kernel for i686, i586 and others

    Kernel Compilation: (Updated for Fedora 8) (the old howto is attached)

    1. Reasons to recompile the kernel
    2. Where to start
    3. Configuring
    4. Compiling
    5. Installing


    1. There are various reasons to recompile the kernel. For example:
    - Include new drivers (that are not enabled by default)
    - Just for fun
    - Gain a performance boost
    - And many more...
    Recompiling the kernel is not for those who are regular Windows end-users. You need to know:
    - Which hardware you have (and which drivers are required)
    - What the system really needs
    Things could go wrong, so always make a back-up of important data!


    2. You start by preparing the system for the compilation. Your system needs several tools to build the kernel. Plus, you need the source of the kernel of course...
    So, let's update the system to compile (you first become root (after opening a terminal of course), and you have to stay root during the entire howto):

    su -
    yum -y install yum-utils ncurses-devel gcc-c++ gcc binutils rpm-build m4 rpmdevtools make sparse e2fsprogs jfsutils reiserfs-utils xfsprogs pcmciautils quota ppp isdn4k-utils nfs-utils procps oprofile libglade
    Some of these programs are really required (yum-utils ncurses-devel gcc-c++ gcc binutils rpm-build m4 rpmdevtools make). Some might not even be touched (e2fsprogs jfsutils reiserfs-utils xfsprogs pcmciautils quota ppp isdn4k-utils nfs-utils procps oprofile libglade). But I included them so you don't have to hunt them down in case they are needed .
    Now, let's grab the source.

    yumdownloader --source kernel
    Now we only need to install the source so that it is ready for editing and compiling:

    rpmdev-setuptree
    rpm -Uvh /root/kernel-*src.rpm

    3. Configuring (I will add patching later if I have time)

    gedit /root/rpmbuild/SPECS/kernel.spec
    These sections are important (look closely (plus they may vary in each kernel version)):

    >>>
    %define fedora_build %(R="$Revision: 1.294 $"; R="${R%% \$}"; R="${R##: 1.}"; expr $R - %{fedora_cvs_origin})
    <<<
    -----------------------------------------------------------------------^ Place any extra stuff after this (in our case 1.294...) to seperate this kernel from the stock kernel. You must do this, or you will overwrite your default kernel.


    <<<
    # The following build options are enabled by default.
    # Use either --without <opt> in your rpmbuild command or force values
    # to 0 in here to disable them.
    #
    # standard kernel
    %define with_up %{?_without_up: 0} %{?!_without_up: 1}
    # kernel-smp (only valid for ppc 32-bit, sparc64)
    %define with_smp %{?_without_smp: 0} %{?!_without_smp: 0} # %{?!_without_smp: 0} will mean no SMP kernel same as the others below.
    # kernel-PAE (only valid for i686)
    %define with_pae %{?_without_pae: 0} %{?!_without_pae: 0}
    # kernel-xen
    %define with_xen %{?_without_xen: 0} %{?!_without_xen: 0}
    # kernel-kdump
    %define with_kdump %{?_without_kdump: 0} %{?!_without_kdump: 0}
    # kernel-debug
    %define with_debug %{?_without_debug: 0} %{!?_without_debug: 0}
    # kernel-doc
    %define with_doc %{?_without_doc: 0} %{?!_without_doc: 0}
    # kernel-headers
    %define with_headers %{?_without_headers: 0} %{?!_without_headers: 0} # Assuming you stay x86, you don't need new headers.
    # kernel-debuginfo
    %define with_debuginfo %{?_without_debuginfo: 0} %{!?_without_debuginfo: 0}
    >>>


    >>>
    %define debugbuildsenabled 1 # Set this to 0 to disable the annoying debug kernel.
    <<<

    Now we can start building to generate a .config:

    rpmbuild -bp --target=i686 /root/rpmbuild/SPECS/kernel.spec
    Note, I use --target=i686. This is for the architecture of your computer. If you have a normal computer (PC) then you should always use i686. Unless you have a mac, then use 'ppc' (not tested). You can view your arch by typing:

    arch
    Now creat your config:

    cd /root/rpmbuild/BUILD/*/linux*
    make menuconfig
    Now, create and save your .config inside menuconfig in your root directory: (save it as: /root/config)

    AND, save your kernel.spec in your root directory (this is done below) and clean up the mess:

    cp /root/rpmbuild/SPECS/kernel.spec /root/spec
    rm -rf /root/rpmbuild/
    cd /root/
    Now we have to reinstall the source (we do this to keep the building environment in good condition):

    rpmdev-setuptree
    rpm -Uvh /root/kernel-*src.rpm
    Copy back your spec file:

    cp /root/spec /root/rpmbuild/SPECS/kernel.spec
    Now your /root/config file, this one is a little more complicated:

    dir /root/rpmbuild/SOURCES | grep "config-"
    One of these configs are used for your kernel (defined by --target=i686). If you build an i686 (normal and SMP) kernel you need:

    config-i686
    So you copy your config over that config:

    cp /root/config /root/rpmbuild/SOURCES/config-i686

    4. Compiling

    Finally you can start compiling (again replace i686 with your architecture):

    rpmbuild -bb --target=i686 /root/rpmbuild/SPECS/kernel.spec


    5. Installing

    You can find the .rpms inside:

    /root/rpmbuild/RPMS/`arch`/

    This will install the newly build kernel on an i686 system:

    rpm -i /root/rpmbuild/RPMS/i686/kernel-2.6.*.rpm
    And the development package:

    rpm -i /root/rpmbuild/RPMS/i686/kernel-devel-2.6.*.rpm
    Your new kernel is now installed, reboot to test it . (Chose the new entry in grub during boot)

    To remove (RPM requires and exact match (so no wildcards) before it will delete packages):

    To see all installed kernels (and development and headers) do:

    rpm -aq | grep kernel
    The output will list the installed kernels. Yours has the same name as the packages in /root/rpmbuild/RPMS/`arch`/

    The following example will delete the current stock kernel from Fedora (and devel): (So replace it with your kernel!)

    rpm -e kernel-2.6.23.9-85.fc8
    rpm -e kernel-devel-2.6.23.9-85.fc8
    If there are any questions, feel free to ask them...

    Thanks to the people who gave feedback and some really good tips
    Attached Files Attached Files
    Last edited by alpha645; 13th January 2008 at 10:08 AM. Reason: Updated

  2. #2
    jim's Avatar
    jim is offline Retired Community Manager & Avid Drinker Of Suds
    Join Date
    Feb 2005
    Location
    Rochester NY
    Age
    49
    Posts
    4,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change the following rules:

    # I'm assuming you don't want to build the XEN or KDUMP kernels
    %define buildxen 1 Change to: %define buildxen 1
    %define builddoc 0 Change to: %define builddoc 0
    %define buildkdump 1 Change to: %define buildkdump 1
    %define buildheaders 1 Change to: %define buildheaders 1
    you dont to appear to be changing anything...
    Registered Linux User: #376813
    Western NY
    My linux site
    Smolt Profile

    please remember to say if you problem was solved

    Did you get your id10t award today?

  3. #3
    leigh123linux Guest
    Well laid out and easy to follow , how about a howto for the kernel-devel.

    10/10

  4. #4
    alpha645 Guest
    Quote Originally Posted by jim
    you dont to appear to be changing anything...
    Whoops, I'll correct it .

    Well laid out and easy to follow , how about a howto for the kernel-devel.
    Kernel-devel package is included as well .
    Last edited by alpha645; 18th December 2006 at 09:58 AM.

  5. #5
    alpha645 Guest
    I changed the guide:

    - Found a way to change kernelstring
    - Removed some vague parts
    - Improved explanation for architecture
    - Some commands are combined (less commands needed)
    Last edited by alpha645; 18th December 2006 at 06:34 PM.

  6. #6
    Join Date
    Sep 2004
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd also recommend instructions on adding any additional patches that someone may want to add while they rebuild their kernel.

    Excellent work, definitely a handy guide.

  7. #7
    alpha645 Guest
    When I have time, I will add the following stuff:

    - Much easier way to configure kernel (menuconfig REALLY )
    - Disable debug-packages (reduces compile time)
    - And finally, on many requests patches. But I will have to figure a way to bypass those who are not working...

    Happy Xmas everyone

  8. #8
    alpha645 Guest
    Okay, it's updated. Now, for the final part, the patches . I really appreciate some feedback.

  9. #9
    alpha645 Guest
    4. Troubleshooting

    - If you get a message during the compilation like that you need to collect more 'entropy'. Simply open up openoffice or firefox. This is needed for the module signing and encrypting (I think).

    - If you kernel fails to boot and you get all sorts of errors, this means you configured your kernel the wrong way. try customizing your kernel step by step to prevent problems.

    - To prevent problems with kmod's (kernel mods) like fglrx, make sure you compile the kernel in the way the kmod 'wants' it. (http://www.stanchina.net/~flavio/deb...l#requirements)

    5. More info
    I managed to create my own and fully functionable kernel package of just 4,5 MB . Here is some more information.

    1: Once you installed your kernel, yum will popup for an update. You can bypass this by changing the kernel string to a higher value than the original kernel (in the guid I use 'custom'), for example:

    - Version: 2.18-1.2868 (the standard one) will overwrite your current kernel
    - Version: 2.18-1.custom (used in the manual) will be overwritten during update
    - Version: 2.18-1.2869 (recommended) will not overwrite your current kernel and it will NOT be updated by yum

    2: I also recommend you leave Code Maturity enabled for many more options

    3: These were some conditions in my case:

    - Leave the Network Packet Filtering untouched as it will colide with the firewall
    - Sound doesn't work anymore when I tried to configure the sound part in menuconfig
    Last edited by alpha645; 2nd January 2007 at 10:06 PM.

  10. #10
    Join Date
    Feb 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help for patches

    Hello,

    First thank you for your procedure, it worked directly on my system, except for the configuration stuff that I haven't understood. Keeping the defaults gave me an operational system, so I'm happy.

    Now I'd like to apply the patches from http://home-tj.org/files/libata-tj-s...061020.tar.bz2

    I've extracted the patches to ../SOURCE/ and added a PatchXXXX and a %patchXXXX into the .spec file for each patch file.

    When I try a rebuild, patches fail because they are recognised as 'already applied', in this case I comment out the patch in the .spec file, or because the patch command prompts me with the question 'File to patch :' like this :

    Code:
    |---
    | drivers/ata/libata-core.c |   79 +++++++++++++++++++++++++++++
    | drivers/ata/libata-eh.c   |  123 ++++++++++++++++++++++++++++++++++++++++++++-
    | drivers/ata/libata.h      |    2 +
    | include/linux/libata.h    |   10 ++++
    | 4 files changed, 211 insertions(+), 3 deletions(-)
    |
    |diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
    |index f19e041..5c3d566 100644
    |--- a/drivers/ata/libata-core.c
    |+++ b/drivers/ata/libata-core.c
    --------------------------
    File to patch:
    TIA for your help.

  11. #11
    alpha645 Guest
    Quote Originally Posted by koridor
    Hello,

    First thank you for your procedure, it worked directly on my system, except for the configuration stuff that I haven't understood. Keeping the defaults gave me an operational system, so I'm happy.

    Now I'd like to apply the patches from http://home-tj.org/files/libata-tj-s...061020.tar.bz2

    I've extracted the patches to ../SOURCE/ and added a PatchXXXX and a %patchXXXX into the .spec file for each patch file.

    When I try a rebuild, patches fail because they are recognised as 'already applied', in this case I comment out the patch in the .spec file, or because the patch command prompts me with the question 'File to patch :' like this :

    Code:
    |---
    | drivers/ata/libata-core.c |   79 +++++++++++++++++++++++++++++
    | drivers/ata/libata-eh.c   |  123 ++++++++++++++++++++++++++++++++++++++++++++-
    | drivers/ata/libata.h      |    2 +
    | include/linux/libata.h    |   10 ++++
    | 4 files changed, 211 insertions(+), 3 deletions(-)
    |
    |diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
    |index f19e041..5c3d566 100644
    |--- a/drivers/ata/libata-core.c
    |+++ b/drivers/ata/libata-core.c
    --------------------------
    File to patch:
    TIA for your help.
    Commenting out patches in the specfile didn't help for me. If you could explain that a little more, I might be able to upgrade the manual for patches.

    I already found out about the --short-circuit switch in rpmbuild. That could allow you to do %prep first (build source files) and do %build and %install after that. However, when performing %prep with a patched kernel, I get errors. You solve those errors by commenting them out, but that doesn't work here. I get the error: could not find patchXXXX.

  12. #12
    Join Date
    Feb 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by alpha645
    Commenting out patches in the specfile didn't help for me. If you could explain that a little more, I might be able to upgrade the manual for patches.
    I already found out about the --short-circuit switch in rpmbuild. That could allow you to do %prep first (build source files) and do %build and %install after that. However, when performing %prep with a patched kernel, I get errors. You solve those errors by commenting them out, but that doesn't work here. I get the error: could not find patchXXXX.
    Each patch takes 2 lines in the specfile. Did you comment out both ? I did.

    WARNING : what I did is just a try to make the kernel (modules) build. YOU are the expert and I'm here to get help. What I did is probably wrong. Sorry to disappoint you.
    Last edited by koridor; 3rd January 2007 at 01:10 AM.

  13. #13
    alpha645 Guest
    Quote Originally Posted by koridor
    Each patch takes 2 lines in the specfile. Did you comment out both ? I did.

    WARNING : what I did is just a try to make the kernel (modules) build. YOU are the expert and I'm here to get help. What I did is probably wrong. Sorry to disappoint you.
    I did not comment out both lines. I will give it a try your way. (thanks for the compliment but I'm not an expert, I use Fedora Core for just 4 months )

  14. #14
    Join Date
    Feb 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Update

    Quote Originally Posted by alpha645
    Commenting out patches in the specfile didn't help for me. If you could explain that a little more, I might be able to upgrade the manual for patches.

    I already found out about the --short-circuit switch in rpmbuild. That could allow you to do %prep first (build source files) and do %build and %install after that. However, when performing %prep with a patched kernel, I get errors. You solve those errors by commenting them out, but that doesn't work here. I get the error: could not find patchXXXX.
    What patches are you trying to apply ? If they are not Fedora or Red Hat specific, it will not succeed.

    I've contacted the author of 'my' patches and he told me that the situation was hopeless for me (effort and required skills).

  15. #15
    alpha645 Guest
    Don't know what you mean with that. I just want to apply Fedora specific patches. This can be done by downloading another kernel from kernel.org and perhaps replacing it with the kernel inside the SOURCE directory of rpmbuild.

    Check this out: http://www.howtoforge.com/kernel_compilation_fedora

Page 1 of 8 123 ... LastLast

Similar Threads

  1. i386/i586/i686
    By arun_maurya in forum Using Fedora
    Replies: 4
    Last Post: 27th May 2008, 09:10 AM
  2. Replies: 3
    Last Post: 14th September 2007, 02:14 PM
  3. i386 i586 i686
    By name_user in forum Using Fedora
    Replies: 4
    Last Post: 30th March 2006, 11:13 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
[[template footer(Guest)]]