Kernel

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Ex.No.

08 10/10/12

KERNEL CONFIGURATION, COMPILATION AND INSTALLATION

____________________________________________________________________
1.Objective: (1)To configure, compile and install Linux kernel from source. (2)To access the source code of kernel. 2.DESCRIPTION: KERNEL: The kernel is the main component of computer operating systems.it acts as a bridge between applications and the actual data processing done by the hardware level. The kernel manages the system resources.The kernel provides the lowest level abstraction layer for the resources that application software must control to perform its function. The kernel interacts with application processes through interprocess communincation mechanisms and system calls. LINUX KERNEL: The linux kernel is used in unix like operating systems.Its a free open source software.It supports preemptive multitasking,virtual memory,shared libraries,demand loading,shared copy-on-write executables,memory management and threading. Linux is a monolithic kernel.Device drivers and kernel extensions are in kernel space with access to the hardware.The graphics system does not run in the kernel. BUILDING A KERNEL FROM THE SOURCE: The following packages need to be installed. 1)rpm devtools 2)yum utils ->To install the above mentioned packages execute the following command: Su c yum install rpmdevtools yum-utils ->The following additional packages are installed inorder to use make xconfig ->qt 3-devd ->libxi devd Execute the command: su c yum install qt3-devd libxi-devd Prepare a rpm package building environment in your home directory. Run the following command:rpmdev-setuptree Download the kernel-<version>.src.rpm file.Enable the appropriate source repositories with the enablerepo switch Yumdownloader source kernel Install build dependencies for the kernel source with the yum-budddep command. Su c yum-builddep kernel--<version>.src.rpm Install kernel--<version>.src.rpm with the following command: Rpm Uvh kernel-<version>.src.rpm Prepare the kernel source tree using the following commands: Cd ~/rpbuild/SPECS Rpmbuild bp target=$(uname m)kernel.spec Copy the source tree to persue the original tree while making changes to the copy Cp r ~/rpmbuild/BUILD/kernel-2.6.$ver.$fedver/linux-2.6.$ver.$arch ~/rpmbuild/ BUILD/kernel2.6.$ver.$fedver.orig Cp al ~/rpmbuild/ BUILD/kernel-2.6.$ver.$fedver.orig ~/rpmbuild/ BUILD/kernel-2.6.$ver. $fedver.new After the .new source tree is modified to generate a patch.To generate the patch,run different against the entire .new and .orig source trees with the following command: Cd ~/rpmbuild/BUILD Diff uvrp kernel-2.6.$ver.$fedver.orig kernel-2.6.$ver.$fedver.new>../SOURCES/linux-2.6-mynew-patch.patch

Configure kernel: ->Change to the kernel source tree directory Cd ~/rpmbuild/BUILD/kernel-2.6.$ver/linux-2.6$ver.$arch/ ->Select the desired configuration file from Cd ~/rpmbuild/BUILD/kernel-2.6.$ver/linux-2.6$ver.$arch/configs. ->Copy the desired config file to Cd ~/rpmbuild/BUILD/kernel-2.6.$ver/linux-2.6$ver.$arch/config Cp configs/<desired-config-file>.config ->Run the following command: Make oldconfig ->Run the following command,selecting and saving the desired kernel options from the text-based UI Make menuconfig For a graphical UI, Make xconfig ->Add a new line to the top of the of the config file that contains the hardware platform the kernel is built for #x86_64 ->Copy the config file to ~/rpmbuild/SOURCES/cp.config ~/rpmbuild/SOURCES/config-uname-m.

Prepare build files ->Change to the ~/rpmbuild/SPECS directory: Cd ~/rpmbuild/SPECS ->Open the kernel.spec file for editing ->Give the kernel a unique name.This is important to ensure the custom kernel is not confused with any released kernel. ->Change #%define buildid.local to %define buildid.<custom_text> ->Add the generated patch to the kernel.spec file. Build the new kernel ->Use the rpmbuild utility to build the new kernel: Rpmbuild bb target=uname mkernel.spec Install the new kernel To install the new kernel,use the rpm ivh command, Su-c rpm ivh force $HOME/rpmbuild/RPMS/<arch>/kernel-<version>.<arch>.rpm The kernel will now be installed in /boot,create a new initramfs to bootstrap your kernel and add the new kernel to your glub bootloader menu.lst The new kernel takes control after reboot.

BENEFITS OF BUILDING A CUSTOM KERNEL: The generic kernel usually supports a wide range of hardware whereas a custom kernel can be built to support the particular computers hardware. FASTER BOOT TIME: Since the kernel will only probe the hardware on the system,the time it takes your system to boot can decrease dramatically. LOWER MEMORY USAGE: A custom kernel often uses less memory than the generic kernel by omitting unused features and device drivers.The kernel code remains resident in physical memory at all times,preventing that memory from being used by applications.The custom kernel is especially useful on a sysem with a small amount of RAM. ADDITIONAL HARDWARE SUPPORT: A custom kernel allows you to add in support for devices which are not present in the GENERIC kernel,such as sound cards.

3.Procedure: 3.1 To ensure that all tools required for compiling the kernel are installed: Type the following commands in terminal and type the password for root user, when prompted. [fosslab@fosslab~]$ su Password: [root@ fosslab fosslab]# rpm -qa kernel-devel kernel-devel-2.6.35.6-45.fc14.1686 Type the following command to get name and information about current kernel [root@ fosslab fosslab]# uname -r 2.6.35.6-45.fc14.i686 3.2 To Download the latest kernel source from kernel.org: http://www.kernel.org/pub/linux/kernel/v3.0/linux-2.6.35.7.tar.bz2 3.3 To move the downloaded kernel source to /usr/src: [root@ fosslab fosslab]# cd Downloads [root@fosslab Downloads]# mv linux-2.6.35.7.tar.bz2 /usr/src/ 3.4 To extract the tar file to the location /usr/src/: [root@fosslab Downloads]# cd /usr/src [root@fosslab src]# tar -xjvf linux-2.6.35.7.tar.bz2 [root@fosslab src]# cd linux-2.6.35.7 [root@fosslab linux-2.6.35.7]# 3.5 To create a symlinks to the kernel tree: [root@fosslab linux-2.6.35.7]# ln -s /usr/src/linux-3.0 /usr/src/linux 3.6 To Clean out all previous configurations and reset the source directory [root@fosslab linux-2.6.35.7]# make mrproper A file system is the formatting structure used on a (disk)partition. It is important to build support for the file systems in the kernel (and not as a module) as otherwise the kernel will need file system support to mount the file system in cases where the kernel modules are installed. 3.7 To configure the kernel with NTFS write support: [root@fosslab linux-2.6.35.7]# make menuconfig 3.8 Save and exit the tool. 3.9 To build the kernel: [root@fosslab linux-2.6.35.7]# make clean [root@fosslab linux-2.6.35.7]# make Once the compilation is completed , Install the kernel and its modules. [root@fosslab linux-2.6.35.7]# make modules_install [root@fosslab linux-2.6.35.7]# make install The newly created kernel will be in /boot 3.10 To check that the install process has configured the boot loader to point to the new kernel: [root@fosslab linux-2.6.35.7]# vi /boot/grub/menu.lst The new kernel will have an entry at the top of the kernel list. It can be identified by the kernel version number. Change the line containing timeout to the value -1and comment out the hiddenmenu entry. default=0 timeout=-1 #hiddenmenu Now reboot the computer and the computer will boot into the new kernel 4.Conclusion: The following operations were carried out: Downloading the kernel code from www.kernel.org

The downloaded kernel code was studied and various modules were examined. Finally Linux kernel was installed using the Linux code Base.

You might also like