16
1 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 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

Embed Size (px)

Citation preview

Page 1: 1 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

1

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.

Page 2: 1 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

2

Linux Kernel

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

Page 3: 1 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

3

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.

Page 4: 1 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

4

Example of Some Sample Tunable Kernel Parameters

• /etc/sysctl.conf

Page 5: 1 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

5

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.

Page 6: 1 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

6

LibrariesLibraries CommandsCommands

Device DriverDevice Driver

The UNIX ArchitectureInteractive User

ApplicationPrograms

ApplicationPrograms

OS System Call Interface

Device DriverDevice Driver

Device DriverDevice Driver

Dri

ver

Inte

rfac

eD

rive

r In

terf

ace

…Monolithic Kernel Module•Process Management•Memory Management•File Management•Device Mgmt Infrastructure

Trap Table

Page 7: 1 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

7

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.

Page 8: 1 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

8

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.

Page 9: 1 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

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)• libglade2-dev (use make gconfig}• module-assistant, debhelper (to create modules)

9

Page 10: 1 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

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.bz2

• sudo aptitude install git-core

• cd /usr/src/linux-source-2.6.31

• make menuconfig10

Page 11: 1 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

Customizing the Kernel

• Under /usr/src/linux-source-***: make menuconfig

• Check the hidden .config file

11

Page 12: 1 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

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

Page 13: 1 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

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

Page 14: 1 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

Downloading, compiling, and installing nonstandard modules

• module-assistant –text-mode auto-install line6-usb-source– Module-assistant utility calls sudo to run apt-get

and dpkg

14

Page 15: 1 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

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

Page 16: 1 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

Load a module

• modprobe: loads, unloads, and repots on modules

• rmmod: unloads a module from a running kernel

16