What is a Kernel The kernel of any

  • Slides: 16
Download presentation
What is a Kernel • The kernel of any operating system is the core

What is a Kernel • The kernel of any operating system is the core of all the system’s software. The only thing more fundamental than the kernel is the hardware. • The kernel has many jobs. The essence of its job is to provide a running environment for application software. The environment has to handle issues such as networking, disk access, virtual memory and multitasking. • Although the kernel is a small part of the complete linux system, it is by far the most critical element. If the kernel fails, the rest of system goes with it. 1

Linux Kernel • The kernel is responsible for: – CPU resource scheduling – Process

Linux Kernel • The kernel is responsible for: – CPU resource scheduling – Process management – Signals and semaphores – Virtual memory (swapping, paging, and mapping) – Filesystem – Interprocess communication 2

Kernel • The SA is able to directly customize a kernel. Some of the

Kernel • The SA is able to directly customize a kernel. Some of the reasons for doing this might be: – The system hardware has been modified by adding devices, memory and processors etc. – Memory usage needs to be optimized – The speed and performance of the system may need improvement • The actual kernel size varies from machine to machine, depending on what features are compiled onto it, what modifications you have made to the kernel data structures and what additions you have made to the code. 3

Example of Some Sample Tunable Kernel Parameters • /etc/sysctl. conf 4

Example of Some Sample Tunable Kernel Parameters • /etc/sysctl. conf 4

Finding and unpacking the kernel source code • The distribution of Linux should have

Finding and unpacking the kernel source code • The distribution of Linux should have the source code to that specific kernel. Otherwise, the source code can be obtained from the vendor. • Traditionally, the kernel source is located at /usr/src. Before you unpack a new source tree, you should always save and rename the current one. In /usr/src, there should be a directory named linux, which contains the current source tree. Most distributions do not install the entire source tree by default. Only the necessary files for development are installed. The safest path to upgrading is to rename the existing tree with a suffix indicating its associated version number. 5

The UNIX Architecture Interactive User Application … Programs OS System Call Interface Commands Device

The UNIX Architecture Interactive User Application … Programs OS System Call Interface Commands Device Driver … Device Driver Interface Libraries Trap Table Monolithic Kernel Module • Process Management • Memory Management • File Management • Device Mgmt Infrastructure 6

Building the Kernel • Building the kernel allows the user to thin down the

Building the Kernel • Building the kernel allows the user to thin down the feature list so that UNIX can run on less-powerful systems, with the same performance. • Building the kernel requires configuring and compiling. If you have windows running, this process would be simpler, because it can be menu driven. 7

Modules • When configuring, there is a choice of making modules. As a systems

Modules • When configuring, there is a choice of making modules. As a systems administrator, there are situations where a kernel feature is necessary for a short period of time. • With the module system, it allows parts of the kernel, called modules, to be dynamically loaded and unloaded from the kernel as needed. Features often not used can thus be enabled but won’t waste memory when they aren’t being used. The kernel automatically determines what to load and when. 8

Prerequisites • linux-source (latest release of Ubuntu kernel code) • build-essential (packages required to

Prerequisites • linux-source (latest release of Ubuntu kernel code) • build-essential (packages required to compile the code) • fakeroot (kernel specific) • kernel-package (kernel specific) • ncurses-dev (use make menuconfig) • libglade 2 -dev (use make gconfig} • module-assistant, debhelper (to create modules) 9

Download and install the kernel source code using aptitude • • sudo aptitude update

Download and install the kernel source code using aptitude • • sudo aptitude update sudo aptitude install linux-source ls –l /usr/src/linux-source* cd /usr/src tar –xjf linux-source-2. 6. 31. tar. bz 2 sudo aptitude install git-core cd /usr/src/linux-source-2. 6. 31 make menuconfig 10

Customizing the Kernel • Under /usr/src/linux-source-***: make menuconfig • Check the hidden. config file

Customizing the Kernel • Under /usr/src/linux-source-***: make menuconfig • Check the hidden. config file 11

Compiling/Installing a kernel image file and loadable modules • make-kpkg–rootcmd fakeroot kernel-image – man

Compiling/Installing a kernel image file and loadable modules • make-kpkg–rootcmd fakeroot kernel-image – man make-kpkg – Compile the kernel • /var/cache/apt/archives/linux-image-***deb • sudo dpkg –i linux-image*. deb: – Install the kernel 12

Search the package • aptitude search source$ – To display a list of available

Search the package • aptitude search source$ – To display a list of available *-source packages – Source$ ensures that the string matches only the last part of a package name 13

Downloading, compiling, and installing nonstandard modules • module-assistant –text-mode auto-install line 6 usb-source –

Downloading, compiling, and installing nonstandard modules • module-assistant –text-mode auto-install line 6 usb-source – Module-assistant utility calls sudo to run apt-get and dpkg 14

Load a module • After a module is installed with module-assistant, it must be

Load a module • After a module is installed with module-assistant, it must be loaded to make it available to the kernel • depmod: works with dependencies for modules • insmod: loads modules in a running kernel – insmod /lib/modules/2. 6. 31*/kernel/drivers/block/floppy. ko • lsmod: lists information about all loaded modules • modinfo: list information about a module 15

Load a module • modprobe: loads, unloads, and repots on modules • rmmod: unloads

Load a module • modprobe: loads, unloads, and repots on modules • rmmod: unloads a module from a running kernel 16