Вы находитесь на странице: 1из 6

KERNEL SERVICES

THE LINUX KERNEL

The kernel constitutes the core part of the Linux operating system.

KERNEL DUTIES:

System initialization: detects hardware resources and boots up the system.

Process scheduling: determines when processes should run and for how long.

Memory Management: allocates memory on behalf of running processes.

Security: Constantly verifies filesystem permissions, SELinux contexts and firewall rules.

Provides buffers and caches to speed up hardware access.

Implements standard network protocols and filesystem formats.

KERNEL IMAGES

Architectures supported: x86, x86_64, IA64/Itanium, PowerPC64, s390x.

Three kernel versions available for x86:

o Regular: one or more processors but 4GB of RAM or less

o PAE: multiple processors and up to 64G of RAM

o Xen: needed for virtualization

Kernels always installed under /boot/vmlinuz-*

KERNEL MODULES

o Modules are small kernel extensions that may be loaded and unloaded

o Can implement drivers, filesystems, firewall, and more

o Are located under /lib/modules/$(uname -r)/

o Compiled for a specific kernel version and are provided with the kernel RPM.

o Third party modules may be added

kernel modules resides in /lib/modules

lsmod - program to show the status of modules in the Linux Kernel

lsmod eth0

lsmod usb_storage

modprobe - program to add and remove modules from the Linux Kernel

To add the module eth0


modprobe eth0

modprobe usb_storage

To Remove the module eth0

modprobe -r eth0

modprobe -r usb_storage

modinfo - program to show information about a Linux Kernel module

modinfo ipv6

modinfo mii

/etc/modprobe.conf - module aliases are stored

/etc/modprobe.conf used for module configuration:

o Parameters to pass to a module whenever it is loaded

o Aliases to represent a module name

o Commands to execute when a module is loaded or unloaded

depmod - creates a list of module dependencies, by reading each module under

/lib/modules/version. By default this list is written to modules.dep in the same directory.

insmod - simple program to insert a module into the Linux Kernel, it will not load

dependencies of the modules

rmmod - simple program to remove a module from the Linux Kernel

Note: modprobe and modprobe --remove <modulename> are the preferred methods to insert and

remove modules from kernel.

ACCESSING DRIVERS THROUGH /dev

Device special files located under /dev are all tagged with three attributes:

the device type (character or block)

major number

minor number

ls -l command display those attributes:

ls -l /dev/ttyS0
crw-rw---- 1 root uucp 4, 64 Sep 12 17:02 /dev/ttyS0

ls -l /dev/sdb1

brw-r----- 1 root disk 8, 1 Sep 12 2007 /dev/sdb1

where c ==> character device

b ==> block device

Note: Notice that there is no file size, this field was replaced with 4, 64.

4 ==> major number

64 ==> minor number

The major number determines which driver to access, whereas the minor number allows the driver to

differentiate between similar physical devices.

DEVICE NODES:

BLOCK DEVICES

/dev/hda, /dev/hdc - IDE hard disk, CDROM

/dev/sda, /dev/sdb - SCSI, SATA, or USB Storage

/dev/md0, /dev/md1 - Software RAID

CHARACTER DEVICES

/dev/tty[0-6] - virtual consoles

/dev/null, /dev/zero - software Devices

/dev/random, /dev/urandom - random Numbers

MANAGING /dev WITH UDEV

udev manages files stored under /dev/

Files only created if corresponding device is plugged in

Files are automatically removed when device is disconnected

udev statements under /etc/udev/rules.d/ determine:

o Filenames

o Permissions

o Owners and groups


o Commands to execute when a new device shows up

ADDING FILES UNDER /dev

The right way to add a /dev entry involves udev:

Create a new file under /etc/udev/rules.d/99-usb.rules

Insert a statement such as:

KERNEL=="sdb", NAME="myusbkey" , SYMLINK="usbstorage"

This creates a device file named usbkey and a symlink named usbstorage next time /dev/sdb gets

plugged.

Files can be added manually with mknod:

mknod /dev/usbdevice b 8 0

mknod not persistent!

MANAGING PROC FILE SYSTEMS

/proc is a virtual filesystem containing information about the running kernel. Files under /proc

may be viewed using cat

cat /proc/cpuinfo ===> info about system CPU

cat /proc/meminfo ===> memory info ( RAM Size )

/proc/partitions ===> kernel partition table info

IP FORWARDING:

It is used to connect two different networks, ie., system is acting like a router

cat /proc/sys/net/ipv4/ip_forward

echo "1" > /proc/sys/net/ipv4/ip_forward

List all current settings: sysctl -a

Reload settings from sysctl.conf: sysctl -p

Note: /proc/sys modifications are temporary and not saved at system shutdown

vi /etc/sysctl.conf

net.ipv4.ip_forward = 1

sysctl -p
Note: sysctl is called at boot time by rc.sysinit and uses settings in

/etc/sysctl.conf

EXPLORING HARDWARE DEVICES:

A snapshot of all connected devices is maintained by HAL: Hardware Abstraction Layer

hal-device ==> lists all devices in text mode.

hal-device-manager ==> displays all devices on a graphical window.

lspci and lsusb ==>list devices connected to the PCI and USB buses, respectively.

MEMORY:

free

Display amount of free and used memory in the system

vmstat

Report virtual memory statistics

swapon -s

Display swap usage summary by device. Equivalent to "cat /proc/swaps

pmap

report memory map of a process

PROCESSES:

ps

report a snapshot of the current processes

top

program provides a dynamic real-time view of a running system

gnome-system-monitor

graphical tool to display current processes

KERNEL STATE:

uname

print system information suchas kernel-name, kernel-version, kernel-release...


uptime

Tell how long the system has been running

tload

graphic representation of system load average

KUDZU

Kudzu detects and configures new and/or changed hardware on a system. When started,

kudzu detects the current hardware, and checks it against a database stored in /etc/sysconfig/hwconf,

if one exists. It then determines if any hardware has been added or removed from the system. If so, it

gives the users the opportunity to configure any added hardware, and unconfigure any removed

hardware. It then updates the database in /etc/sysconfig/hwconf

Вам также может понравиться