Pages

Tuesday, March 25, 2014

Compile kernel source rpm and biuild with .spec file

Here we are recompiling source rpm with latest linux kernel(kernel.org)
(1) Download the source rpm
http://repo.smartservermanagement.com/el6/x86_64/kernel-xen-3.4.58-1.src.rpm
(2) Installed the source RPM
#rpm -ivh kernel-xen-3.4.58-1.src.rpm
This wil create rpbnild folder under /root

cd /root/rpmbuild/SPECS/
vi kernel-xen.spec
(Changed .58 to 80))
(3)Downloaded the kernel source from kernel.org(3.4.80) to /root/rpmbuild/SOURCES/
cd /root/rpmbuild/SPECS
(4)Replace the version in the spec file. Here the change is from .58 to .80
(5)Build the rpm using the .spc file as follows.
[root@test SPECS]# rpmbuild -ba kernel-xen.spec
The rpms will be available here(/root/rpmbuild/RPMS)
------------------------------------
[root@test rpmbuild]# ls RPMS/x86_64/
kernel-xen-3.4.80-1.x86_64.rpm kernel-xen-devel-3.4.80-1.x86_64.rpm kernel-xen-firmware-3.4.80-1.x86_64.rpm kernel-xen-headers-3.4.80-1.x86_64.rpm
[root@test rpmbuild]#
-------------------------------------
You can install the rpm using yum/rpm. here is the sample grub.conf after the installation.
[root@test ~]# cat /etc/grub.conf 
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd1,0)
# kernel /boot/vmlinuz-version ro root=/dev/sdb1
# initrd /boot/initrd-[generic-]version.img
#boot=/dev/sdc
default=0
timeout=5
splashimage=(hd1,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.4.80-1.el6xen.x86_64)
root (hd1,0)
kernel /boot/vmlinuz-3.4.80-1.el6xen.x86_64 ro root=UUID=2e3c5488-2950-4143-ad6c-b522fc689685 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /boot/initramfs-3.4.80-1.el6xen.x86_64.img
title CentOS (2.6.32-431.5.1.el6.x86_64)
[root@test ~]# uname -r
3.4.80-1.el6xen.x86_64
[root@test ~]#s

0 comments:

Post a Comment