Compiling the Linux 3.0 Kernel

Jul 25, 2011·
Julio Batista Silva
Julio Batista Silva
· 3 min read
blog Linux
INCOMPLETE ARTICLE!

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

Note: On Arch Linux there is also the option of compiling the kernel using the ABS + Pacman system. But for now I will only cover the traditional method.

WARNING! This is a new version with several bugs; I only did the installation for educational purposes. I recommend waiting a few more weeks for the package your distribution ships, which will save you a few hours of compiling and possible crashes.

This tutorial is also useful for anyone who needs to modify a module or apply a patch to enable new features or support new hardware. The steps are quite simple and, if something goes wrong, you will probably be able to go back to the previous kernel. Even so, proceed carefully and back up your important files; I take no responsibility for any problems resulting from installing the new kernel.

Steps:

  1. Install all the development tools used for compiling

    On Ubuntu:

    $ sudo apt-get install gcc
    

    On Arch:

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

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

    $ tar jxvf linux-3.0.tar.bz2 -C ~/src
    
  4. It is recommended (not required) to copy the current configuration and only change what you need.

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

    In Ubuntu’s .config I saw that MANY items can be removed. Remove ALL the network, wireless, video and other device drivers you do not have or will not need. That will considerably cut the compile and kernel load time.

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

    We have the following tool options:

    • $ make config -> Plain text mode. It asks a lot of questions to answer.
    • $ make menuconfig -> ncurses interface
    • $ make xconfig -> QT GUI.
    • $ make gconfig -> GTK GUI

    Here I will use menuconfig, since it does not need X, but for beginners running QT I quite liked xconfig, since it gives easier access to the help.

    Work your way through the menus and pick what should be changed.

    • Y -> Builds the item into the kernel
    • M -> Builds the item as a loadable module
    • N -> Disables the item
    • ? -> Help for the item
    • / -> Search
    • -> Space toggles between options
    • ESC -> Goes up one level or leaves the configuration

    Save the configuration.

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

    $ make -j2
    

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

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

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

    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. Restart the computer and boot the new kernel.

    $ sudo reboot
    

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


Julio Batista Silva
Authors
Senior Cloud Developer

I’m a Brazilian computer engineer based in Germany, passionate about tech, science, photography, and languages.

I’ve been programming for about two decades already, exploring everything from mobile apps and web development to machine learning. These days I focus on cloud SRE and data engineering.

I volunteer in the open source and Python communities, helping organize PyCon DE and PyData Berlin, mentoring, and contributing with code and translations.

On my blog, I share Linux tips, setup guides, and personal notes I’ve written for future reference. I hope others find them helpful as well. The content is available in multiple languages.

Browse my gallery for some of my photography.

Away from the keyboard, you’ll find me at concerts, playing clarinet, cycling, scuba diving, or exploring new places, cultures, and cuisines.

Always happy to connect! 🙂

comments powered by Disqus