Linux:Kernel:Basic
lastmod 2018-08-17created 2015-02-1315 edits
A summary of how to compile and debug the kernel for analysis, plus basic information.
How to compile
A simple way to compile the kernel.
- First, install an existing Linux distribution.
- Download the kernel source from kernel.org.
- Install the required packages.
-
sudo yum -y install gcc bc perl
-
- Create the configuration file.
- If a previously applied configuration exists, remove it with
make mrproper. - To apply the default configuration, use
make defconfig. - If you use a GUI-environment tool, you can create the configuration file using the ncurses library
-
make menuconfig
-
- For reference,
make localmodconfigcreates a config file selecting only the modules currently in use. <- recommended
- If a previously applied configuration exists, remove it with
- Build.
make1 - Install the modules.
sudo make modules_install - Install the generated kernel image.
sudo make install
Afterwards, check /boot/grub/grub.conf2 and you can see that the compiled kernel version is registered.
Kernel ctags & cscope
The kernel Makefile provides options to generate ctags and cscope, so there is no need to run mkcscope.sh; you can generate them by entering the following. (See the iamroot lecture/tip posts)
If you want absolute paths instead of relative paths, modify the tags file as shown below.
## $KERN_DIR 에 커널소스의 경로를 입력.
$ cat tags | sed -e 's;^\([^!][^\t]*\)\t;\1\t'"$KERN_DIR"'/;' > tags.absolute_path