Linux Kernel Basics

  • Introduction and Kernel Documentation

 

In CentOS or RehHat install the package  kernel-doc

In Ubuntu the documentation is installed with the kernel source code

Web based documentation can be retrieved fron  www.kernel.org/doc

 

yum install kernel-doc

ls /usr/share/doc/kernel-doc-2.6.32/Documentation

../Documentation/filesystems/proc.txt

 

less /usr/share../Documentation/filesystems/proc.txt

$ cat /proc/self/status 

less filesystems/proc.txt

 

  • Understanding Kernel Types and Initial Ram Disks

 

Kernel Files

/boot/vmlinux   no-compression    – Also may include virtual memory support as a zImage file

/boot/vmlinuz  compresed with zlib – Or higher compression as bzImage  file

 

Check the Kernel Image Tyoe

 file /boot/vmlinuz-3.13.0-49-generic 

This should list kernel as bzImage and highly compressed with virtual memory support

 

Initial RAM Disks

The initial RAM disk is responsible for loading a temporary root file-system during the Linux boot process. This allows for the real root file-system to be checked and drivers to access the root file-system loaded.

 

There are 2 Types of Initaial RAM Disks

initrd

Use prior to kernel 2.6.13

Compressed file-system image mounted through /dev/ram

The file-system module used in initrd must be compiled into the kernel , often ext2 but some use cramfs

 

initramfs

Used with kernel 2.6.13 onwards

This is cpio  archive

Unpacked by the kernel to tmpfs which becomes the initial root file system

Does not require file-system or block device to be compiled into the kernel

 

  • Viewing the Kernel and Initial Ram Disks

cd /boot

Viewing the Kernel and Initial Ram Disks

file vmlinuz-2.6.32-504.8.1.el6.x86_64

Viewing the Kernel and Initial Ram Disks 2

 

 

file initramfs

sudo initramfs-2.6.32-505.8.1.el6.x86_64.img

sudo initramfs-2.6.32-505.8.1.el6.x86_64.img

 

 

copy file in tmp directory

rename in img.gz

gunzip

initramfs

mkdir init

cd init

cpio *-id <../initramfs-2.6.32…..img

unarchive and create the directory

ls

we do have full filesystem expended

is the operated system

cpio initramfs

 

Ubuntu

file initrd.imig-2.6.10-5-386    is a linux compress filesystem

 

mount -t sysfs initrrd.img-2.6.10-5-386 /mnt

mount -t sysfs initrrd.img-2.6.10-5-386

 

ls /mnt

 

umount /mnt

 

tree /urs/src

yum install-devel

tree /usr/src/ | less

 

Kernel and Initial Ram Disk files   is a compress file-system itself that is mounted through your memory during the boot process