How to compile kernel in RHEL and CentOS 5?
Here i am compiling Kernel "linux-2.6.36.2" on CentOS 5.3
To create new custom kernel we will follow below steps;
1. Check for essential packages.
2. Find the kernelsource code.
3. Configure the new kernel.
4. Customize the kernel.
5. Build the kernel.
6. Edit entry in "/boot/grub/grub.conf" file.
Steps :
1. Before you start compiling a kernel ckeck following packages are installed or not,
gcc & make
#rpm -qa make gcc
2. You can download latest stable kernel from "Kernel.org", then download and untar "linux-2.6.36.2.tar.bz2" package,
#bunzip2 linux-2.6.36.2.tar.bz2
#tar xvf linux-2.6.36.2.tar
3. Now got to extracted directory of latest kernel
#cd linux-2.6.36.2
4. Copy Kernel source code directory "linux-2.6.36.2"in "/usr/src" directory,
#cp -r linux-2.6.36.2 /usr/src/
5. Go to "/usr/src/linux-2.6.36.2/" and run,
#make menuconfig
Note : Don't get confuse here, 1st i was logged in the server with Putty, but to show you all the thing graphically i switched on GUI.
This will open Linux Kernel configuration window for you to select & load extra modules. Make selection as below, you can choose something different :)
6. Select modules whatever you want, Click "Enter" to go to sub menu, & press "Space" to enable , load & disable modules.
Here i am enabling NTFS file system in Linux, to make it enable do like this,
7. Click on exit button twice to come out up to main menu. Press "Esc" twice to get & save configuration.
8. Now execute "make" command in the same folder as above.
#make
It will start compile your brand new kernel with selected modules.
It will take atleast 15 - 20 mins depending upon your server speed. Till that time you can have coffee, and relex :D
As compilation finishes, either you run this command,
#make modules && make modules_install && make install
Or you can execute it one by one like this,
#make modules
#make modules_install
#make install
9. Once the process is done, you will see new kernel entry in "/boot/grub/grub.conf" file.
Now open it in any editor, and replace below line
defualt=1
with,
defualt=0
10. In new kernel 2.6.35 and above we dont need to make "initrd*.img", it will be made automatically when you run "make install" command.
Now reboot & check kernel version by,
#uname -a
If it's booting from new kernel.
Congrats Compilation Finished !!!
To create new custom kernel we will follow below steps;
1. Check for essential packages.
2. Find the kernelsource code.
3. Configure the new kernel.
4. Customize the kernel.
5. Build the kernel.
6. Edit entry in "/boot/grub/grub.conf" file.
Steps :
1. Before you start compiling a kernel ckeck following packages are installed or not,
gcc & make
#rpm -qa make gcc
2. You can download latest stable kernel from "Kernel.org", then download and untar "linux-2.6.36.2.tar.bz2" package,
#bunzip2 linux-2.6.36.2.tar.bz2
#tar xvf linux-2.6.36.2.tar
3. Now got to extracted directory of latest kernel
#cd linux-2.6.36.2
4. Copy Kernel source code directory "linux-2.6.36.2"in "/usr/src" directory,
#cp -r linux-2.6.36.2 /usr/src/
5. Go to "/usr/src/linux-2.6.36.2/" and run,
#make menuconfig
Note : Don't get confuse here, 1st i was logged in the server with Putty, but to show you all the thing graphically i switched on GUI.
This will open Linux Kernel configuration window for you to select & load extra modules. Make selection as below, you can choose something different :)
6. Select modules whatever you want, Click "Enter" to go to sub menu, & press "Space" to enable , load & disable modules.
Here i am enabling NTFS file system in Linux, to make it enable do like this,
7. Click on exit button twice to come out up to main menu. Press "Esc" twice to get & save configuration.
8. Now execute "make" command in the same folder as above.
#make
It will start compile your brand new kernel with selected modules.
It will take atleast 15 - 20 mins depending upon your server speed. Till that time you can have coffee, and relex :D
As compilation finishes, either you run this command,
#make modules && make modules_install && make install
Or you can execute it one by one like this,
#make modules
#make modules_install
#make install
9. Once the process is done, you will see new kernel entry in "/boot/grub/grub.conf" file.
Now open it in any editor, and replace below line
defualt=1
with,
defualt=0
10. In new kernel 2.6.35 and above we dont need to make "initrd*.img", it will be made automatically when you run "make install" command.
Now reboot & check kernel version by,
#uname -a
If it's booting from new kernel.
Congrats Compilation Finished !!!
Thanks for the post - I found it very helpful!
ReplyDeleteI think step 3 is unnecessary - you don't want to change into the directory before copying it.
You might want to mention that when you do the make you can pass in "-j " where is the number of threads you want to use. I just compiled on a 32 thread machine, and it took less than 3 minutes!
Also, a friend of mine suggested copying your existing kernel config, and then working off that. It's usually in /boot/config- and you copy it to .config in /usr/src//
My previous comment got mangled a bit. Here it is again, fixed:
ReplyDeleteThanks for the post - I found it very helpful!
I think step 3 is unnecessary - you don't want to change into the directory before copying it.
You might want to mention that when you do the make you can pass in "-j NUM" where NUM is the number of threads you want to use. I just compiled on a 32 thread machine, and it took less than 3 minutes!
Also, a friend of mine suggested copying your existing kernel config, and then working off that. It's usually in /boot/config-KERNEL and you copy it to .config in /usr/src/KERNEL/
It's depend on you what and who to follow :)
DeleteHi myself Shraddhesh Rao.I am working as linix admin.I want to do virtualization so how can i go for it?
ReplyDeletehow to learn Virtualization (Xen & VMware ESX Server 4.0)
I have to join classes or Some other...
Please reply my email -ID = shraddhesh07rao@gmail.com