You are on page 1of 6

Aim: Study of kernel, types of kernel, UNIX/ Linux kernel re-compilation. Theory: What is Kernel?

Kernel of UNIX is the hub of the Operating System. A computer is nothing but a machine, which we can instruct around, so as to achieve lots of things. Kernel is the core OS program which does all the ground and dirty work of instructing different parts of the machine. Most of the programs that we use like Open Office, Gimp, xmms etc (application programs) get its job done by asking Kernel to give certain services. Now, the kernel has to run around, communicate with lot of hardware and some software to get the finished product from these places and get it delivered to the application programs. Kernel Architecture

1) User Space. The User Space is the space in memory where user processes run. This Space is protected. o The system prevents one process from interfering with another process. o Only Kernel processes can access a user process 2) Kernel Space The kernel Space is the space in memory where kernel processes run. The user has access to it only through the system call. 3) System Call User Space and Kernel Space are in different spaces. When a System Call is executed, the arguments to the call are passed from User Space to Kernel Space. A user process becomes a kernel process when it executes a system call.

Kernel Functional Overview 1) 2) 3) 4) 5) File System Process Management Device Driver Memory Management Networking

1. File System The UNIX system has the following types of files: Ordinary File Contain information entered into them by a user. Directory Files Manage the cataloguing of the file system Special Files (devices) Used to access the peripheral devices FIFO Files for Pipes 2. Process Management The Unix OS is a time-sharing system. Every process is scheduled to run for a period of time (time slice). Kernel creates, manages and deletes the processes. Every process (except init) in the system is created as the result of a fork system call. The fork system call splits a process into two processes (Parent and Child). Each process has a unique identifier (Process ID).

3. Device Manager One of the purposes of an OS is to hide the systems hardware from user. Instead of putting code to manage the HW controller into every application, the code is kept in the Linux kernel. It abstracts the handling of devices. All HW devices look like regular files. Types of Devices Character Devices - A character device is one that can be accessed as a stream of bytes. Block Devices - A block device can be accessed only as multiples of a block. Network Devices - They are created by Linux kernel.

4. Memory Management The term memory management refers to the mechanisms implemented by an operating system to provide memory-related services to applications. These services include virtual memory (use of a hard disk or other non-RAM storage media to provide additional program memory), protected memory (exclusive access to a region of memory by a process), and shared memory (cooperative access to a region of memory by multiple processes). Linuxs memory management services are built on a programming foundation that includes a peripheral device called a Memory Management Unit (MMU). An MMU translates physical memory addresses to linear addresses used by the operating system, and requests a page fault interrupt when the CPU tries to access memory that it is not entitled to.

5. Networking

Types of Kernel
There are four popular categories or kinds of Kernels namely monolithic kernels, micro kernels, hybrid kernels and Exokernels. Monolithic kernels are part of Unixlike operating systems like Linux, FreeBSD etc. These types of kernels consist of the core functions of the operating system and the device drivers with the ability to load modules at runtime. Micro kernels are part of the operating systems like AIX, BeOS, Hurd, Mach, Mac OS X, MINIX and QNX. Etc. These types of kernels normally provide only the minimal services such as defining memory address spaces, Inter-process

communication (IPC) and the process management. The other functions such as running the hardware processes are not handled directly by micro kernels. Hybrid kernels are part of the operating systems such as Microsoft Windows NT, 2000 and XP. Dragonfly BSD etc. These types of kernels are extensions of micro kernels with some properties of monolithic kernels. Unlike monolithic kernels, these types of kernels are unable to load modules at runtime on their own. Exokernels are evolving and still under experimental stage in development of an operating system that could incorporate multiple library operating systems and are intended to simultaneously run multiple operating systems of different kinds like Linux and Microsoft Windows together using appropriate Application Programming Interface (API).

Kernel Re-compilation
Need For Kernel Re-compilation 1. 2. 3. 4. Reduce the size of the kernel Activation and deactivation of support for devices. More up-to-date version of the kernel. Advantage of new features, bug fixes or security fixes before your vendor responds.

How to Recompile Kernel? I- Download the kernel source code /usr/src/ is the preferred location, however, you can untar and install wherever you want, for other distros like Red Hat, you can directly install in /usr/src/linux) # cd /usr/src #wget http://ftp.ntu.edu.tw/linux/kernel/v3.0/linux-3.0.4.tar.gz #tar -xzvf linux-3.0.4.tar.gz At this point, weve downloaded and uncompressed the source code, the next step is to remove the symbolic link to the old kernel and create a new one pointing to the kernel weve just downloaded: #rm linux #ln -s linux-3.0.4 linux II- Configuration: #cd linux #cp /boot/config .config #make oldconfig Configuration can be done in three ways:

make menuconfig (command line)

make xconfig (X Window based graphical environment) make config (this is a yes/no based process and ites very tedious, dont choose unless youve lost a bet or something)

III- Installation: # make bzImage This will compile the kernel, and place it as a compressed file under arch/i386/boot then to compile the modules and install them: #make modules #make modules_install This will copy the modules in /lib/modules/ . #cp arch/i386/boot/bzImage /boot/vmlinuz-3.0.4 #cp System.map /boot/System.map-3.0.4 Delete the link to the old System.map: #rm /boot/System.map Make a symbolic link for that specific kernel: #ln -s /boot/System.map-3.0.4 /boot/System.map At this point were done; still we should make an entry for that new kernel in lilo. Open the file /etc/lilo.conf youll find the old entry, use it as template for the new one for example the old entry looked like this image = /boot/vmlinuz root = /dev/sda2 label = Linux read-only The new one would look like this image = /boot/vmlinuz-3.0.4 root = /dev/sda2 label = CustomKernel read-only Save and close, run: #lilo

Conclusion:

You might also like