The kernel (written in c) : Kernel jobs: • memory management • Process management • Device drivers • System calls and security Kernel features : • System memory management (physical and virtual(swap memory), maintain page table for physical and virtual memory) • Software program management • Hardware management • Filesystem management Kernel modules (extension: .ko) : allows drivers and features to work as modules (can be loaded d uring run time oe unlinked) Process : a running program When a kernel starts a process the process is given a unique space in virtual memory to store process data Device driver: enables kernel to communicate with hardware Linux device file classificatio n : files that defines the type of hardware <character/block/network> Kernel binary: compiled kernel code (usually compressed to save memory) Kernel patch: incremental release to add changes to kernel. example: Patch release 4.3.1 for kernel version 4.3.0 Applying kernel patch: download source code and use patch command to install then recompile kernel Kernel headers (extension: .h): used to inform compilers of the needed libraries to successfully compile kernel usually put into /usr/src/linux/ directory or /usr/src/kernels/ directory Kernel documentation: Details about kernel source codes (separated th an kernel usualy) Location: /usr/src/linux/ subdirectories or /usr/src/kernels/ subdirectories Kernel binary image types: • Bzimage: compressed with gnu zip • Vmlinux: uncompressed • Vmlinuz: generic compressed • Zimage: gnu zip compressed small binary Kernel re lated commands : • Uname < - s print kernel name, - n print hostname , - r print kernel release info, - v prints kernel version, - m prints the machine hardware name , - o prints os name, - a prints all > //shows information about the system kernel. For more parameters type man uname • Lsmod // prints list of installed modules on the system • Modinfo // shows information about a specific module • Rmmod // a command to safely remove kernel module • Insmod // to in stall a kernel module and you should specify the path for the module • Ps // show running processes • Variant // show running processes • Cat /proc/meminfo // displays memory information • Cd dev ; ls //shows all devices in the system • Lspci //shows pci devices • Lsusb //shows usb devices Important directories: Lib/modules/ #downloaded modules and previously installed ones are located here – /usr/src/linux/ directory or /usr/src/kernels/ directory #location to extract kernel source code after downloading it from www.kernel.org or distribution repository /etc/dev //location of system all devices /lib/modules/ //location where modules are in /etc/modules or /etc/ modules - load.d/ in redhat //required for boot modules /etc/conf.modules //customize boot modules – /etc/udev/rules.d/ and – /lib/udev/rules.d/ for hardware rules Compiling kernel: 1. Obtaining source code Download it from kernel.org and extract it to /u sr/src/linux/ or /usr/src/kernels/ 2. Creating the configuration file Edit /usr/src/linux/.config (contains feature name and settings) or use make target command (the script will ask questions and scan for features and make the config) You can do it using: • Config : asks questions and makes configuration • Deconfig: creates default configuration based on the detected system • Oldconfig: updates the config with new kernel features only • Menuconfig: uses text based menu to select features • Xconfig: uses graphical men u Gconfig: uses graphical gtk feature selection 3. Compiling and installing the kernel • Make clean • Make //to create uncompressed kernel • Make bzimage //to make a compressed kernel image • Move image to boot and system.map if needed and run make install 4. Compilin g and installing modules • Make modules • Make make modules • Or copy them to /lib/modules/ kernelversion then run make modules_install 5. Creating an initial RAM disk • Mkinitrd for red hat • Makeinitramfs for debian 6. Booting the new kernel • Add kernel info to /boot/grub/grub.cfg or run update - grub 7. Creating a kernel package deb - pkg to create a package installer so you wont have to do everything again proc Contains – Configuration and performance information related to the running kernel – Information on hardware, such as: • Assigned interrupt requests (/proc/interrupts) • I/O ports (/proc/ioports) • Direct memory access (DMA) channels (/proc/dma) – Kernel information in /proc/sys/kernel