— This is old article I wrote on my old Nest —
Recently I was doing some linux kernel compilation for a course homework. I did it manually. Someone said it’s so complicated so I will share my guide for linux kernel compilation. Here I use the most recent kernel version as October 9th, 2012. The version is 3.6.1. All operations are performed on Ubuntu distribution.
Check for your current linux kernel version. You can do it by typing this on your terminal.
Now download the latest kernel at http://kernel.org/ website. In this tutorial we would use kernel version 3.6.1.
The reason I used linux-3.6.1.tar.xz instead of linux-3.6.1.tar.gz or linux-3.6.1.tar.bz2 is simply because of download size.We will following a convention or common practice of kernel building so we will use /usr/src directory. Make sure you move the source to /usr/src/ directory. Do that using root access.
Now extract the source code.
tar -Jxf linux-3.6.1.tar.xz cd linux-3.6.1
In linux-3.6.1 folder there would be some files and folders. Some of them used as special purpose as:
arch – describe all architecture support by kernel
crypto – contain cryptographic implementation like AES, DES
drivers – all drivers modules (ID, SCSI, Ethernet device, Wireless)
fs – all filesystem implementation (ext4, FAT, NTFS)
net – all network protocol implementation (IPv4, IPv6, tcp, 802.11)
Now let’s configure our kernel source. The kernel compilation need a configuration file that contain lots of variable to help to understand what modules we need to compile. Specific kernel variable can be found at kernel.org
We can take the old configuration as our basis for creating configuration file.
cp /boot/config-188.8.131.52-generic .config
Note that I use kernel 184.108.40.206-generic so I copy the configuration file. It can be different in your system so match the version number with your current kernel version.
It’s a wise way to see what we can do by invoking make. A little help could give us hint.
Now, to configure the config file, invoke
After deciding what configuration you choose, It’s time for compilation. We will using generic way of compilation. It is the standard way provided by kernel and not platform oriented.
To compile the kernel and its modules we can invoke:
The process could be 1 to 4 hours depending on your system performance. For old machine like mine, it could be around 4 hours to do so. In this step the compiled kernel is stored in binary form as arc/x86/boot/bzImage file. Based on kernel headers it will compile the kernel modules (device driver, filesystem, network, etc) and generate .ko files which are kernel objects. These modules also called Loadable Kernel Modules (LKM).
Next, we will install kernel modules. to do so we can invoke.
This step will copy all kernel modules (*.ko) to /lib/modules/<version>/kernel/ folder.
Next we will install the kernel itself. We did that by invoking.
This step copy the arch/x86/boot/bzImage to /boot folder and copy the .config to /boot/config-<latest version> and generate System.map file.
Next we need to create initramfs file. What is iniramfs? You can find out here.
update-initramfs -c -k <version>
Here <version> can be 3.6.1 for this case.
Next we have to update the boot loader. I’m using GRUB so we have to invoke:
This command automatically probe the kernels in /boot folder and add the entries in configuration file, grub.cfg
Restart the system and look at your bootloader entry. choose the new kernel in bootloader. Now open terminal and invoke.
The kernel version should be 3.6.1 now.kernel, linux