sobota, 10 stycznia 2015

Compile kernel on CentOs 7 (should be very similar on RedHat and Fedora)

For me the reason why I decided to compile kernel was that in work I am testing software that is not included in default release.

Steps required to compile your own kernel:
Download kernel from https://www.kernel.org/.

Extract kernel by command tar -xvzf archive_name

Copy configuration file to location where you have extracted kernel:
cp /boot/config-3.10.0-123.el7.x86_64 your_extracted_archive_location


Prerequisites (install packages required):
yum groupinstall "Development Tools"
yum install bc.x86_64
yum install ncurses-devel

Configure what you want to be compiled to your new kernel:
- make menuconfig (choose option load file that you took earlier from /boot/config*, make modifications, choose save )
- make bzImage -j your_number_here (-j stands for the number of jobs (commands) to run simultaneously, I usually set one job per one core of processor)
- make modules -j your_number_here
- make modules_install -j your_number_here
- make install

The reason why I decided to choose configuration file from /boot/config* is that to do it manually properly would take much time, there is also less chance that I will make an error which will make machine to be unable boot. It is much easier and faster to edit existing proper configuration file.

Make install does all the magic, modifies grub but does not set new kernel as default.

In order to use compiled kernel during next boot modify file /etc/default/grub.
[root@localhost ~]# cat /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
#GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="vconsole.keymap=pl2 crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"


As you can see I've added GRUB_DEFAULT=0 and commented out "#GRUB_DEFAULT=saved".

I have read some articles that compiling kernel does not necessarily make Linux work faster but I have this strange filling that it does (even login via ssh takes less time).

A proof that it went through successfully:
[root@localhost ~]# uname -r
3.18.0-rc1


Brak komentarzy:

Prześlij komentarz