![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Python Enthusiast
![]() |
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 (if you are using KDE, the graphic interface that comes with Kubuntu) Code:
sudo kate /etc/X11/xorg.conf Code:
Section "Device" Identifier "ATI Technologies, Inc. Radeon 330M/340M/350M (RS200 IGP)" Driver "ati" BusID "PCI:1:5:0" Code:
Section "Device" Identifier "ATI Technologies, Inc. Radeon 330M/340M/350M (RS200 IGP)" Driver "vesa" BusID "PCI:1:5:0" 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 2) Download the Ubuntu kernel sources: Code:
sudo apt-get install linux-source 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 Code:
sudo make oldconfig (so as not to compile the entire kernel from scratch) Code:
sudo make menuconfig 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) 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 Code:
Select ATA/ATAPI/MFM/RLL support 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 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 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 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) 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 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 05:41 AM.. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|