Compiling Linux Kernel 3.0

INCOMPLETE ARTICLE!

The new version 3.0 of the kernel was released 3 days ago (07/22/2011) and I decided to compile and install it on my laptops and post the results here. I did it first on an Ubuntu 11.04 and then on Arch Linux, but the process is similar for any Linux distribution.

Note: In Arch Linux, there is also the possibility of compiling the kernel using the ABS + Pacman system. But for now, I will only comment on the traditional method.

ATTENTION! This is a new version with several bugs, I installed it only for educational purposes. I recommend waiting a few more weeks for the package provided by your distribution, which will save you some hours of compilation and possible crashes.

This tutorial is also useful for those who need to modify a module or apply a patch to activate new features or support new hardware. The steps are quite simple, and if something goes wrong, you will probably be able to revert to the previous kernel. However, proceed with caution and create backups of your important files. I am not responsible for any problems resulting from the installation of the new kernel.

Procedures:

  1. Install all development tools used for compilation

    In Ubuntu:

    $ sudo apt-get install gcc
    

    In Arch:

    $ sudo pacman -S gcc
    
  2. Download the kernel package. Here I will use the one available at http://www.kernel.org, as it is still the only v3.0 available. Custom versions for other distributions will be released soon.

    $ wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.bz2
    
  3. Unpack the package in a folder (I used ~/src here)

    $ tar jxvf linux-3.0.tar.bz2 -C ~/src
    
  4. It is recommended (not required) to copy the current configurations and only modify what is necessary.

    cp /usr/src/linux-headers-2.6.38-8-generic-pae/.config ~/src/linux-3.0
    

    In Ubuntu’s .config file, I saw that MANY items can be removed. Remove ALL network, wireless, video, and other device drivers that you do not have or will not need. This will significantly reduce kernel compilation and loading time.

  5. Go to the folder that was just extracted (cd ~/src/linux-3.0) to start the configuration.

    We have the following tool options:

    • $ make config -> Plain text mode. Contains several questions to be answered.
    • $ make menuconfig -> ncurses interface
    • $ make xconfig -> QT GUI.
    • $ make gconfig -> GTK GUI

    Here I will use menuconfig, as I don’t need X, but for beginners running QT, I really liked xconfig because it provides easier access to help.

    Navigate through the menus and choose what needs to be modified.

    • Y -> Embeds the item in the kernel
    • M -> Compiles the item as a loadable module
    • N -> Disables the item
    • ? -> Help related to the item
    • / -> Search
    • -> Space toggles between options
    • ESC -> Up one level or exit configuration

    Save the configurations.

  6. Start compiling the kernel and go do something else. It took over an hour here.

    $ make -j2
    

    On dual-core processors, it is better to use “make -j3”, on quad-cores it is better make -j5 and so on (make -jX; where X = cores+1).

  7. After compilation, you need to install the kernel and modules

    $ make modules
    $ sudo make modules_install
    $ sudo make install
    
  8. Check if your /boot/grub/grub.cfg has been changed. If not, add the new kernel. Here it automatically added the following lines:

    (menuentry 'Ubuntu, with Linux 3.0.0Julio' --class ubuntu --class gnu-linux --class gnu --class os {
            recordfail
            set gfxpayload=$linux_gfx_mode
            insmod part_msdos
            insmod ext2
            set root='(/dev/sda,msdos6)'
            search --no-floppy --fs-uuid --set=root 6d6b6bce-af80-450f-943f-23c0a2bed958
            linux	/vmlinuz-3.0.0Julio root=/dev/sda7 ro   quiet splash vt.handoff=7
        }
    
  9. Reboot the computer and boot the new kernel.

    $ sudo reboot
    

If a kernel panic occurs, you can boot into the old kernel and try to fix the error.


Julio Batista Silva
Julio Batista Silva
Data Engineer

I’m a computer engineer passionate about science, technology, photography, and languages. Currently working as a Data Engineer in Germany.

comments powered by Disqus