Kernel Compilation

From ArchWiki
Revision as of 20:34, 23 July 2005 by Maxsipos (talk | contribs)
Jump to navigation Jump to search

Kernel Compilation

You can choose to compile the kernel using /usr/src (this document), or via ABS: Kernel Compilation With ABS. A small minority of Arch users prefer the /usr/src way, however using ABS is helpful for automating certain tasks. The choice is yours, neither way is inherently better than the other.

The below summary is helpful for building Arch kernels. This normal way of compiling kernels is common to all distros. There is a comprehensive Howto on the subject, for more information: Kernel-Build-HOWTO

  • Move the Arch default kernel headers out of the way. This is better than removing them, so you have a backup
# cd /usr/src
# mv linux-2.x.x linux-2.x.x.arch
# mv /lib/modules/linux-2.x.x /lib/modules/linux-2.x.x.arch
# mv /boot/vmlinuz2x vmlinuz-2.x.x.arch
# mv /boot/System.map2x
# mv /boot/kconfig2x /boot/kconfig-2.x.x.arch

It is a very good idea, to change your grub / lilo config to be able boot this stuff. There should be info on how to do this here

  • Fetch the source from, where xx is your country key (f.e. 'us', 'de', 'uk', ... - Check [1] for a list of mirrors). If you have no ftp gui, you can use wget. For this example, we will fetch and compile 2.6.6; you should need to change only the version to get a different kernel.
# wget
  • Move/Copy it to /usr/src.
  • Unpack it
# tar --bzip2 -xvf linux-2.6.6.tar.bz2
  • (Optional) Copy the old .config file, if you want to modify default Arch settings.
# cp /usr/src/linux-2.x.x.arch/.config /usr/src/linux-2.6.6/
  • Change the directory to configure your kernel. Remember to activate devfs stuff if you use it (not if you are a udev user). There should be mention of which options these are
# rm /usr/src/linux
# ln -s /usr/src/linux-2.66 /usr/src/linux
# cd /usr/src/linux
# make oldconfig       (If you've copied the old .config file)
# make menuconfig

You can also use make xconfig (depends on Qt) or make gconfig (depends on GTK), instead of make menuconfig.

  • Save your config. Its a good idea to make a backup copy, since you will likely be doing this multiple times until you get all the options right.
  • Compile it. Warning: Don't run make all if you use grub and still have lilo installed. It will configure lilo in the end, and you may no longer boot your machine!
# make -s clean bzImage modules modules_install
  • Copy kernel.
# cp -v /usr/src/linux-2.6.6/arch/i386/boot/bzImage /boot/vmlinuz-2.6.6-revision1
# cp -v /usr/src/linux-2.6.6/arch/i386/Kconfig /boot/Kconfig-2.6.6-revision1
# cp -v /usr/src/linux-2.6.6/ /boot/

or, if you run lilo, let the install script copy the files and configure lilo. You are, of course, free to change the name of the kernel, Kconfig, and files. The name-version-revision system is helpful for keeping track which of several kernel compiles you have used. You could also try including a date or time, or stick to a simpler naming system if you wish.

# cd /usr/src/linux-2.6.5/arch/i386/boot/
# sh ./
  • Configure Grub or Lilo, if not already done.

If you use lilo, remember to type lilo at the prompt to update it.