Sunday, November 16, 2008

Kernel Compiling

Kernel Compiling Chapter 15:

Follow the training videos in the order below and follow along in the blog. Between the two resources this will make doing the labs so much easier. Remember the compiling process for the kernel changes almost monthly. So refer to both sources for how to go about compiling the kernel.

1. DownloadingKernelFedora32Bit.ogg
2. FedoraCompilingKernelRPMSourceSetup.ogg
3. ComilingKernelFedora.ogg

Compiling Problems: Install Development Packages:
Install all of the development packages if you have not already. When you installed Red Hat 8 you were told to install all of the development packages also. In order to compile the kernel you must have the compiling tools installed. These are referred to as the development tools. If you can not compile the kernel then you are probably missing these development packages. You can download these packages from the graphical yum and not at the command line terminal. Select Add and Remove Software menu "I think its called" from the top left most menu on your desktop. It is the last menu option at the bottom. Select it then go to the development section and check all of the program packages in the list. Then select install for the graphical yum to install them. This will take awhile so if you have this problem please do this before class.

Installing the Kernel Source Code:
You should have already of FTPed the source directory from my FTP server. If you have not then you need to down load the kernel and create the symbolic link.

Red Hat Only Way:
su --

cd $HOME

yumdownloader --source kernel

yum install rpmdevtools

rpm -Uhv kernel*rpm

cd /root/rpmbuild/SPECS

yum install xmlto asciidoc

rpmbuild -bp --target $(arch) kernel.spec

cd /root/rpmbuild/BUILD/kernel*

ls

cp -Rfv linux* /usr/src/kernels


For all other distributions of linux not Red Hat. If you are using Centos then do it this way.

Download from www.kernel.org linux 3.0
stable

cd

cd Downloads

su --

cp ./linux-3.*.tar.bz2 /usr/src/kernels

cd /usr/src
/kernels

bunzip2 linux-3.*.tar.bz2

tar xvf linux-3.2.2.tar

cd ..



Do not type yourkernelversion make sure you put in your kernel version number there in its place.
ln -s /usr/src/kernels/linux-yourkernelversion /usr/src/linux

an example of how to do the symbolic link is on page 528.

cd /usr/src/linux

Compiling The Graphical User Interface For The Kernel Custimization:
use the command use the command below in order to build the interface.

yum install gtk+ libglade2-devel glib

make gconfig


You will want to edit the makefile and add the special programming option at the top of the kernel for optimized compiling. We are going to compile at optimization level 4. Note that is an O as in Orange -O4 and not a -04 like 0 1 2 3.

Change:

HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer

HOSTCXXFLAGS = -O2

To:

HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O4 -fomit-frame-pointer

HOSTCXXFLAGS = -O4

Compiling The Kernel:
Once you have edited the makefile and configured the kernel then you are ready to start compiling. You can do all of the compiling commands on a single line in the terminal which will save you a lot of time and headaches.

make clean; make vmlinux; make modules; make modules_install; make;

Moving the Kernel To The Boot Directory:
the generated kernel to the /boot directory and then use the make install command. Page 532 shows in your book covers this step.

yum install mkinitrd

make install

Now edit the GRUB configuration file by hand or you can use Webmin which is much easier to add the new kernel entry for booting. To edit the file by hand look in your book at page 533-535.

Now reboot Linux and see your new entry in the boot loader. Go ahead and select it to see if it runs. If it does not thats ok you are done with this project, but in the real world you would have to go back and reconfigure your kernel until you fixed the problem go back and look at your hardware configuration.


Stoping Your Compile:
If you want to stop your compile you do

ctrl-c

at the terminal. When you want to start up your compile again you run the commands.

make vmlinux; make modules; make modules_install; make;

and then continue on with the rest of the tutorial following those commands from above.


Starting From Scratch Again:
cd /usr/src/kernels

rm -rf YourKernelYouWantToRemove

Example:
rm -rf linux-2.6.32.i686

Now do your cp -Rfv linux* /usr/src/kernels command from above

Fix Configuration Errors:

make CONFIG_DEBUG_SECTION_MISMATCH=y

No comments: