https://wiki.archlinux.org/api.php?action=feedcontributions&user=Llg179&feedformat=atomArchWiki - User contributions [en]2024-03-29T10:56:45ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Kernel/Traditional_compilation&diff=188382Kernel/Traditional compilation2012-03-08T23:55:00Z<p>Llg179: /* Configure your kernel */</p>
<hr />
<div>[[Category:Kernel (English)]]<br />
{{i18n|Kernels/Compilation/Traditional}}<br />
<br />
The summary below is helpful for building custom kernels from '''kernel.org sources'''. This method of compiling kernels is the traditional method common to all distros; however, an excellent method of cleanly installing the custom kernel with makepkg and pacman is also included. <br />
<br />
Alternatively, you can use ABS to build and install your kernel; see: [[Kernels#Compilation]]. Using the existing {{Pkg|linux}} PKGBUILD will automate most of the process and will result in a package. However, some Arch users prefer the {{ic|traditional}} way.<br />
<br />
== Fetching source ==<br />
* Fetch the kernel source from {{ic|ftp.xx.kernel.org/pub/linux/kernel/}}, where xx is your country key (e.g. 'us', 'uk', 'de', ... - Check [http://www.kernel.org] for a complete list of mirrors). If you have no ftp gui, you can use {{ic|wget}}. For this example, we will fetch and compile 2.6.32.8; you should need to change only the version to get a different kernel.<br />
For instance:<br />
$ wget -c http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.8.tar.bz2<br />
* It is always a good idea to verify the signature for any downloaded tarball. See [http://kernel.org/signature.html#using-gnupg-to-verify-kernel-signatures kernel.org/signature] for how this works and other details. <br />
<br />
* Copy the kernel source to your build directory, e.g.:<br />
$ cp linux-2.6.32.8.tar.bz2 ~/kernelbuild/<br />
<br />
* Unpack it and enter the source directory:<br />
$ cd ~/kernelbuild<br />
$ tar -xvjf linux-2.6.32.8.tar.bz2<br />
$ cd linux-2.6.32.8<br />
Prepare for compilation by running the following command:<br />
make mrproper<br />
This ensures that the kernel tree is absolutely clean. The kernel team recommends that this command be issued prior to each kernel compilation. Do not rely on the source tree being clean after un-tarring.<br />
<br />
== Build configuration ==<br />
This is the most crucial step in customizing the kernel to reflect your computer's precise specifications. By setting the configurations in 'menuconfig' properly, your kernel and computer will function most efficiently.<br />
<br />
=== Get .config file ===<br />
Optional. Copy the .config file from the running kernel, if you want to modify default Arch settings.<br />
$ zcat /proc/config.gz > .config<br />
<br />
=== Configure your kernel ===<br />
<br />
There are two choice:<br />
* Traditional menuconfig<br />
$ make menuconfig (Will start with a fresh '.config'. Option dependencies are usually automatically selected.)<br />
<br />
Make your changes to the kernel and save your config file. It is a good idea to make a backup copy, since you will likely be doing this multiple times until you get all the options right. If you cannot boot your newly built kernel see the list of necessary config items [http://www.archlinux.org/news/users-of-unofficial-kernels-must-enable-devtmpfs-support/ here]. Running $ lspci -k # from liveCD lists names of kernel modules in use.<br />
<br />
* localmodconfig <br />
Since kernel 2.6.32, localmodconfig is provided to ease kernel configuration:<br />
<br />
$ make oldconfig (Only works with the old '.config' file, copied into the build directory. Also marks previously unused options as 'NEW'.)<br />
$ make localmodconfig (Tries to extract /proc/config.gz from running kernel. Pre-selecting options/modules in use.)<br />
$ make localyesconfig (Same as above, except that as many modules as possible compiled into the kernel.)<br />
$ make xconfig (Depends on Qt. A nicer interface. Dependency checking not verified.)<br />
$ make gconfig (Depends on GTK. Otherwise same as xconfig.)<br />
$ make help (Lists ALL targets available.)<br />
<br />
For more information about the build target "localmodconfig" refer to the [http://kernelnewbies.org/Linux_2_6_32#head-11f54cdac41ad6150ef817fd68597554d9d05a5f 2.6.32 release notes].''<br />
<br />
==== Local version ====<br />
If you are compiling a kernel using your current config file, do not forget to rename your kernel version, or you may replace your existing one by mistake.<br />
<br />
$ make menuconfig<br />
General setup ---><br />
(-ARCH) Local version - append to kernel release '3.n.n-RCn'<br />
<br />
=== What about /usr/src/ ? ===<br />
Using the /usr/src/ directory for kernel compilation as root, along with the creation of the corresponding symlink, is considered poor practice by some kernel hackers. They consider the cleanest method to simply use your home directory. If you subscribe to this point of view, build and configure your kernel as normal user, and install as root, or [[Kernels/Compilation/Arch Build System|with makepkg and pacman]]. <br />
<br />
However, this concept has been the target of debate, and other very experienced hackers consider the practice of compiling as root under /usr/src/ to be completely safe, acceptable and even preferable. <br />
<br />
Use whichever method you feel more comfortable with.<br />
<br />
== Compilation and installation ==<br />
To compile kernel manually, follow these steps:<br />
<br />
=== Compile ===<br />
{{Warning | Do not run {{ic|make all}} if you use GRUB and still have LILO installed; it will configure LILO in the end, and you may no longer be able to boot your machine! Remove LILO (pacman -R lilo) before running {{ic|make all}} if you use GRUB!}}<br />
$ make (Same as make vmlinux && make modules && make bzImage - see 'make help' for more information on this.)<br />
or<br />
$ make -jN (N = # of processors + 1) (This utilizes all CPUs at 100% A Dual-core[-j3] 2.8Ghz compiled in less than 15 minutes.)<br />
<br />
=== Install modules ===<br />
This needs to be done as root.<br />
# make modules_install<br />
<br />
This copies the compiled modules into a directory in /lib/modules named by the kernel version and appended string you set in menuconfig. This way, modules are kept separate from those used by other kernels on your machine.<br />
<br />
=== Copy kernel to /boot directory ===<br />
# cp -v arch/x86/boot/bzImage /boot/vmlinuz-YourKernelName<br />
<br />
=== Make initial RAM disk ===<br />
The initial RAM disk (initrd option in the GRUB menu, or, the file "initramfs-YourKernelName.img") is an initial root file system that is mounted prior to when the real root file system is available. The initrd is bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd as part of the two-stage boot process to load the modules to make the real file systems available and get at the real root file system. The initrd contains a minimal set of directories and executables to achieve this, such as the insmod tool to install kernel modules into the kernel. In the case of desktop or server Linux systems, the initrd is a transient file system. Its lifetime is short, only serving as a bridge to the real root file system. In embedded systems with no mutable storage, the initrd is the permanent root file system.<br />
<br />
If you need any modules loaded in order to mount the root filesystem, build a ramdisk (most users need this). The -k parameter accepts the kernel version and appended string you set in menuconfig and is used to locate the modules in /lib/modules:<br />
<br />
# mkinitcpio -k FullKernelName -g /boot/initramfs-YourKernelName.img<br />
<br />
You are free to name the /boot files anything you want. However, using the [kernel-major-minor-revision] naming scheme helps to keep order if you: Keep multiple kernels/ Use mkinitcpio often/ Build third-party modules.<br />
<br />
If you are using LILO and it cannot communicate with the kernel device-mapper driver, you have to run {{ic|modprobe dm-mod}} first.<br />
<br />
=== Copy System.map ===<br />
The System.map file is not required for booting Linux. It is a type of "phone directory" list of functions in a particular build of a kernel. The System.map contains a list of kernel symbols (i.e function names, variable names etc) and their corresponding addresses. This "symbol-name to address mapping" is used by:<br />
<br />
* Some processes like klogd, ksymoops etc<br />
* By OOPS handler when information has to be dumped to the screen during a kernel crash (i.e info like in which function it has crashed).<br />
<br />
Copy System.map to /boot and create symlink<br />
# cp System.map /boot/System.map-YourKernelName<br />
<br />
After completing all steps above, you should have the following 3 files and 1 soft symlink in your /boot directory along with any other previously existing files:<br />
vmlinuz-YourKernelName (Kernel)<br />
initramfs-YourKernelName.img (Ramdisk)<br />
System.map-YourKernelName (System Map)<br />
<br />
== Bootloader configuration ==<br />
<br />
Add an entry for your amazing new kernel in your bootloader's configuration file - see [[GRUB]] or [[LILO]] for examples. Note that if you use LILO, the kernel sources include a script to automate the process:<br />
<br />
$ arch/i386/boot/install.sh<br />
<br />
If you use LILO, remember to type {{ic|lilo}} as root at the prompt to update it.<br />
<br />
== Using the NVIDIA video driver with your custom kernel ==<br />
To use the NVIDIA driver with your new custom kernel, see: [[NVIDIA#Alternate_install:_custom_kernel|Installing the driver for a custom kernel]]. You can also install nvidia drivers from AUR.</div>Llg179https://wiki.archlinux.org/index.php?title=Kernel/Traditional_compilation&diff=188381Kernel/Traditional compilation2012-03-08T23:54:14Z<p>Llg179: /* Configure your kernel */</p>
<hr />
<div>[[Category:Kernel (English)]]<br />
{{i18n|Kernels/Compilation/Traditional}}<br />
<br />
The summary below is helpful for building custom kernels from '''kernel.org sources'''. This method of compiling kernels is the traditional method common to all distros; however, an excellent method of cleanly installing the custom kernel with makepkg and pacman is also included. <br />
<br />
Alternatively, you can use ABS to build and install your kernel; see: [[Kernels#Compilation]]. Using the existing {{Pkg|linux}} PKGBUILD will automate most of the process and will result in a package. However, some Arch users prefer the {{ic|traditional}} way.<br />
<br />
== Fetching source ==<br />
* Fetch the kernel source from {{ic|ftp.xx.kernel.org/pub/linux/kernel/}}, where xx is your country key (e.g. 'us', 'uk', 'de', ... - Check [http://www.kernel.org] for a complete list of mirrors). If you have no ftp gui, you can use {{ic|wget}}. For this example, we will fetch and compile 2.6.32.8; you should need to change only the version to get a different kernel.<br />
For instance:<br />
$ wget -c http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.8.tar.bz2<br />
* It is always a good idea to verify the signature for any downloaded tarball. See [http://kernel.org/signature.html#using-gnupg-to-verify-kernel-signatures kernel.org/signature] for how this works and other details. <br />
<br />
* Copy the kernel source to your build directory, e.g.:<br />
$ cp linux-2.6.32.8.tar.bz2 ~/kernelbuild/<br />
<br />
* Unpack it and enter the source directory:<br />
$ cd ~/kernelbuild<br />
$ tar -xvjf linux-2.6.32.8.tar.bz2<br />
$ cd linux-2.6.32.8<br />
Prepare for compilation by running the following command:<br />
make mrproper<br />
This ensures that the kernel tree is absolutely clean. The kernel team recommends that this command be issued prior to each kernel compilation. Do not rely on the source tree being clean after un-tarring.<br />
<br />
== Build configuration ==<br />
This is the most crucial step in customizing the kernel to reflect your computer's precise specifications. By setting the configurations in 'menuconfig' properly, your kernel and computer will function most efficiently.<br />
<br />
=== Get .config file ===<br />
Optional. Copy the .config file from the running kernel, if you want to modify default Arch settings.<br />
$ zcat /proc/config.gz > .config<br />
<br />
=== Configure your kernel ===<br />
<br />
There are two choice:<br />
* Traditional menuconfig<br />
$ make menuconfig (Will start with a fresh '.config'. Option dependencies are usually automatically selected.)<br />
<br />
Make your changes to the kernel and save your config file. It is a good idea to make a backup copy, since you will likely be doing this multiple times until you get all the options right. If you cannot boot your newly built kernel see the list of necessary config items [http://www.archlinux.org/news/users-of-unofficial-kernels-must-enable-devtmpfs-support/ here]. Running [code]lspci -k[/code] from liveCD lists names of kernel modules in use.<br />
<br />
* localmodconfig <br />
Since kernel 2.6.32, localmodconfig is provided to ease kernel configuration:<br />
<br />
$ make oldconfig (Only works with the old '.config' file, copied into the build directory. Also marks previously unused options as 'NEW'.)<br />
$ make localmodconfig (Tries to extract /proc/config.gz from running kernel. Pre-selecting options/modules in use.)<br />
$ make localyesconfig (Same as above, except that as many modules as possible compiled into the kernel.)<br />
$ make xconfig (Depends on Qt. A nicer interface. Dependency checking not verified.)<br />
$ make gconfig (Depends on GTK. Otherwise same as xconfig.)<br />
$ make help (Lists ALL targets available.)<br />
<br />
For more information about the build target "localmodconfig" refer to the [http://kernelnewbies.org/Linux_2_6_32#head-11f54cdac41ad6150ef817fd68597554d9d05a5f 2.6.32 release notes].''<br />
<br />
==== Local version ====<br />
If you are compiling a kernel using your current config file, do not forget to rename your kernel version, or you may replace your existing one by mistake.<br />
<br />
$ make menuconfig<br />
General setup ---><br />
(-ARCH) Local version - append to kernel release '3.n.n-RCn'<br />
<br />
=== What about /usr/src/ ? ===<br />
Using the /usr/src/ directory for kernel compilation as root, along with the creation of the corresponding symlink, is considered poor practice by some kernel hackers. They consider the cleanest method to simply use your home directory. If you subscribe to this point of view, build and configure your kernel as normal user, and install as root, or [[Kernels/Compilation/Arch Build System|with makepkg and pacman]]. <br />
<br />
However, this concept has been the target of debate, and other very experienced hackers consider the practice of compiling as root under /usr/src/ to be completely safe, acceptable and even preferable. <br />
<br />
Use whichever method you feel more comfortable with.<br />
<br />
== Compilation and installation ==<br />
To compile kernel manually, follow these steps:<br />
<br />
=== Compile ===<br />
{{Warning | Do not run {{ic|make all}} if you use GRUB and still have LILO installed; it will configure LILO in the end, and you may no longer be able to boot your machine! Remove LILO (pacman -R lilo) before running {{ic|make all}} if you use GRUB!}}<br />
$ make (Same as make vmlinux && make modules && make bzImage - see 'make help' for more information on this.)<br />
or<br />
$ make -jN (N = # of processors + 1) (This utilizes all CPUs at 100% A Dual-core[-j3] 2.8Ghz compiled in less than 15 minutes.)<br />
<br />
=== Install modules ===<br />
This needs to be done as root.<br />
# make modules_install<br />
<br />
This copies the compiled modules into a directory in /lib/modules named by the kernel version and appended string you set in menuconfig. This way, modules are kept separate from those used by other kernels on your machine.<br />
<br />
=== Copy kernel to /boot directory ===<br />
# cp -v arch/x86/boot/bzImage /boot/vmlinuz-YourKernelName<br />
<br />
=== Make initial RAM disk ===<br />
The initial RAM disk (initrd option in the GRUB menu, or, the file "initramfs-YourKernelName.img") is an initial root file system that is mounted prior to when the real root file system is available. The initrd is bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd as part of the two-stage boot process to load the modules to make the real file systems available and get at the real root file system. The initrd contains a minimal set of directories and executables to achieve this, such as the insmod tool to install kernel modules into the kernel. In the case of desktop or server Linux systems, the initrd is a transient file system. Its lifetime is short, only serving as a bridge to the real root file system. In embedded systems with no mutable storage, the initrd is the permanent root file system.<br />
<br />
If you need any modules loaded in order to mount the root filesystem, build a ramdisk (most users need this). The -k parameter accepts the kernel version and appended string you set in menuconfig and is used to locate the modules in /lib/modules:<br />
<br />
# mkinitcpio -k FullKernelName -g /boot/initramfs-YourKernelName.img<br />
<br />
You are free to name the /boot files anything you want. However, using the [kernel-major-minor-revision] naming scheme helps to keep order if you: Keep multiple kernels/ Use mkinitcpio often/ Build third-party modules.<br />
<br />
If you are using LILO and it cannot communicate with the kernel device-mapper driver, you have to run {{ic|modprobe dm-mod}} first.<br />
<br />
=== Copy System.map ===<br />
The System.map file is not required for booting Linux. It is a type of "phone directory" list of functions in a particular build of a kernel. The System.map contains a list of kernel symbols (i.e function names, variable names etc) and their corresponding addresses. This "symbol-name to address mapping" is used by:<br />
<br />
* Some processes like klogd, ksymoops etc<br />
* By OOPS handler when information has to be dumped to the screen during a kernel crash (i.e info like in which function it has crashed).<br />
<br />
Copy System.map to /boot and create symlink<br />
# cp System.map /boot/System.map-YourKernelName<br />
<br />
After completing all steps above, you should have the following 3 files and 1 soft symlink in your /boot directory along with any other previously existing files:<br />
vmlinuz-YourKernelName (Kernel)<br />
initramfs-YourKernelName.img (Ramdisk)<br />
System.map-YourKernelName (System Map)<br />
<br />
== Bootloader configuration ==<br />
<br />
Add an entry for your amazing new kernel in your bootloader's configuration file - see [[GRUB]] or [[LILO]] for examples. Note that if you use LILO, the kernel sources include a script to automate the process:<br />
<br />
$ arch/i386/boot/install.sh<br />
<br />
If you use LILO, remember to type {{ic|lilo}} as root at the prompt to update it.<br />
<br />
== Using the NVIDIA video driver with your custom kernel ==<br />
To use the NVIDIA driver with your new custom kernel, see: [[NVIDIA#Alternate_install:_custom_kernel|Installing the driver for a custom kernel]]. You can also install nvidia drivers from AUR.</div>Llg179https://wiki.archlinux.org/index.php?title=Kernel/Traditional_compilation&diff=188377Kernel/Traditional compilation2012-03-08T23:43:31Z<p>Llg179: /* Configure your kernel */</p>
<hr />
<div>[[Category:Kernel (English)]]<br />
{{i18n|Kernels/Compilation/Traditional}}<br />
<br />
The summary below is helpful for building custom kernels from '''kernel.org sources'''. This method of compiling kernels is the traditional method common to all distros; however, an excellent method of cleanly installing the custom kernel with makepkg and pacman is also included. <br />
<br />
Alternatively, you can use ABS to build and install your kernel; see: [[Kernels#Compilation]]. Using the existing {{Pkg|linux}} PKGBUILD will automate most of the process and will result in a package. However, some Arch users prefer the {{ic|traditional}} way.<br />
<br />
== Fetching source ==<br />
* Fetch the kernel source from {{ic|ftp.xx.kernel.org/pub/linux/kernel/}}, where xx is your country key (e.g. 'us', 'uk', 'de', ... - Check [http://www.kernel.org] for a complete list of mirrors). If you have no ftp gui, you can use {{ic|wget}}. For this example, we will fetch and compile 2.6.32.8; you should need to change only the version to get a different kernel.<br />
For instance:<br />
$ wget -c http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.8.tar.bz2<br />
* It is always a good idea to verify the signature for any downloaded tarball. See [http://kernel.org/signature.html#using-gnupg-to-verify-kernel-signatures kernel.org/signature] for how this works and other details. <br />
<br />
* Copy the kernel source to your build directory, e.g.:<br />
$ cp linux-2.6.32.8.tar.bz2 ~/kernelbuild/<br />
<br />
* Unpack it and enter the source directory:<br />
$ cd ~/kernelbuild<br />
$ tar -xvjf linux-2.6.32.8.tar.bz2<br />
$ cd linux-2.6.32.8<br />
Prepare for compilation by running the following command:<br />
make mrproper<br />
This ensures that the kernel tree is absolutely clean. The kernel team recommends that this command be issued prior to each kernel compilation. Do not rely on the source tree being clean after un-tarring.<br />
<br />
== Build configuration ==<br />
This is the most crucial step in customizing the kernel to reflect your computer's precise specifications. By setting the configurations in 'menuconfig' properly, your kernel and computer will function most efficiently.<br />
<br />
=== Get .config file ===<br />
Optional. Copy the .config file from the running kernel, if you want to modify default Arch settings.<br />
$ zcat /proc/config.gz > .config<br />
<br />
=== Configure your kernel ===<br />
<br />
There are two choice:<br />
* Traditional menuconfig<br />
$ make menuconfig (Will start with a fresh '.config'. Option dependencies are usually automatically selected.)<br />
<br />
Make your changes to the kernel and save your config file. It is a good idea to make a backup copy, since you will likely be doing this multiple times until you get all the options right. If you cannot boot your newly built kernel see the list of necessary config items [http://www.archlinux.org/news/users-of-unofficial-kernels-must-enable-devtmpfs-support/ here]<br />
<br />
* localmodconfig <br />
Since kernel 2.6.32, localmodconfig is provided to ease kernel configuration:<br />
<br />
$ make oldconfig (Only works with the old '.config' file, copied into the build directory. Also marks previously unused options as 'NEW'.)<br />
$ make localmodconfig (Tries to extract /proc/config.gz from running kernel. Pre-selecting options/modules in use.)<br />
$ make localyesconfig (Same as above, except that as many modules as possible compiled into the kernel.)<br />
$ make xconfig (Depends on Qt. A nicer interface. Dependency checking not verified.)<br />
$ make gconfig (Depends on GTK. Otherwise same as xconfig.)<br />
$ make help (Lists ALL targets available.)<br />
<br />
For more information about the build target "localmodconfig" refer to the [http://kernelnewbies.org/Linux_2_6_32#head-11f54cdac41ad6150ef817fd68597554d9d05a5f 2.6.32 release notes].''<br />
<br />
==== Local version ====<br />
If you are compiling a kernel using your current config file, do not forget to rename your kernel version, or you may replace your existing one by mistake.<br />
<br />
$ make menuconfig<br />
General setup ---><br />
(-ARCH) Local version - append to kernel release '3.n.n-RCn'<br />
<br />
=== What about /usr/src/ ? ===<br />
Using the /usr/src/ directory for kernel compilation as root, along with the creation of the corresponding symlink, is considered poor practice by some kernel hackers. They consider the cleanest method to simply use your home directory. If you subscribe to this point of view, build and configure your kernel as normal user, and install as root, or [[Kernels/Compilation/Arch Build System|with makepkg and pacman]]. <br />
<br />
However, this concept has been the target of debate, and other very experienced hackers consider the practice of compiling as root under /usr/src/ to be completely safe, acceptable and even preferable. <br />
<br />
Use whichever method you feel more comfortable with.<br />
<br />
== Compilation and installation ==<br />
To compile kernel manually, follow these steps:<br />
<br />
=== Compile ===<br />
{{Warning | Do not run {{ic|make all}} if you use GRUB and still have LILO installed; it will configure LILO in the end, and you may no longer be able to boot your machine! Remove LILO (pacman -R lilo) before running {{ic|make all}} if you use GRUB!}}<br />
$ make (Same as make vmlinux && make modules && make bzImage - see 'make help' for more information on this.)<br />
or<br />
$ make -jN (N = # of processors + 1) (This utilizes all CPUs at 100% A Dual-core[-j3] 2.8Ghz compiled in less than 15 minutes.)<br />
<br />
=== Install modules ===<br />
This needs to be done as root.<br />
# make modules_install<br />
<br />
This copies the compiled modules into a directory in /lib/modules named by the kernel version and appended string you set in menuconfig. This way, modules are kept separate from those used by other kernels on your machine.<br />
<br />
=== Copy kernel to /boot directory ===<br />
# cp -v arch/x86/boot/bzImage /boot/vmlinuz-YourKernelName<br />
<br />
=== Make initial RAM disk ===<br />
The initial RAM disk (initrd option in the GRUB menu, or, the file "initramfs-YourKernelName.img") is an initial root file system that is mounted prior to when the real root file system is available. The initrd is bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd as part of the two-stage boot process to load the modules to make the real file systems available and get at the real root file system. The initrd contains a minimal set of directories and executables to achieve this, such as the insmod tool to install kernel modules into the kernel. In the case of desktop or server Linux systems, the initrd is a transient file system. Its lifetime is short, only serving as a bridge to the real root file system. In embedded systems with no mutable storage, the initrd is the permanent root file system.<br />
<br />
If you need any modules loaded in order to mount the root filesystem, build a ramdisk (most users need this). The -k parameter accepts the kernel version and appended string you set in menuconfig and is used to locate the modules in /lib/modules:<br />
<br />
# mkinitcpio -k FullKernelName -g /boot/initramfs-YourKernelName.img<br />
<br />
You are free to name the /boot files anything you want. However, using the [kernel-major-minor-revision] naming scheme helps to keep order if you: Keep multiple kernels/ Use mkinitcpio often/ Build third-party modules.<br />
<br />
If you are using LILO and it cannot communicate with the kernel device-mapper driver, you have to run {{ic|modprobe dm-mod}} first.<br />
<br />
=== Copy System.map ===<br />
The System.map file is not required for booting Linux. It is a type of "phone directory" list of functions in a particular build of a kernel. The System.map contains a list of kernel symbols (i.e function names, variable names etc) and their corresponding addresses. This "symbol-name to address mapping" is used by:<br />
<br />
* Some processes like klogd, ksymoops etc<br />
* By OOPS handler when information has to be dumped to the screen during a kernel crash (i.e info like in which function it has crashed).<br />
<br />
Copy System.map to /boot and create symlink<br />
# cp System.map /boot/System.map-YourKernelName<br />
<br />
After completing all steps above, you should have the following 3 files and 1 soft symlink in your /boot directory along with any other previously existing files:<br />
vmlinuz-YourKernelName (Kernel)<br />
initramfs-YourKernelName.img (Ramdisk)<br />
System.map-YourKernelName (System Map)<br />
<br />
== Bootloader configuration ==<br />
<br />
Add an entry for your amazing new kernel in your bootloader's configuration file - see [[GRUB]] or [[LILO]] for examples. Note that if you use LILO, the kernel sources include a script to automate the process:<br />
<br />
$ arch/i386/boot/install.sh<br />
<br />
If you use LILO, remember to type {{ic|lilo}} as root at the prompt to update it.<br />
<br />
== Using the NVIDIA video driver with your custom kernel ==<br />
To use the NVIDIA driver with your new custom kernel, see: [[NVIDIA#Alternate_install:_custom_kernel|Installing the driver for a custom kernel]]. You can also install nvidia drivers from AUR.</div>Llg179https://wiki.archlinux.org/index.php?title=Kernel/Traditional_compilation&diff=188376Kernel/Traditional compilation2012-03-08T23:41:05Z<p>Llg179: /* Configure your kernel */</p>
<hr />
<div>[[Category:Kernel (English)]]<br />
{{i18n|Kernels/Compilation/Traditional}}<br />
<br />
The summary below is helpful for building custom kernels from '''kernel.org sources'''. This method of compiling kernels is the traditional method common to all distros; however, an excellent method of cleanly installing the custom kernel with makepkg and pacman is also included. <br />
<br />
Alternatively, you can use ABS to build and install your kernel; see: [[Kernels#Compilation]]. Using the existing {{Pkg|linux}} PKGBUILD will automate most of the process and will result in a package. However, some Arch users prefer the {{ic|traditional}} way.<br />
<br />
== Fetching source ==<br />
* Fetch the kernel source from {{ic|ftp.xx.kernel.org/pub/linux/kernel/}}, where xx is your country key (e.g. 'us', 'uk', 'de', ... - Check [http://www.kernel.org] for a complete list of mirrors). If you have no ftp gui, you can use {{ic|wget}}. For this example, we will fetch and compile 2.6.32.8; you should need to change only the version to get a different kernel.<br />
For instance:<br />
$ wget -c http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.8.tar.bz2<br />
* It is always a good idea to verify the signature for any downloaded tarball. See [http://kernel.org/signature.html#using-gnupg-to-verify-kernel-signatures kernel.org/signature] for how this works and other details. <br />
<br />
* Copy the kernel source to your build directory, e.g.:<br />
$ cp linux-2.6.32.8.tar.bz2 ~/kernelbuild/<br />
<br />
* Unpack it and enter the source directory:<br />
$ cd ~/kernelbuild<br />
$ tar -xvjf linux-2.6.32.8.tar.bz2<br />
$ cd linux-2.6.32.8<br />
Prepare for compilation by running the following command:<br />
make mrproper<br />
This ensures that the kernel tree is absolutely clean. The kernel team recommends that this command be issued prior to each kernel compilation. Do not rely on the source tree being clean after un-tarring.<br />
<br />
== Build configuration ==<br />
This is the most crucial step in customizing the kernel to reflect your computer's precise specifications. By setting the configurations in 'menuconfig' properly, your kernel and computer will function most efficiently.<br />
<br />
=== Get .config file ===<br />
Optional. Copy the .config file from the running kernel, if you want to modify default Arch settings.<br />
$ zcat /proc/config.gz > .config<br />
<br />
=== Configure your kernel ===<br />
http://www.archlinux.org/news/users-of-unofficial-kernels-must-enable-devtmpfs-support/<br />
<br />
There are two choice:<br />
* Traditional menuconfig<br />
$ make menuconfig (Will start with a fresh '.config'. Option dependencies are usually automatically selected.)<br />
<br />
Make your changes to the kernel and save your config file. It is a good idea to make a backup copy, since you will likely be doing this multiple times until you get all the options right.<br />
<br />
* localmodconfig <br />
Since kernel 2.6.32, localmodconfig is provided to ease kernel configuration:<br />
<br />
$ make oldconfig (Only works with the old '.config' file, copied into the build directory. Also marks previously unused options as 'NEW'.)<br />
$ make localmodconfig (Tries to extract /proc/config.gz from running kernel. Pre-selecting options/modules in use.)<br />
$ make localyesconfig (Same as above, except that as many modules as possible compiled into the kernel.)<br />
$ make xconfig (Depends on Qt. A nicer interface. Dependency checking not verified.)<br />
$ make gconfig (Depends on GTK. Otherwise same as xconfig.)<br />
$ make help (Lists ALL targets available.)<br />
<br />
For more information about the build target "localmodconfig" refer to the [http://kernelnewbies.org/Linux_2_6_32#head-11f54cdac41ad6150ef817fd68597554d9d05a5f 2.6.32 release notes].''<br />
<br />
==== Local version ====<br />
If you are compiling a kernel using your current config file, do not forget to rename your kernel version, or you may replace your existing one by mistake.<br />
<br />
$ make menuconfig<br />
General setup ---><br />
(-ARCH) Local version - append to kernel release '3.n.n-RCn'<br />
<br />
=== What about /usr/src/ ? ===<br />
Using the /usr/src/ directory for kernel compilation as root, along with the creation of the corresponding symlink, is considered poor practice by some kernel hackers. They consider the cleanest method to simply use your home directory. If you subscribe to this point of view, build and configure your kernel as normal user, and install as root, or [[Kernels/Compilation/Arch Build System|with makepkg and pacman]]. <br />
<br />
However, this concept has been the target of debate, and other very experienced hackers consider the practice of compiling as root under /usr/src/ to be completely safe, acceptable and even preferable. <br />
<br />
Use whichever method you feel more comfortable with.<br />
<br />
== Compilation and installation ==<br />
To compile kernel manually, follow these steps:<br />
<br />
=== Compile ===<br />
{{Warning | Do not run {{ic|make all}} if you use GRUB and still have LILO installed; it will configure LILO in the end, and you may no longer be able to boot your machine! Remove LILO (pacman -R lilo) before running {{ic|make all}} if you use GRUB!}}<br />
$ make (Same as make vmlinux && make modules && make bzImage - see 'make help' for more information on this.)<br />
or<br />
$ make -jN (N = # of processors + 1) (This utilizes all CPUs at 100% A Dual-core[-j3] 2.8Ghz compiled in less than 15 minutes.)<br />
<br />
=== Install modules ===<br />
This needs to be done as root.<br />
# make modules_install<br />
<br />
This copies the compiled modules into a directory in /lib/modules named by the kernel version and appended string you set in menuconfig. This way, modules are kept separate from those used by other kernels on your machine.<br />
<br />
=== Copy kernel to /boot directory ===<br />
# cp -v arch/x86/boot/bzImage /boot/vmlinuz-YourKernelName<br />
<br />
=== Make initial RAM disk ===<br />
The initial RAM disk (initrd option in the GRUB menu, or, the file "initramfs-YourKernelName.img") is an initial root file system that is mounted prior to when the real root file system is available. The initrd is bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd as part of the two-stage boot process to load the modules to make the real file systems available and get at the real root file system. The initrd contains a minimal set of directories and executables to achieve this, such as the insmod tool to install kernel modules into the kernel. In the case of desktop or server Linux systems, the initrd is a transient file system. Its lifetime is short, only serving as a bridge to the real root file system. In embedded systems with no mutable storage, the initrd is the permanent root file system.<br />
<br />
If you need any modules loaded in order to mount the root filesystem, build a ramdisk (most users need this). The -k parameter accepts the kernel version and appended string you set in menuconfig and is used to locate the modules in /lib/modules:<br />
<br />
# mkinitcpio -k FullKernelName -g /boot/initramfs-YourKernelName.img<br />
<br />
You are free to name the /boot files anything you want. However, using the [kernel-major-minor-revision] naming scheme helps to keep order if you: Keep multiple kernels/ Use mkinitcpio often/ Build third-party modules.<br />
<br />
If you are using LILO and it cannot communicate with the kernel device-mapper driver, you have to run {{ic|modprobe dm-mod}} first.<br />
<br />
=== Copy System.map ===<br />
The System.map file is not required for booting Linux. It is a type of "phone directory" list of functions in a particular build of a kernel. The System.map contains a list of kernel symbols (i.e function names, variable names etc) and their corresponding addresses. This "symbol-name to address mapping" is used by:<br />
<br />
* Some processes like klogd, ksymoops etc<br />
* By OOPS handler when information has to be dumped to the screen during a kernel crash (i.e info like in which function it has crashed).<br />
<br />
Copy System.map to /boot and create symlink<br />
# cp System.map /boot/System.map-YourKernelName<br />
<br />
After completing all steps above, you should have the following 3 files and 1 soft symlink in your /boot directory along with any other previously existing files:<br />
vmlinuz-YourKernelName (Kernel)<br />
initramfs-YourKernelName.img (Ramdisk)<br />
System.map-YourKernelName (System Map)<br />
<br />
== Bootloader configuration ==<br />
<br />
Add an entry for your amazing new kernel in your bootloader's configuration file - see [[GRUB]] or [[LILO]] for examples. Note that if you use LILO, the kernel sources include a script to automate the process:<br />
<br />
$ arch/i386/boot/install.sh<br />
<br />
If you use LILO, remember to type {{ic|lilo}} as root at the prompt to update it.<br />
<br />
== Using the NVIDIA video driver with your custom kernel ==<br />
To use the NVIDIA driver with your new custom kernel, see: [[NVIDIA#Alternate_install:_custom_kernel|Installing the driver for a custom kernel]]. You can also install nvidia drivers from AUR.</div>Llg179