These are my notes of
Linux Device Drivers class at
UCSC Extension. This could be incomplete and can contain errors. Please do your due diligence.
tldr; Steps to build linux kernel
1. Download latest stable source from here.
2. cd /usr/src
3. rm -rf linux
4. tar Jxvf linux-<version>.tar.xz /* note the .xz extension */
5. ln -sf linux-<version> linux
6. cp /boot/.config .
7. make oldconfig
8. make
9. make modules_install
10. make install
11. reboot /* choose kernel during bootup */
Steps 1 to 5 are obvious.
Run
make help to get a quick overview of each make options.
Step 6: One way to compile a kernel is to work off of a config file. An instance of it can be got from
/boot directory, which makes us use the next command
make oldconfig.
Step 7:
make oldconfig takes an existing config and asks input from users for each configuration option finally resulting in new
.config file. Old config file will be saved in
.config.old. Another option (GUI) is to run
make xconfig
Step 8: Using the new
.config file, compile the kernel.
Step 9: Install modules using this command. I noticed that this command is redundant on my system (built 3.13.0 kernel on Ubuntu 12.0.4).
Step 10:
make install
Step 11: reboot the machine and at boot up time, we should get an option to choose which kernel to boot in to.