Using and configuring the Linux 2.6 kernel, and building it “The Debian Way” Presented April 2, 2008 by Chris Knadle Files related to the talk maintained.

Slides:



Advertisements
Similar presentations
Drivers and the kernel1-1 Drivers and the kernel UNIX system has three layers: m The hardware m The operating system kernel m The user-level programs Kernel.
Advertisements

Linux can be generally divided into four major components: 1. KERNEL – OS, ultimate boss The kernel is the core program that runs programs and manages.
CIS238/DL1 Chapter 15 Rebuilding the Linux Kernel Preparing the Source Code Locating the Source Code Installing the Source Code Read the Documentation.
Week 10 The Linux Kernel More Development Tools CSCI 156.
Project 0: Linux & VM Dabbling CS-502, Fall Project 0: Linux & Virtual Machine Dabbling CS-502, Operating Systems.
Hands-On Microsoft Windows Server 2003 Chapter 2 Installing Windows Server 2003, Standard Edition.
Chapter 9 Extra Topics. The Kernel Core of the operating system Similar to UNIX kernel Originally developed and still controlled by Linus Torvalds uname.
Cambodia-India Entrepreneurship Development Centre - : :.... :-:-
G51FSE Version Control Naisan Benatar. Lecture 5 - Version Control 2 On today’s menu... The problems with lots of code and lots of people Version control.
Introduction to The Linaro Toolchain Embedded Processors Training Multicore Software Applications Literature Number: SPRPXXX 1.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Git for Version Control These slides are heavily based on slides created by Ruth Anderson for CSE 390a. Thanks, Ruth! images taken from
Operating Systems Lab. (#2) University of Tehran – ECE Dept. Fall 2005 Reza Shokri
Chapter-4 Windows 2000 Professional Win2K Professional provides a very usable interface and was designed for use in the desktop PC. Microsoft server system.
Hands-On Microsoft Windows Server 2008
Guide to Linux Installation and Administration, 2e1 Chapter 3 Installing Linux.
Tutorial 11 Installing, Updating, and Configuring Software
Kernel Development using Virtualization Installing VMWare and using a virtual machine to build and test a Linux Kernel.
Hands-On Virtual Computing
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
LOGO Linux Installation. Linux Distribution Including shells, libraries, tools, compiler, servers, applications. Redhat, Fedora, Mandrake, SuSE, Debian,
Working with Ubuntu Linux Track 2 Workshop June 2010 Pago Pago, American Samoa.
Kernel Modules Giving your Linux more pop since 1995.
Windows Vista Inside Out Chapter 22 - Monitoring System Activities with Event Viewer Last modified am.
09/21/081 Ho Chi Minh city University of Technology Linux kernel R.M. Introduction of building Linux kernel from source.
Installation Overview Lab#2 1Hanin Abdulrahman. Installing Ubuntu Linux is the process of copying operating system files from a CD, DVD, or USB flash.
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.
Guide to Linux Installation and Administration, 2e1 Chapter 10 Managing System Resources.
Troubleshooting and Performance
Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System.
CHAPTER 2. Overview 1. Pre-Installation Tasks 2. Installing and Configuring Linux 3. X Server 4. Post Installation Configuration and Tasks.
Linux Kernel Management. Module 9 – Kernel Administration ♦ Overview The innermost layer of Linux operating system is the kernel, which is a thin layer.
What is a port The Ports Collection is essentially a set of Makefiles, patches, and description files placed in /usr/ports. The port includes instructions.
National Taiwan University OS Project 0 & 1 Advisor: Dr. Chih-Wen Hsueh Student: Tang-Hsun Tu 台灣大學 網媒所 / 資工所 Wireless Networking and Embedded Systems Laboratory.
OS Project 0 February 25, Outline  Linux Installation  Linux Kernel Compilation  System Call Development  Kernel Modules / 452.
LOGO Linux Installation. Linux Distribution Including shells, libraries, tools, compiler, servers, applications. Redhat, Fedora, Mandrake, SuSE, Debian,
Linux Kernel Programming (LKP). LKP New sub-course New sub-course We will learn together We will learn together Evaluation of this part of course will.
Installing Applications in FreeBSD lctseng. Computer Center, CS, NCTU 2 Before we start  Permission issue root: the super user Like administrator in.
Lab 8 Department of Computer Science and Information Engineering National Taiwan University Lab8 - Root Filesystem 2015/11/10/ 22 1.
Implementation of Embedded OS
Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 - OS Kernel 2014/10/21/ 16 1.
1 Setup and Compile Linux Kernel Speaker: Yi-Ji Jheng Date:
Embedded Software Design Week II Linux Intro Linux Kernel.
Thousands of Linux Installations (and only one administrator) A Linux cluster client for the University of Manchester A V Le Blanc I T Services University.
Rebuilding Linux Kernel Dedicated to penguin lovers everywhere 26 September 20161Rebuilding kernel by Visakh M R.
Packaging Software for Debian Roberto C. Sánchez Ohio Linuxfest Saturday, September 29, 2007.
Installing Windows 7 Lesson 2.
The GRUB bootloader Michael Opdenacker Thomas Petazzoni Free Electrons
Andrea Chierici Virtualization tutorial Catania 1-3 dicember 2010
Operating System Kernel Compilation
Development Environment
© 2002, Cisco Systems, Inc. All rights reserved.
Guide to Linux Installation and Administration, 2e
Computer System Laboratory
OS Homework 1 February 22, 2017.
UBUNTU INSTALLATION
Installation and Configuration
Drivers and the kernel UNIX system has three layers: Kernel
Development and Deployment
CVS revisions UML diagram
Braindumps
Operating System Kernel Compilation
IS3440 Linux Security Unit 7 Securing the Linux Kernel
COP 4343 Unix System Administration
SUSE Linux Enterprise Desktop Administration
Version Control System - Git
SUSE Linux Enterprise Desktop Administration
Computer System Laboratory
Operating System Kernel Compilation
Presentation transcript:

Using and configuring the Linux 2.6 kernel, and building it “The Debian Way” Presented April 2, 2008 by Chris Knadle Files related to the talk maintained at: ftp://ftp.coredump.us/kernel-talk_ or on the MHVLUG page for the meeting at:

** Outline / overview – 28 slides total ● Tour of interacting with the Linux kernel ● Bootup diagrams ● Configuration strategies ● Building Linux and external drivers ● diff, patch, quilt, and git ● Specific CONFIG_ options of interest

** The main functions of the kernel 1. Memory management 2. Process management 3. File system management 4. I/O management 5. “Blue Black Screen Of Death !” :-) i.e. if something goes horribly wrong and a kernel panic occurs, try to give a clue as to why [ level of detail depends on debugging options ] 2

** Whirlwind tour of interacting w/ the kernel (1) ● boot parameters can be for drivers or to change boot behavior GRUB: kenrel /vmlinuz... root=/dev/hda3 ro vga=1 ● insmod loads a single driver built as a module ● modprobe loads a driver built as a module (which initializes hardware) + loads driver dependencies Module parameters can be specified in an alias in /etc/modprobe.conf, /etc/modprobe.d/*, or (deprecated) /etc/modules.conf 3

** Whirlwind tour of interacting w/ the kernel (2) ● rmmod removes a module ● /etc/modules modules to load at boot that are not auto-detected ● /sbin/modinfo as well as the documentation on the driver explain parameters a module offers and where the module is ● Text output from driver load is output to the kernel ring buffer; available for examination in /var/log/dmesg or by running the ' dmesg ' command 4

** Whirlwind tour of interacting w/ the kernel (3) ● In /proc/sys/ there are kernel settings that can be viewed and changed on-the-fly. Example: $ cat /proc/sys/net/ipv4/ip_forward 0 $ echo “1” > /proc/sys/net/ipv4/ip_forward ● Making settings in /proc/sys/ permanent can be accomplished by modifying /etc/sysctl.conf, changing ' / ' characters to '. ', and stripping off the initial /proc/sys/ portion. Using previous Ex: net.ipv4.ip_forward = 1 5

** Whirlwind tour of interacting w/ the kernel (4) ● But developers are moving items from /proc/sys/ to /sys/ and /etc/sysctl.conf is hardcoded to adjust items in /proc/sys/ Example: $ cat /sys/block/hda/queue/scheduler noop anticipatory deadline [cfq] $ echo “deadline” > /sys/block/hda/queue/scheduler ● The sysfsutils package includes /etc/sysfs.conf which will set kernel parameters in /sys/ at boot time; has a different syntax than /etc/sysctl.conf block/hda/queue/scheduler = deadline 6

** Reasons to compile your own kernel Because you can ● Because you can “Use the source!” ● New hardware support ● Quirky, old, or non-generic hardware ● Experimentation, development, bug fixes ● Configuration for a particular desire (security, preemption, embedded applications, remove the need of an initrd image, remove unwanted functionality, custom fixes, etc) 7

** Reasons NOT to compile your own kernel ● It's likely to get it “wrong” at first. [ won't compile, can't find init, missing drivers, etc ] ● Some software vendors refuse to give support if you are running a custom kernel ● In some cases software may break even if you get it “right” due to expecting kernel to be built in a particular way [Missing driver, a script designed to load a module when instead the driver is built-in, etc] 8

** Minimum requirements for kernel building For Linux : = 3.2 [and I recommend gcc < 4.3] ● binutils >= 2.12 ● make >= ● util-linux >= 2.10 ● module-init-tools >= ● e2fsprogs >= 1.29 (if ext2/3/4 used) ● udev >= 081 ● procps >= ● A “computer”; 128 MB of RAM is definitely more than enough, need 500 MB to 1 GB of dedicated storage space 9

** Bootup for the Linux kernel (simplified) Power on, CMOS MBR BOOT LOADER LINUX initrd.im g run /sbin/init run initrd /init mount / POSIX shell script ELF binary executable Boot Options mount / init rd? Yes No load internal drivers load driver modules load initrd driver modules 10

** Decide what Linux source to start with (1) 1. Download a Linux kernel source tarball wget ~56 MiB download for full image, patch sizes vary Expands to an additional ~308 MiB 2. Install as a package from the distribution apt-get install linux-source- yum install kernel-devel. Size varies 3. Download from a Git repository git clone git://git.kernel.org/pub/... ~176 MiB packed in.git + ~308 MiB expanded, updates are space efficient 11

** Decide what Linux source to start with (2) Downloading the latest stable full image; or visit: PATCH FULL 12

** Configuration of the Linux kernel (1) ● Don't start from scratch; copy one of the working config files from /boot/config- to the local Linux source directory as the filename “.config ” These ship with every distribution. ● Make one of: ' menuconfig ', ' xconfig ', ' gconfig' Customize the configuration for your needs; ' xconfig ', ' menuconfig ', etc, can also be used as a visualizer for looking at a config file ● Read the help on the configuration options If you're in a rush, pay close attention to: If in doubt, say “_” 13

** Configuration of the Linux kernel (2) menuconfig 14

** Configuration of the Linux kernel (3) xconfig 15

** Configuration of the Linux kernel (4) gconfig 16

** Linux configuration strategies (1) ● Generic, all drivers built as a module, initrd ● Targetted built-in drivers, all other drivers built as a module ● Minimal drivers all built-in, no module support at all ● Drivers can be built-in (choosing “Y), as a module (choosing “M”), or not built at all (choosing “N). “N” -- driver / feature not available at all “Y” -- loaded with kernel, cannot be unloaded, cannot specify options using aliases “M” -- modularized, might be loaded with initrd 17

“M” = module “Y” = built-in ** Linux configuration strategies (2) Power on, CMOS MBR BOOT LOADER LINUX initrd.im g run /sbin/init run initrd /init mount / Boot Options mount / init rd? Yes No load internal drivers load driver modules load initrd driver modules “M” + req'd for boot 18

** Linux configuration strategies (3) ● Generic, all drivers built as a module, initrd Build drivers as modules, specify ' --initrd ' during the build. Easiest starting method ● Targeted built-in drivers ● Use 'lsmod' to list the modules your machine ● uses, look in the help for ● “module will be called ” ● can also use '/sbin/modinfo' for hints ● find + build-in the most required parts of the list ● Minimal drivers all built-in, no module support at all Build-in dependencies, remove all nonessentials 19

** Installing the required tools ● Required: kernel-package fakeroot bzip2 and other packages are required depending on which configuration ' make ' target you want to build: For ' menuconfig ': libncurses5-dev For ' xconfig ': libqt3-mt-dev g++ For ' gconfig ': libgtk2.0-dev libglade2-dev ● fakeroot is a shell script specifically designed to allow making files that have root ownership, which is required to make Debian packages. It does not give a user elevated privilages. 20

package ** Reasons to build + install Linux as a package rather than installation via “make install” ● Makes life easier: installing / removing package updates the boot menu automatically ● Can transfer the package to another box for installation, alleviating the need for installing a development environment on servers ● Can also build external modules in packaged sources maintained outside of the kernel tree ● Because... is there a good reason not to? 21

** But isn't making a package more work? Let's see! This is without making a package: make menuconfig make clean time nice make bzimage modules su make modules_install install cp arch/i386/boot/bzImage /boot/vmlinuz initrd-crk1 cp System.map /boot/System.map initrd-crk1 cp.config /boot/config initrd-crk1 mkinitramfs initrd-crk1 update-grub With making a package: make menuconfig fakeroot make-kpkg clean time nice fakeroot make-kpkg --revision= initrd+crk1 \ --initrd kernel_image cd.. sudo dpkg -i *.deb 22

** Making packages saves you work ● Sources for external modules can be installed, which install tarballs into /usr/src/ make-kpkg looks for these in /usr/src/modules by default, behavior can be changed by modifying the MODULES_LOC parameter of kernel-pkg.conf ● With making kernel + external module packages: make menuconfig fakeroot make-kpkg modules_clean fakeroot make-kpkg clean time nice fakeroot make-kpkg \ --revision= initrd+crk1 \ --initrd kernel_image modules_image cd.. sudo dpkg -i *.deb 23

** How the boot manager gets updated ● /etc/kernel-img.conf sets behavior for when a new kernel is installed; runs update-grub by default ● menu.lst “comments” used by update-grub # Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST ### BEGIN AUTOMAGIC KERNELS LIST ## lines between the AUTOMAGIC KERNELS LIST markers will be modified ## by the debian update-grub script except for the default options ## below ## DO NOT UNCOMMENT THEM, Just edit them to your needs... # kopt=root=/dev/hde3 ro vga=1 This is not simply a comment -- this a setting used by update-grub when re-making the boot entries 24

** diff, patch, quilt, and git (1) ● diff -- outputs the differences between files or directories; ' diff -u ' has a nicer looking output ● patch – apply a diff to file(s) patch -p1 <../patch ● quilt – handles a series of patches; uses a directory ' patches ' to create or use a series of diffs The ' series ' file lists the order to apply a set of patches. Apply all patches of a quilt patchset with quilt push -a 25

** diff, patch, quilt, and git (2) ● git -- a full Source Control Management system [package name is ' git-core '] git-clone -- download a repository git-pull -- update a repository git-branch -- make a new branch git-branch -D -- delete a branch (uncond.) git-checkout -- switch working branches git-add -- add a file to be tracked git-commit -a -- commit differences to tracked files git-status -- check working tree status vs repository 26

** CONFIG options of interest for “General setup” section: CONFIG_FAIR_GROUP_SCHED → For desktop, Say N CONFIG_PREEMPT_VOLUNTARY → For desktop, Say Y “Processor type and features” section: CONFIG_NO_HZ → tickless kernel, interesting idea “Kernel hacking” section: CONFIG_MAGIC_SYSRQ → Say Y, and read sysrq.txt CONFIG_DEBUG_KERNEL → Say Y “Device Drivers -> General Driver Options” CONFIG_UEVENT_HELPER_PATH → set to “” (i.e. empty) unless your system is old and actually uses /sbin/hotplug (the default) 27

** Additional resources ● Things to look for in the Linux /Documentation area: HOWTO -- lists starting points and relevant text files kernel-parameters.txt -- lists the many available boot parameters kernel-doc.txt -- lists lots of free online books /networking/* -- network drivers documentation Linux Kernel In A Nutshell [free pdf download] by Greg Kroah-Hartman: 28