Computer Science
Algorithm
Data Processing
Digital Life
Distributed System
Distributed System Infrastructure
Machine Learning
Operating System
Android
Linux
Compile And Install Kernel (2012)
Tizen
Windows
iOS
Programming Language
C++
Erlang
Go
Scala
Scheme
Type System
Software Engineering
Storage
UI
Flutter
Javascript
Virtualization
Life
Life in Guangzhou (2013)
Recent Works (2013)
东京之旅 (2014)
My 2017 Year in Review (2018)
My 2020 in Review (2021)
十三年前被隔离的经历 (2022)
A Travel to Montreal (2022)
My 2022 in Review (2023)
Travel Back to China (2024)
Projects
Bard
Blog
RSS Brain
Scala2grpc
Comment Everywhere (2013)
Fetch Popular Erlang Modules by Coffee Script (2013)
Psychology
耶鲁大学心理学导论 (2012)
Thoughts
Chinese
English

Compile And Install Kernel

Posted on 27 Nov 2012, tagged linuxkernel

There are already many documents to teach one how to compile and install kernel. Here are just some key notes. Use make help under source directory for details.

0. Kernel configure

It is happy to have a kernel git repo. Using git tag to see the kernel versions and use git checkout <tag> to checkout the specified version, such as:

git checkout v3.7-rc6

It is recommended to use the distribution’s kernel configure file as a basic configure when you compile the kernel for the first time. Copy it from /boot to <build_dir>/.config. Use this command to modify it:

make O=<build_dir> menuconfig

It will save the new configure and rename the old configure with .config.old.

1. Kernel image

Kernel image is the most important part. Use this command to compile kernel in <build_dir>:

make O=<build_dir> -j4

After that, Copy vmlinux and System.map to /boot. And then configure the boot loader. Or use the command installkernel if you have it.

2. Kernel modules

Some code are compiled to kernel modules. It need to be installed to the system. Use this command to install kernel modules and firmwares:

make O=<build_dir> modules_install

It installs kernel modules under /usr/lib/modules/<kernel_version>. You can also specify the output directory using INSTALL_MOD_PATH:

make O=<build_dir> INSTALL_MOD_PATH=<module_dir> modules_install

The INSTALL_MOD_PATH is / by default.

3. Linux headers

Linux headers are some header files to invoked by user space programs. Using this command to output it:

make O=<build_dir> INSTALL_HDR_PATH=<headers_dir> headers_install

It installs headers to <headers_dir>. You should copy them into /usr/include.

Another way

After all, you may want to make a kernel package to install on other machines. Such as:

make O=<build_dir> -j4 binrpm-pkg