Page 1 of 29 12311 ... LastLast
Results 1 to 10 of 286

Thread: HOWTO: Kernel Compilation for Newbies

  1. #1
    Join Date
    May 2005
    Location
    Lecce, Italy
    Beans
    6,168
    Distro
    Ubuntu

    HOWTO: Kernel Compilation for Newbies

    This guide is aimed at the newbies who are willing to learn something about kernel compilation or just who need a new kernel for incompatibility issues (e.g. DMA issues). This is a STEP-BY-STEP guide, so don't be afraid of compiling your first kernel, it's a piece of cake.

    I want to thank the user luca_linux, who made a great compilation guide, from which I've taken the commands for my guide and thanks to which I learnt how to compile a kernel. I advise you to check it out: http://ubuntuforums.org/showthread.p...el+compilation

    It takes a while (even an hour) to complete the process described below, so make sure you have enough time to spend.

    Make sure you have all the repositories: go to http://www.ubuntuguide.org/ , find the section “How to add extra repositories?” and follow the instructions.

    BEFORE YOU START

    If you have an Nvidia or ATI graphic card and you are using a proprietary driver (i.e. if you have installed the graphic driver before) please do this, otherwise get straight to step 1:

    Open Terminal or Konsole and type these commands:

    (if you are using GNOME, the graphic interface that comes with Ubuntu)
    Code:
    sudo gedit /etc/X11/xorg.conf
    Otherwise

    (if you are using KDE, the graphic interface that comes with Kubuntu)
    Code:
    sudo kate /etc/X11/xorg.conf
    Scroll down the text until you find this section (this is my configuration):

    Code:
    Section "Device"
    	Identifier	"ATI Technologies, Inc. Radeon 330M/340M/350M (RS200 IGP)"
    	Driver		"ati"
    	BusID		"PCI:1:5:0"
    Substitute the word in red with “vesa”, make it look like this:
    Code:
    Section "Device"
    	Identifier	"ATI Technologies, Inc. Radeon 330M/340M/350M (RS200 IGP)"
    	Driver		"vesa"
    	BusID		"PCI:1:5:0"
    Save and exit. Restart the computer and go to the next step.

    When you have the new kernel working you might want to reinstall the proprietary drivers for your graphic card. Have a look at "Hoary 5.04 Customization Tips & Tricks" section of Ubuntu Forum for the instructions.


    1) Open Terminal or Konsole and type these commands (so as to see what kernel you are using)

    Code:
    uname -r
    NOTE: if you want to compile a vanilla kernel from kernel.org have a look at the end of the guide.Otherwise proceed with step 2.

    2) Download the Ubuntu kernel sources:
    Code:
    sudo apt-get install linux-source
    NOTE:
    If you want to download the sources of kernel 2.6.11 try this otherwise skip it and go to step 3:
    Make sure you have all the repositories: go to http://www.ubuntuguide.org/ , find the section “How to add extra repositories?” and follow the instructions.
    Then open either Synaptic or Kynaptic, press the “search” button and type “tree” (and launch the search)
    Look for linux-tree-2.6.11 and select it with your mouse, select “mark for the installation”, “mark”. Then click on the “Apply” button and then select “apply” again.
    Remember that the name of the file (e.g. linux-source-2.6.11.tar.bz2) will be different from the one in my examples.
    i.e. for the 1st command: “sudo apt-get install linux-tree-2.6.11”

    Apart from this command you will have to put “2.6.11” instead of “2.6.10” every time you see it in this HOWTO.
    e.g. for this command “sudo tar --bzip2 -xvf linux-source-2.6.11.tar.bz2” (instead of “sudo tar --bzip2 -xvf linux-source-2.6.10.tar.bz2”)

    3)Open Terminal or Konsole (if it's not open yet) and type these commands:

    Code:
    sudo apt-get update
    sudo apt-get install build-essential
    sudo apt-get install kernel-package
    sudo apt-get install gcc
    sudo apt-get install gcc-3.4  (this is required only for Breezy users)
    sudo apt-get install libncurses5
    sudo apt-get install libncurses5-dev
    sudo apt-get install libqt3-mt-dev
    Code:
    cd /usr/src
    sudo tar --bzip2 -xvf linux-source-2.6.10.tar.bz2
    sudo ln -s /usr/src/linux-source-2.6.10 /usr/src/linux
    cd /usr/src/linux
    NOTE: if the computer says "file exists" when you try type this command "sudo ln -s /usr/src/linux-source-2.6.10 /usr/src/linux", you have to type "sudo rm /usr/src/linux" (this will remove the old link). Now you wont' have this error and the command "sudo ln -s /usr/src/linux-source-2.6.10 /usr/src/linux" will work.


    Code:
    sudo make oldconfig (so as not to compile the entire kernel from scratch)
    If it makes you any questions just press Enter (so as to select the recommended answer)

    Code:
    sudo make menuconfig
    4)Now you have to use the keyboard to move the cursor over the function or submenu you want and press Enter to select it.

    Select the 4th option: Processor type and features

    If you have a multiprocessor system you might want to enable "Symmetric multi-processing support" (SMP): select it with your keyboard and press the spacebar to enable it (a "*" will appear beside it). If you don't have it don't enable it.

    Select Processor Family and choose the right one (i386 in my case) depending on the output of the command “uname -r” you have used before

    Press the right arrow and select exit

    If you have more than 900MB RAM then you'll definitely need this, otherwise (or if you are using Ubuntu 64 bit) skip this step:
    Scroll down the text until you find “High Memory Support”.
    Select it.
    You'll have three possible choices:
    Code:
    Off
    4GB (if you have no more than 4GB RAM)
    64GB (if you have more than 4GB RAM)
    Select one of these functions and press enter.
    Press the right arrow and select exit

    The following operation is required if you want to enable DMA directly in your kernel. You might want to try this if none of the methods found in this forum works for you, Otherwise skip it and go to Step 5.
    NOTE: if you have old hardware which doesn't support DMA you won't be able to access this hardware with your new kernel. If this happens go straight to Step 8.

    Code:
    Select Device drivers
    then

    Code:
    Select ATA/ATAPI/MFM/RLL support
    Scroll down the text until you find (and highlight with the keyboard) “Enable DMA only for disks” and disable it by pressing N (now the “*” beside it should disappear, this means it is not selected any more)

    Press the right arrow and select exit

    5)Keep on selecting Exit until it asks you whether you want to save you new configuration or not. Answer yes.

    Now you are back to the command line, type:

    Code:
    sudo make-kpkg clean
    sudo make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
    NOTE: you can put whatever you want instead of “custom”

    e.g. sudo make-kpkg --initrd –append-to-version=-alberto kernel_image kernel_headers


    The system will ask you this question:

    “By default, I assume you know what you are doing, and I
    apologize for being so annoying. Should I abort[Ny]?”

    Answer no by either typing N and then pressing Enter, or just by pressing Enter (as N is the recommended answer)

    Well now you'll have to wait at least 45min. The process will use 100% of your CPU so try to leave your computer alone, go have a tea or something else just to keep you away from your computer for a while.

    6)After the (long) process type this in the command line (Terminal or Konsole)

    Code:
    cd /usr/src
    ls
    You'll see a list of the names of the files in the folder as well as the names of your new kernel image and kernel headers; they should look (approximately)like the following:

    kernel-image-2.6.10-custom_10.00.Custom_i386.deb
    kernel-headers-2.6.10-custom_10.00.Custom_i386.deb

    Now install them by typing these commands (change the name of the files according to the ones you have seen after the output of the command “ls”):

    Code:
    sudo dpkg -i kernel-image-2.6.10-custom_10.00.Custom_i386.deb
    Code:
    sudo dpkg -i kernel-headers-2.6.10-custom_10.00.Custom_i386.deb
    REMEMBER NOT TO UNINSTALL your previous kernel (just in case anything goes wrong) (i.e. don't do anything else apart from following the instructions)

    7)Ok, now it's time to see if they work.

    Restart your computer.

    Then if you want to see if DMA is active type (in Terminal or Konsole):

    Code:
    sudo hdparm -d /dev/hda (to check if your harddisk has DMA enabled)
    sudo hdparm -d /dev/cdrom (to check if your cd-reader has DMA enabled)
    Don't you worry if it gives you an error as output but the performance of your harddisk and cdreader have improved (try to transfer a file from a CD to your harddisk and see if it the system slows down).

    If everything is ok, then Congratulations you have compiled your first kernel successfully!

    8 )If anything went wrong (I don't know a reason for which it would) you could switch back to your previous kernel: while your computer is booting press "ESC" repeatedly while your computer is booting until GRUB menu appears and you can choose kernel 2.6.10 again (using your keyboard arrows). Once you enter Ubuntu type these commands in order to uninstall the new kernel (remember to put the name of the kernel you have created)

    follow this example and put the name of the kernel you have created instead of “custom”

    Code:
    sudo dpkg -r kernel-image-2.6.10-custom
    sudo dpkg -r kernel-headers-2.6.10-custom
    (in my case, sudo dpkg -r kernel-image-2.6.10-alberto)

    NOTE you DON'T have to type the full name of the file .deb which you created

    e.g. put “kernel-image-2.6.10-custom” instead of “kernel-image-2.6.10-custom_10.00.Custom_i386.deb”

    And restart your computer.

    Enjoy!
    ---------------------------------------------------------------------------------------------------------------------------------
    NOTE: HOWTO compile from a vanilla kernel from kernel.org

    If you want to compile from a vanilla kernel from kernel.org something need to be changed in my guide:

    Skip point 2
    You have to download it from www.kernel.org (try the latest stable kernel source)

    When you get to Point 3 of the guide and you get to the following lines you have to modify them in this way:

    cd /home/your_username_folder/directory_where_you_put_the_downloaded_kernel (instead of cd /usr/src) (e.g. "cd /home/alberto/download" in my case)
    sudo tar --bzip2 -xvf linux-source-2.6.10.tar.bz2 /usr/src (use the name of the file you downloaded)
    sudo ln -s /usr/src/linux-source-2.6.10 /usr/src/linux (use the name of the file you downloaded)
    cd /usr/src/linux

    Then you can go on with the instructions of Point 3.

    And in point 4 (this is the 1st thing to do at the beginning of point 4):

    Get to "File Systems".

    Select your filesystem (ext3, reiserfs, etc.) with the cursor.( ext3 is the filesystem used by Ubuntu by default, so if you chose automatic partitioning when you installed Ubuntu Hoary then "ext3" is definitely your filesystem)

    Then press the spacebar on the desired filesystem (a "*" will appear beside it). (Make sure there's a "*" beside it instead of a "M". In this way the support for you filesystem will be built directly in the kernel instead of being built as a module and you will not get a "kernel panic")

    For example:
    select "ext3 journalling filesystem support" and press the spacebar (a "*" will appear beside it).

    Press the right arrow and select exit.

    Then you can go on with the instructions of Point 4.

    The rest of the HOWTO is ok.

    NOTE: I've always had Ubuntu complaining about errors with ndiswrapper ONLY during the bootstrap when I used a kernel compiled from a vanilla source. Apart from these error messages the kernel worked flawlessly, perhaps it was only my SDcard reader which was not properly detected (I can't test it as I've never used a SDcard).
    ---------------------------------------------------------------------------------------------------------------------------------

    Alberto
    Last edited by tseliot; July 21st, 2008 at 10:41 AM.

  2. #2
    Join Date
    Aug 2005
    Location
    Europe, Italia, Roma.
    Beans
    13

    Re: HOWTO: Kernel Compilation for Newbies

    Bella guida! Good job!

    Ciao

  3. #3
    Join Date
    May 2005
    Location
    Lecce, Italy
    Beans
    6,168
    Distro
    Ubuntu

    Re: HOWTO: Kernel Compilation for Newbies

    Grazie, spero che sia utile ai nuovi arrivati.

    Thanks

  4. #4
    Join Date
    Jun 2005
    Location
    Sweden
    Beans
    109

    Re: HOWTO: Kernel Compilation for Newbies

    Nice guide. Thanks!

  5. #5
    Join Date
    Aug 2005
    Beans
    2

    Re: HOWTO: Kernel Compilation for Newbies

    Great guide !!

    Thanks a lot !

  6. #6
    Join Date
    Aug 2005
    Beans
    102

    Re: HOWTO: Kernel Compilation for Newbies

    Quote Originally Posted by tseliot
    (if you are using KDE, the graphic interface that comes with Kubuntu)
    sudo kate /etc/X11/xorg.conf

    Scroll down the text until you find this section (this is my configuration):

    Section "Device"
    Identifier "ATI Technologies, Inc. Radeon 330M/340M/350M (RS200 IGP)"
    Driver "ati"
    BusID "PCI:1:5:0"

    Substitute the word in red with “vesa”, make it look like this:
    Section "Device"
    Identifier "ATI Technologies, Inc. Radeon 330M/340M/350M (RS200 IGP)"
    Driver "vesa"
    BusID "PCI:1:5:0"

    Save and exit. Restart the computer and go to the next step.
    Question regarding this.
    My driver is listed as "fglrx". I'm using ATI's 8.14.13 drivers. Do I still enter 'vesa' ? What does that mean? Will I have to reinstall my ATI drivers after recompiling the kernel?

    Thanks.

  7. #7
    Join Date
    May 2005
    Location
    Lecce, Italy
    Beans
    6,168
    Distro
    Ubuntu

    Re: HOWTO: Kernel Compilation for Newbies

    Quote Originally Posted by Dolphin
    Question regarding this.
    My driver is listed as "fglrx". I'm using ATI's 8.14.13 drivers. Do I still enter 'vesa' ? What does that mean? Will I have to reinstall my ATI drivers after recompiling the kernel?

    Thanks.
    Yes you will have to reinstall the driver after booting with the new kernel, I'll edit the guide and make this clear.

    If you put "vesa" you will use a generic driver (without 3d acceleration). If you don't do that, the modules of ATI drivers (which had been compiled for your previous kernel by ATI driver installer, I suppose) won't work with your new kernel and you won't be able to start and use GNOME or KDE because Xserver won't work. I know it because that's the way it works with nvidia drivers (I have never installed ATI proprietary drivers though)

  8. #8
    Join Date
    May 2005
    Location
    Lecce, Italy
    Beans
    6,168
    Distro
    Ubuntu

    Re: HOWTO: Kernel Compilation for Newbies

    However in your case you can also put "ATI" (ATI generic drivers) which also work on the the notebook from which I have written the guide. It's just a temporary thing until you boot with the new kernel and reinstall your graphic driver again.

  9. #9
    Join Date
    Jul 2005
    Location
    KRK, Poland
    Beans
    180
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: HOWTO: Kernel Compilation for Newbies

    d0h! thanks a lot tseliot!

    i dont have much time now but i will do it for sure tommorow morning. it looks straight and clear enought for me . i will write the results.

    copter :]

  10. #10
    Join Date
    Aug 2005
    Beans
    2

    Re: HOWTO: Kernel Compilation for Newbies

    Uauu, now my Ubuntu is flying

    Simple, and Fast !

    Thanks again

Page 1 of 29 12311 ... LastLast

Bookmarks

Posting Permissions

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