Difference between revisions of "Kernel Compilation"

From ArchWiki
Jump to: navigation, search
(Changed this article to a general kernel compilation resource)
Line 1: Line 1:
==Kernel Compilation==
==Kernel Compilation==
You can choose to compile the kernel using <code>/usr/src</code> (this document), or via [[ABS]]: [[Kernel Compilation With ABS]]. A small minority of Arch users prefer the <code>/usr/src</code> way, however using [[ABS]] is helpful for automating certain tasks.  The choice is yours, neither way is inherently better than the other.
There is multiple ways to compile a custom kernel under Arch.
* [[Kernel Compilation From Source]]
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: [http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html Kernel-Build-HOWTO]
* Via [[ABS]]:
** [[Kernel Compilation With ABS 2.4 | Kernel 2.4]]
* Move the Arch default kernel headers out of the way. This is better than removing them, so you have a backup
** [[Kernel Compilation With ABS (2.6.8 or Earlier) | Kernel 2.6.8 or Earlier]]
# cd /usr/src
** [[Custom Kernel Compilation with ABS (2.6.9 and later) | Kernel 2.6.9 and Later]]
# 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 System.map-2.x.x.arch
# 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 <code>ftp.xx.kernel.org/pub/linux/kernel/</code>, where xx is your country key (f.e. 'us', 'de', 'uk', ... - Check [http://www.kernel.org] for a list of mirrors). If you have no ftp gui, you can use <code>wget</code>. 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 ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
* Move/Copy it to <code>/usr/src</code>.
* 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 <code>make xconfig</code> (depends on Qt) or <code>make gconfig</code> (depends on GTK), instead of <code>make menuconfig</code>.
* 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 <code>make all</code> 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/System.map /boot/System.map-2.6.6-revision1
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 <code>kernel</code>, <code>Kconfig</code>, and <code>System.map</code> files. The <code>name-version-revision</code> 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.
There is also two other articles.
* [[Kernel Compliation with ABS]]
# cd /usr/src/linux-2.6.5/arch/i386/boot/
* [[Kernel PKGBUILD Prototype]]
# sh ./install.sh
* Configure [[Grub]] or [[Lilo]], if not already done.
If you use lilo, remember to type <code>lilo</code> at the prompt to update it.

Revision as of 18:34, 24 July 2005

Kernel Compilation

There is multiple ways to compile a custom kernel under Arch.

There is also two other articles.