2016-11-07

Brought installation steps up-to-date as of the Linux 4.8 kernel. If I missed anything or screwed something up, please correct it. :)

← Older revision

Revision as of 21:07, 7 November 2016

Line 31:

Line 31:

{{Note| It is a good idea to verify the PGP signature of any downloaded kernel tarball. This ensures that it is legitimate and helps to build the Web of Trust. See [http://kernel.org/signature.html#using-gnupg-to-verify-kernel-signatures kernel.org/signature].}}

{{Note| It is a good idea to verify the PGP signature of any downloaded kernel tarball. This ensures that it is legitimate and helps to build the Web of Trust. See [http://kernel.org/signature.html#using-gnupg-to-verify-kernel-signatures kernel.org/signature].}}



In the following command-line example, {{Pkg|wget}} has been installed and is used inside the {{ic|~/kernelbuild}} directory to obtain kernel 4.
7
.
2
:

+

In the following command-line example, {{Pkg|wget}} has been installed and is used inside the {{ic|~/kernelbuild}} directory to obtain kernel 4.
8
.
6
:

$ cd ~/kernelbuild

$ cd ~/kernelbuild



$ wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.
7
.
2
.tar.xz

+

$ wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.
8
.
6
.tar.xz

If {{ic|wget}} was not used inside the build directory, it will be necessary to move the tarball into it, e.g.

If {{ic|wget}} was not used inside the build directory, it will be necessary to move the tarball into it, e.g.



$ mv /path/to/linux-4.
7
.
2
.tar.xz ~/kernelbuild/

+

$ mv /path/to/linux-4.
8
.
6
.tar.xz ~/kernelbuild/

=== Unpack the kernel source ===

=== Unpack the kernel source ===

Line 44:

Line 44:

Within the build directory, unpack the kernel tarball:

Within the build directory, unpack the kernel tarball:



$ tar -xvJf linux-4.
7
.
2
.tar.xz

+

$ tar -xvJf linux-4.
8
.
6
.tar.xz

To finalise the preparation, ensure that the kernel tree is absolutely clean; do not rely on the source tree being clean after unpacking. To do so, first change into the new kernel source directory created, and then run the {{ic|make mrproper}} command:

To finalise the preparation, ensure that the kernel tree is absolutely clean; do not rely on the source tree being clean after unpacking. To do so, first change into the new kernel source directory created, and then run the {{ic|make mrproper}} command:



$ cd linux-4.
7
.
2
/

+

$ cd linux-4.
8
.
6
/

$ make clean && make mrproper

$ make clean && make mrproper

Line 128:

Line 128:

# make modules_install

# make modules_install



This will copy the compiled modules into {{ic|/lib/modules/<kernel version>-<config local version>}}. For example, for kernel version
3
.
18
installed above, they would be copied to {{ic|/lib/modules/
3
.
18
.
28
-ARCH}}. This keeps the modules for individual kernels used separated.

+

This will copy the compiled modules into {{ic|/lib/modules/<kernel version>-<config local version>}}. For example, for kernel version
4
.
8
installed above, they would be copied to {{ic|/lib/modules/
4
.
8
.
6
-ARCH}}. This keeps the modules for individual kernels used separated.



{{Tip|If your system requires modules which are not distributed with the regular Linux kernel, you need to compile them for your custom kernel when it is finished. Such modules are typically those which you explicitly installed
seperately
for your running system. See [[NVIDIA#Custom kernel]] for an example.}}

+

{{Tip|If your system requires modules which are not distributed with the regular Linux kernel, you need to compile them for your custom kernel when it is finished. Such modules are typically those which you explicitly installed
separately
for your running system. See [[NVIDIA#Custom kernel]] for an example.}}

=== Copy the kernel to /boot directory ===

=== Copy the kernel to /boot directory ===

{{Note|Ensure that the {{ic|bzImage}} kernel file has been copied from the appropriate directory for your system architecture. See below.}}

{{Note|Ensure that the {{ic|bzImage}} kernel file has been copied from the appropriate directory for your system architecture. See below.}}



The kernel compilation process will generate a compressed {{ic|bzImage}} (big zImage) of that kernel, which must be copied to the {{ic|/boot}} directory and renamed in the process. Provided the name is prefixed with {{ic|vmlinuz-}}, you may name the kernel as you wish. In the examples below, the installed and compiled
3
.
18
kernel has been copied over and renamed to {{ic|vmlinuz-
linux318
}}:

+

The kernel compilation process will generate a compressed {{ic|bzImage}} (big zImage) of that kernel, which must be copied to the {{ic|/boot}} directory and renamed in the process. Provided the name is prefixed with {{ic|vmlinuz-}}, you may name the kernel as you wish. In the examples below, the installed and compiled
4
.
8
kernel has been copied over and renamed to {{ic|vmlinuz-
linux48
}}:

* 32-bit (i686) kernel:

* 32-bit (i686) kernel:



# cp -v arch/x86/boot/bzImage /boot/vmlinuz-
linux318

+

# cp -v arch/x86/boot/bzImage /boot/vmlinuz-
linux48

* 64-bit (x86_64) kernel:

* 64-bit (x86_64) kernel:



# cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-
linux318

+

# cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-
linux48

=== Make initial RAM disk ===

=== Make initial RAM disk ===



{{Note|You are free to name the initramfs image file whatever you wish when generating it. However, it is recommended to use the {{ic|linux<major revision><minor revision>}} convention. For example, the name '
linux318
' was given as '
3
' is the major revision and '
18
' is the minor revision of the
3
.
18
kernel. This convention will make it easier to maintain multiple kernels, regularly use mkinitcpio, and build third-party modules.}}

+

{{Note|You are free to name the initramfs image file whatever you wish when generating it. However, it is recommended to use the {{ic|linux<major revision><minor revision>}} convention. For example, the name '
linux48
' was given as '
4
' is the major revision and '
8
' is the minor revision of the
4
.
8
kernel. This convention will make it easier to maintain multiple kernels, regularly use mkinitcpio, and build third-party modules.}}

{{Tip|If you are using the LILO bootloader and it cannot communicate with the kernel device-mapper driver, you have to run {{ic|modprobe dm-mod}} first.}}

{{Tip|If you are using the LILO bootloader and it cannot communicate with the kernel device-mapper driver, you have to run {{ic|modprobe dm-mod}} first.}}

Line 151:

Line 151:

==== Automated preset method ====

==== Automated preset method ====



An existing [[Mkinitcpio#Image_creation_and_activation|mkinitcpio preset]] can be copied and modified so that the custom kernel initramfs images can be generated in the same way as for an official kernel. This is useful where intending to recompile the kernel (e.g. where updated). In the example below, the preset file for the stock Arch kernel will be copied and modified for kernel
3
.
18
, installed above.

+

An existing [[Mkinitcpio#Image_creation_and_activation|mkinitcpio preset]] can be copied and modified so that the custom kernel initramfs images can be generated in the same way as for an official kernel. This is useful where intending to recompile the kernel (e.g. where updated). In the example below, the preset file for the stock Arch kernel will be copied and modified for kernel
4
.
8
, installed above.



First, copy the existing preset file, renaming it to match the name of the custom kernel specified as a suffix to {{ic|/boot/vmlinuz-}} when copying the {{ic|bzImage}} (in this case, {{ic|
linux318
}}):

+

First, copy the existing preset file, renaming it to match the name of the custom kernel specified as a suffix to {{ic|/boot/vmlinuz-}} when copying the {{ic|bzImage}} (in this case, {{ic|
linux48
}}):



# cp /etc/mkinitcpio.d/linux.preset /etc/mkinitcpio.d/
linux318
.preset

+

# cp /etc/mkinitcpio.d/linux.preset /etc/mkinitcpio.d/
linux48
.preset

Second, edit the file and amend for the custom kernel. Note (again) that the {{ic|ALL_kver<nowiki>=</nowiki>}} parameter also matches the name of the custom kernel specified when copying the {{ic|bzImage}}:

Second, edit the file and amend for the custom kernel. Note (again) that the {{ic|ALL_kver<nowiki>=</nowiki>}} parameter also matches the name of the custom kernel specified when copying the {{ic|bzImage}}:



{{hc|/etc/mkinitcpio.d/
linux318
.preset|

+

{{hc|/etc/mkinitcpio.d/
linux48
.preset|

...

...



ALL_kver<nowiki>=</nowiki>"/boot/vmlinuz-
linux318
"

+

ALL_kver<nowiki>=</nowiki>"/boot/vmlinuz-
linux48
"

...

...



default_image<nowiki>=</nowiki>"/boot/initramfs-
linux318
.img"

+

default_image<nowiki>=</nowiki>"/boot/initramfs-
linux48
.img"

...

...



fallback_image<nowiki>=</nowiki>"/boot/initramfs-
linux318
-fallback.img"}}

+

fallback_image<nowiki>=</nowiki>"/boot/initramfs-
linux48
-fallback.img"}}

Finally, generate the initramfs images for the custom kernel in the same way as for an official kernel:

Finally, generate the initramfs images for the custom kernel in the same way as for an official kernel:



# mkinitcpio -p
linux318

+

# mkinitcpio -p
linux48

==== Manual method ====

==== Manual method ====

Line 179:

Line 179:

* {{ic|-g}} (--generate <filename>): Specifies the name of the initramfs file to generate in the {{ic|/boot}} directory. Again, using the naming convention mentioned above is recommended.

* {{ic|-g}} (--generate <filename>): Specifies the name of the initramfs file to generate in the {{ic|/boot}} directory. Again, using the naming convention mentioned above is recommended.



For example, the command for the
3
.
18
custom kernel installed above would be:

+

For example, the command for the
4
.
8
custom kernel installed above would be:



# mkinitcpio -k linux-
3
.
18
.
28
-g /boot/initramfs-
linux318
.img

+

# mkinitcpio -k linux-
4
.
8
.
6
-g /boot/initramfs-
linux48
.img

=== Copy System.map ===

=== Copy System.map ===

Show more