Announcement

Collapse
No announcement yet.

Building your own kernel

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Building your own kernel

    First of all, I want to say thanks to Agios for the original how-to as that is where this one comes from. Agios's version is located here: http://timia.net/agios/index.php?page=UbuntuKernel The information he got and put together came from this how-to originally: http://www.ubuntuforums.org/showthre...kernel+compile

    Below are the steps Agios and I have both followed exactly to build the 2.6.17.7 kernel deb packages without any issues at all so far. It *should* work for you. However, be warned that you might need to add support for things like wireless internet and other things. This how-to also tells how to install the Nvidia drivers. Unfortunately, neither of us use ATI, so it won't tell you how to do that.

    Ubuntu discourages compiling your own kernel. However, I not only wanted this ability I needed it for my hardware. I referenced a thread on the Ubuntu forums and compiled a new kernel from kernel.org using the following steps.

    Become root and make sure you have the required packages installed.

    Code:
    sudo su -
    apt-get install build-essential bin86 kernel-package libqt3-headers libqt3-mt-dev wget
    Download the desired kernel source from kernel.org to the /usr/src directory. Extract it and set up the linux symbolic link.

    Code:
    cd /usr/src
    wget [url]http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.6.tar.bz2[/url]
    tar -xvjf linux-2.6.17.6.tar.bz2
    rm -rf linux
    ln -s /usr/src/linux-2.6.17.6 linux
    Navigate to the kernel sources top level directory.

    Code:
    cd /usr/src/linux
    If you have any kernel patches to apply, do it now.

    Code:
    patch p1 <my.patch
    Assuming you don't want to configure the kernel from scratch, copy over your current kernel config.

    Code:
    cp /boot/config-`uname -r` .config
    Configure the new kernel. You cannot run xconfig from a root login shell so get out of root and use kdesu.

    Code:
    exit
    cd /usr/src/linux
    kdesu make xconfig
    **NOTE** Once you run the above command, a window labeled qconf should popup on your screen. This is where you can tweak the settings of the kernel. You will need to disable 3 settings for sure or it's a good possibility that the build will error on your. First you'll want to find the 'Multimedia Devices' section and expand it if necessary. Then you will need to find the 'Digital Video Broadcasting Devices' section and click on it. When you do, it should bring up some information in the panel on the right. There are 3 check boxes for Budget cards. Make sure they are empty.

    You'll also want to make a couple of other minor tweaks that I suggest. Go to the Processor type and features section and set the processor type accordingly to whatever type of processor you have. I have also set the 'Preemption Model' to 'Voluntary' and the 'Time Frequency' I set to '1000'. Click on 'Save' at the top and then you can proceed with the next steps. **NOTE**

    **SPECIAL NOTE** You want to set the following options as well. Below is a very generic description of what you should do. It's for enabling iptables stuff within the kernel. Without setting these values below, you will *not* have iptables functionality in your new kernel once it's built.

    Networking -> Networking options -> Network packet filtering:

    Core Netfilter Configuration - select ALL options as modules.
    IP: Netfilter Configuration - select ALL options except the EXPERIMENTAL options as modules.
    By ALL I mean every option under those sections that can be configured. **SPECIAL NOTE**

    Device Drivers:

    If you want sensors to work select the I2C options.

    If you are using a config from a previous running kernel most everything else should be set for you. If you want to lean up your kernel you can go through the various options and deselect those for hardware you know you don't have. I typically just leave them in. I would not make a lot of changes at once lest you end up with a broken kernel with no idea what specific change you made to break it.

    Code:
    sudo su -
    cd /usr/src/linux
    Compile the kernel. You may change the revision from 686 to whatever you wish. i.e. 386, k7, etc. The clean step runs quickly but the make-pkg -initrd command takes a long time based on your system. Expect 1 - 3 hours.

    Code:
    make-kpkg clean
    make-kpkg -initrd --revision=686 kernel_image kernel_headers modules_image
    The steps above will create two deb files in /usr/src. Install them as follows:

    Code:
    cd /usr/src
    dpkg -i kernel-headers-2.6.17.6_686_i386.deb
    dpkg -i kernel-image-2.6.17.6_686_i386.deb
    I have a Nvidia video card and use the proprietary drivers. Installing a new kernel requires reinstallation of the Nvidia drivers too. Unfortunately you need to do this while running the new kernel. In preparation I downloaded and extracted the nvidia kernel source.

    Code:
    apt-get install nvidia-kernel-source
    cd /usr/src/
    tar zxvf nvidia-kernel-source.tar.gz
    Then rebooted to the new kernel in recovery mode to keep X from trying to start and completed the nvidia install.

    Code:
    cd /usr/src/modules/nvidia-kernel/nv/
    make module
    make install
    Then reboot normally and you should be up and running with your new kernel!

    To clean up old unused kernels use apt-get remove if you installed them with apt. If you rolled your own kernel with the instructions above then use dpkg --purge to remove the two deb packages you installed above. You can also delete any applicable files and directorys for the old kernel in /usr/src. Kernel files are located in the following places:

    Code:
    /boot/grub/menu.lst
    /boot
    /usr/src
    /lib/modules
    /usr/share/doc/kernel*
    I learned a long time ago that it is wise to keep the kernel source for your live kernels, just in case. If you are running a Ubuntu kernel you can get the source by installing the appropriate linux-source-<version> package.

    #2
    Re: Building your own kernel

    thanks, this would make a good sticky somewhere......

    cheers

    Comment

    Working...
    X