_debug_compile
Preaparing the build environment:
In order to create the file system environment we need to run the following command where we want to build the kernel (If missing, install package rpmdevtools):
#
/usr/bin/rpmdev-setuptree
Now, We are having the rpmbuild directory which contain the following directories : BUILD, RPMS, SOURCES, SPECS and SRPMS.
Note: the rpmdevtools was changed between fedora 9 and 10, in 9 we had to call fedora-buildrpmtree.
Other note: Some of the operations required root permissions, you can run it
as root or use "su", just remember that the rpmbuild directory is expected in the current user home directory and pay attention to the directory permission.
To set the build in a specific path (e.g. ~/rpmbuild) add the following to the ~/.rpmmacros file:
%_topdir %(echo $HOME)/rpmbuild #path to your custom
build dir
Download and install the kernel source:
Now, we should downoad the kernel source from
http://kojipkgs.fedoraproject.org/packages/kernel, since my kernel version is 2.6.27.9-159.fc10.i686 I will download the file
kernel-2.6.27.9-159.fc10.src.rpm
After the download completed, extract the rpm by typing (you can ignore the "
warning: group mockbuild does not exist - using root" messages):
#
rpm -ivh kernel-2.6.27.9-159.fc10.src.rpm
Preparing the build (in my case, for i686):
#
cd rpmbuild/SPECS
#
rpmbuild -bp --target=i686 kernel.spec
Building the kernel rpm:
Note: For this sample, I will build the kernel without any configuration changes.
Go to the build directory and start the rpm build.
#
cd rpmbuild/BUILD/kernel-2.6.27/linux-2.6.27.i686
#
make rpm
This is going to take some time .....
Creating the ram disk:
initrd image creation:
Since the mkinitrd function searching the built modules under
/lib/modules/, I created a soft link from there to the place we have built the modules
(there must be more elegant way ...)
#
cd /lib/modules/
#
ln -s <build path>/rpmbuild/BUILDROOT/kernel-2.6.27.9-1.i386/lib/modules/2.6.27.9 2.6.27.9
#cd <build path>/rpmbuild/BUILDROOT/kernel-.6.27.9-1.i386/boot
#mkinitrd /boot/initrd-2.6.27.9.img 2.6.27.9
Installing the new kernel:
Now, We need to copy the generated files from the <build path>rpmbuild/BUILDROOT/kernel-2.6.27.9-1.i386/boot
directory to the /boot directory in the target machine:
initrd-2.6.27.9.img,System.map-2.6.27.9,vmlinuz-2.6.27.9,config-2.6.27.9
In the /etc/grub.conf file we need to add an entry for the new kernel:
title myBuild (2.6.27.9)
root (hd0,0)
kernel /boot/ofer/vmlinuz-2.6.27.9 ro root=UUID=<your uuid> rhgb quiet
initrd /boot/ofer/initrd-2.6.27.9.img
Reboot the machine, choose the new kernel in the grub screen, and that it :-)