Find the answer to your Linux question:
Results 1 to 9 of 9
PREAMBLE First of all, this is an experience I would like to share, the Linux Kernel deserves time BEFORE compiling (around 30 min. Recollecting hardware info and configuration) and even ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! dothacktsukimoto's Avatar
    Join Date
    Feb 2006
    Posts
    9

    Lightbulb Mini HowTO: Compile the Linux Kernel (2.6.*)


    PREAMBLE
    First of all, this is an experience I would like to share, the Linux Kernel deserves time BEFORE compiling (around 30 min. Recollecting hardware info and configuration) and even more after it (at least 1 hr taking notes which processes failed, dependencies, failing modules, etc...) with the reward of a quicker system and other goodies


    Requirements

    Well, in order to compile your Linux Kernel, you need at least the following: (already included and updated on most distros)
    1. GNU C (2.91)
    2. GNU make (ver 3.78 )
    3. binutils (2.12)
    4. util-linux (2.10o)
    5. module-init-tools(0.9.10)
    6. e2fsprogs(1.29)
    7. jfsutils(1.1.3)
    8. reiserfsprogs(3.6.3) (If you user REISER)
    9. xfsprogs(2.1.0)
    10. pcmcia-cs(3.1.21) (If you have a laptop or use PCCard)
    11. quota-tools(3.09)
    12. PPP(2.4.0)
    13. isdn4k-utils(3.1pre1) (If you connect via ISDN)
    14. nfs-utils (1.0.5)
    15. procps(3.1.13)
    16. oprofile(0.5.3)


    Hardware
    Therefore, the next step is to determine your current hardware, using a terminal move to your home directory (or wherever you wish to save hardware data) and type:

    $ lspci > hardware.log

    Then we need to have information about our CPU, again, type:

    $ cat /proc/cpuinfo > cpuinfo.log

    You'll have 2 files now, hardware.log and cpuinfo.log... what for? In order to respond correctly (no, it's not a test, just a cfg file !) some kernel configuration questions in order to tune your machine correctly, this info will come in handy specially when configuring NIC, soundcard, built-in components, etc...

    Download kernel source...
    We have a bifurcation here and all depends the road you'll take, you can download a source from your distribution (already packed with all distro hacks,specific hardware support, etc...) or download a "pristine" kernel (community developed, large hardware support, experimental code, etc...). I'll prefer a pristine rathen than a distro pack, if you wish stability and support from your distro then take that way and please READ your distro kernel docs.
    Staying with "pristine"? Well, the best place to download the kernel source is at http://www.kenel.org, but please be generous and use a mirror near you, mirrors shown at http://www.kenel.org/mirrors. Choose a 2.6.x "tar.bz2" tarball and wait (it should not take more than 15 min using a 512 DSL internet connection).

    Extract kernel tarball
    Uncompress the tarball as follows:

    $ tar jxvf linux-2.6.x.tar.bz2

    Replace the "x" with the version you're using. This will generate a directory "linux-2.6.x", get inside and ... let the party begins !

    Configure the Linux Kernel
    Having a bad day? Try to get a Paracetamol caplet or something because this step is a headache, takes lots of time (30 min at least) in order to configure properly your kernel... one keyword: PATIENCE !

    To start configuring, inside the "linux-2.6.x" directory type the following at your terminal:

    $ make mrproper
    $ make xconfig

    The first command will "prepare" some configuration files in order to compile correctly, in the past I received comments of kernel failure, this step seems to correct most of it. The next step will prepare and show your a graphical kernel configuration interface using qt (most of RH-based systems already includes qt), if you receive an error, please refer to your system updater (urpmi, apt, yast, yum ...) and download "qt" and "qt-devel" or any that refers to qt compilers, execution libraries, widgets and source code.
    An alternative is to use "menuconfig" in the case you find difficult to get "qt" libraries and source, you can use it by changing "xconfig" with "menuconfig", like this:

    $ make menuconfig

    This command will need ncurses, but don't worry, most of Linux distros has them already (it is considered as an terminal developing standard to use ncurses ! That's why...)

    If everythings smooth a window (or a blue menu inside your terminal) will appear you're ready to start configuring your kernel, open with the editor of your choice the 2 files we saved, remember? (hardware.log and cpuinfo.log) or print it if you wish.

    I can't guide you here step-by-step but I can, at least, give to you important tips to follow, please take note:
    1. How to answer? Simply click over the checkbox, it will show 3 different ways, checked, dotted and empty. "checked" means a positive answer, dotted means "to compile/install" as a module and "empty" means a negative answer.
    2. Follow reccomendations at the brief help below, there is a textbox which explains every option, most of times they give tips like "say N if unsure", if you don't really know what you're doing, then follow this brief tips.
    3. EXPERIMENTAL OR STABILITY? An eternal question, depends on you and you'll answer this at "Code Maturity Options"
    4. Proccesor and RAM, please do not lie about your processor information ! (this is "cpuinfo.log" intended for), if you're using a HyperThread processor mark positive any SMP option, choose the max processor information up to 4 (or more if you intend or have more processors). If you have 1GB of RAM or more, please check memory support at "4 GB" if you have more than 4 GB then choose support for 10 GB and so on.
    5. Be systematic! Disable any feature you don't really need ! Any feature that you mark as positive will increase the kernel size resulting on a slow or even buggy kernel ! So please be systematic on choosing features
    6. Bus options: Most modern computers won't have MCA or ISA, you can disable this options safely.
    7. Filesystems: Allow at least ext2, ext3 and reiserFS to be supported by the kernel !!! If you miss this step, the fresh compiled kernel will crash for sure !
    8. Cryptography and loopback device: Allow loopback devices and Cryptography, it's a good idea to create encrypted loopback devices if you want to keep information safe, at least allow Twofish, Blowfish and AES algorhytms to be included.
    9. Be safe ! Check twice your kernel configuration (I told you this will take some time)


    Compile the Linux Kernel
    The final showdown ! Now, after configuring and saving your kernel, type the following at the terminal:

    $ make

    That's it? Nothing else? No. For "pristine" Linux source tarballs, using the "make" command will build everything you need, using a powerful Intel or AMD processor and a simple configuration will take 10 minutes, this may vary from 7 minutes to 45 minutes or more (old Intel machines). So go and grab a lunch, take a nap or go walk for a while.
    When you came back, look at the terminal, if no errors around then... HORAAY !

    Install the Linux Kernel Modules
    First of all, get root rights and type the following at your terminal:

    # make modules_install

    This command will install automagically every module you choose, it won't take long, so please wait, after booting with this freshly-baked linux kernel, you can load them as usual.

    Prepare your bzImage
    This is simple, what you are going to do is to copy 2 files, "System.map" and "bzImage", follow this steps at your terminal (with root right's of course !):

    # cp arch/i386/boot/bzImage /boot/bzImage-<version>
    # cp System.map /boot/System.map-<version>
    # ln -s /boot/System.map-<version> /boot/System.map

    <version> refers to the version you downloaded and compiled, this MUST match with this three given instructions.

    Create initrd image
    Some systems requires this instruction in order to boot the kernel, no problem, just look at "/lib/modules" for the "<version>" you just downloaded and compiled, take this data and do the following inside the "/boot" directory:

    # mkinitrd /boot/initrd-<version>.img <version>

    If success, nothing will returned, at any errors please read the output and figure it out the correct version you're compiling and installing.

    Prepare GRUB and reboot
    Finally, prepare "GRUB" for our new kernel image ! first of all, make a backup of /boot/grub/menu.lst and edit this file appending the following matching your new kernel image:

    title My Distro (<version>)
    title Test Kernel (<version>)
    root (hd0,0)
    kernel /boot/bzImage-<version> ro root=LABEL=/
    initrd /boot/initrd-<version>.img


    Please be sure about your HD device, one useful tip is to look and use the configuration from your distro root hd kernel. Be sure about every file path (bzImage and initrd), if everything's OK, then save and... reboot !

    Take notes about any event or case
    After rebooting, choose "Test Kernel" or any name you input here and check any errors you could have, when you arrive to runlevel 5, run the graphic server, interact with your computer, etc... This information will guide you to any misconfigured kernel parameter or missing module to load, I can't help much around here but If you got a functional system you'll notice that this recent kernel is way more fast than the distro ones... and the confidency that you compiled and tuned it, congratulations ! My job ends here !

    Postamble
    Thanks for reading ! I hope this would come in handy, before sending any questions or comments, try to read a complete Howto, they include for sure more FAQ's and troubleshooting, this is just an "Starting" guide, I'll appreciate any suggestions, corrections, addings or anything CONSTRUCTIVE. Well, again... Thank's for reading !!!

    Reference
    http://www.digitalhermit.com/linux/K...ild-HOWTO.html

  2. #2
    Linux Engineer spencerf's Avatar
    Join Date
    Jan 2005
    Location
    Syracuse, NY
    Posts
    1,144
    excellent how-to and much needed for many people. I just have one thing to add. You can use make menuconfig instead of xconfig so qt and qt-devel are not required.
    All right, brain. You don't like me and I don't like you, but let's just do this and I can get back to killing you with beer. All New Users Read This!!! If you have a grub problem please look at GRUB MANUAL

  3. #3
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,733

    Cool

    Hey, welcome to the forums, dothacktsukimoto!

    Nice kernel howto, too. You should send a PM to the admins to see if they'll move this over to the Tutorials, HowTos, & Reference Material Forum:

    http://www.linuxforums.org/forum/lin...ence-material/

    If they find it acceptable, I feel pretty sure they'll be happy to move it for you.

    Hope you have fun here at the forums and visit often...

    ozar
    oz

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,619
    Quote Originally Posted by spencerf
    excellent how-to and much needed for many people. I just have one thing to add. You can use make menuconfig instead of xconfig so qt and qt-devel are not required.
    Doesn't make xconfig depend on tk as opposed to qt or was that older versions of the kernel?

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  6. #5
    Just Joined! dothacktsukimoto's Avatar
    Join Date
    Feb 2006
    Posts
    9
    I'll modify this sooner or later, thanks for this point ! I really like to use "xconfig" because is a lot more easier to configure the kernel using this tool rather than ncurses-terminal based (nothing against ncurses ! I use it to develop it and it's great) but I think for kernel-compiling beginners and even experts would come more in handy to use the "xconfig" tool.

    And about Tcl-tk, not really, tk libraries are used at 2.4.* branch of kernels, 2.6.* uses qt libraries, I guess in order to provide a "clear" interface to the user.
    Thanks by reading and mentioning about tk

    Thx ozar, I'm flattered ! Sure I'll PM to the admins to request to move it to the most appropiate area, I decided to post it here because everything about kernels must be around here and some kind of advise (my howto, may be) was missing, so I dediced to share my personal experience with yours. Thanks for the compliment

    (Excuse my terrible english >.> I'm learning too XD)

  7. #6
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,619
    Quote Originally Posted by dothacktsukimoto
    I'll modify this sooner or later, thanks for this point ! I really like to use "xconfig" because is a lot more easier to configure the kernel using this tool rather than ncurses-terminal based (nothing against ncurses ! I use it to develop it and it's great) but I think for kernel-compiling beginners and even experts would come more in handy to use the "xconfig" tool.

    And about Tcl-tk, not really, tk libraries are used at 2.4.* branch of kernels, 2.6.* uses qt libraries, I guess in order to provide a "clear" interface to the user.
    Thanks by reading and mentioning about tk

    Thx ozar, I'm flattered ! Sure I'll PM to the admins to request to move it to the most appropiate area, I decided to post it here because everything about kernels must be around here and some kind of advise (my howto, may be) was missing, so I dediced to share my personal experience with yours. Thanks for the compliment

    (Excuse my terrible english >.> I'm learning too XD)
    Your english is great .

    As for tk and qt...I learn something new everyday. Thanks for the explanation. When I compile a kernel, it is with make menuconfig so I never really looked into xconfig.

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  8. #7
    Linux Enthusiast Weedman's Avatar
    Join Date
    May 2005
    Location
    Tasmania, Australia
    Posts
    640
    i dont know what make xconfig requires, but i do know that xconfig is a bit more unstable than menuconfig. thats my experience though.

    however, xconfig would be better for noobs out there compiling their 1st own kernel.

    what would be interesting is if someone wrote a guide on compiling a kernel from source on a redhat/fc machine... i did that not 1/2 hour ago and got init errors on boot.

    good on you dothacktsukimoto for spending a good deal of your time to write a guide to compiling a kernel. Well done!
    i could never be patient enough for that.

    -weed
    "Time has more than one meaning, and is more than one dimension" - /.unknown
    --Registered Linux user #396583--

  9. #8
    Just Joined!
    Join Date
    Jul 2006
    Posts
    1

    Simplified Kernel Installation

    hi...
    if u spent more time on help option on make command. u ll find simplified method to install the compiled kernel. everywhere i went people use the same method, not exploring new way to do it. try this command:
    # make help
    any way, u can simplify the installation by this command (run after make modules_install):
    # make install
    which will do these things
    1. Prepare your bzImage
    2. Create initrd image
    3. Prepare GRUB
    the most interesting part is in "prepare grub" the command will detect default grub setting to boot then change the "version" used in the setting to create new setting for the new kernel. maybe u can give it a try.

  10. #9
    Just Joined!
    Join Date
    Jul 2006
    Posts
    3
    #tar jxvf linux-2.6.16.bz2
    #cd linux-2.6.16
    #make xconfig
    #make
    #make modules_install install

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •