%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Specify default fonts: %deffont "standard" xfont "helvetica-medium-r", tfont "standard.ttf", tmfont "hoso6.ttf" %deffont "thick" xfont "helvetica-bold-r", tfont "thick.ttf", tmfont "hoso6.ttf" %deffont "typewriter" xfont "courier-medium-r", tfont "typewriter.ttf", tmfont "hoso6.ttf" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Default settings per each line numbers. %% %default 1 area 90 90, leftfill, size 2, fore "black", back "white", font "standard", hgap 0 %default 2 size 7, vgap 10, prefix " ", ccolor "black" %default 3 size 2, bar "black", vgap 10 %default 4 size 5, fore "black", vgap 30, prefix " ", font "standard" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Default settings that are applied to TAB-indented lines. %% %tab 1 size 5, vgap 40, prefix " ", icon box "green" 50 %tab 2 size 4, vgap 40, prefix " ", icon arc "green" 50 %tab 3 size 3, vgap 40, prefix " ", icon delta3 "green" 40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 Introduction to the Linux Kernel %bar "skyblue" 6 15 70 %font "standard", hgap 0 %font "standard", size 8.0 Customized Linux Kernel: What? Why? How? %font "standard", hgap 10, size 4.5 %left Presented by: ME of NBLUG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 Overview %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left %rcutin Discussion Overview (@ 10,000 feet) What is a kernel? Why would I want to build my own? How would I build a kernel? Special warnings! Know thy system. Configure your kernel/modules. Build your kernel/modules. Install Kernel/modules. Test your kernel. Examples Questions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 What? (1) %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left The Linux kernel is a special program that manages and arbitrates control of hardware and other programs. %center %IMAGE "kernel-model1.png" %left %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 Why? (1) %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left Why upgrade or build your own kernel? %font "standard", hgap 5, size 2.0 You want to be intimate with your OS. (Sooooo Sexy!) You want to build other apps that use a built kernel src tree You want to optimize a kernel (for speed, size, security, etc.) You want to patch your kernel to use non-standard features. You want a new feature only available in a new kernel. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 Why? (2) %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left Why upgrade or build your own kernel? %font "standard", hgap 5, size 2.0 You are doing kernel development You are adding a new hardware to machine not supported under current kernel You want to customize the kernel and do not want the default kernel shipped out to you. You want to built a "netbooting" version of Linux %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 Why? (3) %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left Why upgrade or build your own kernel? %font "standard", hgap 5, size 2.0 CS course requires you to build or modify a kernel. Curiosity Work requires an OS with src available for review Many, many more reasons... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (0): Review %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: %font "standard", hgap 5, size 2.0 Special warnings! Know thy system. Configure your kernel/modules. Build your kernel/modules. Install Kernel/modules. Test your kernel. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (1a): Special warnings! %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Special warnings! (a) %font "standard", hgap 5, size 2.0 Have recent Backup of system? (good idea) Have access to emergency boot disks (fix bad install) Initial investment in time for first kernel is great Your first kernel may function, but be missing features you want. You may need to reconfigure, enable a feature and rebuild. You may find patches to the kernel that offer non-standard features. (A more advanced process.) Audience have other warnings? You built your running kernel? : upgrade = EASY! You can leverage your existing knowledge You can use the previous kernel's config file (very cool) You won't need to review help information for kernel options. Summary: The first one is the most work, and the rest easier. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (1b): Special warnings! %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Special warnings! (b) %font "standard", hgap 5, size 3.0 Issues: Netbooting kernel System requires/uses initrd Software RAID on root disk Special encryption on root disk (depreciated) Your Distro installed it this way Special hardware support Vendor/Distro special kernels (RH) Other "stuff" depends on kernel version pcmcia-cs certain network sniffers/analyzers commercial modules (with source) proprietary module (no source) vmware %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (2a): Know thy system. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Know thy system. %font "standard", hgap 5, size 3.0 You should become aquainted with the hardware on your computer. How? Use some applications on your present running box: # lsmod |less # dmesg |less # lspci # less /proc/interrupts # less /proc/ioports # less /proc/cpuinfo # less /proc/dma # less /proc/interrupts # ls /proc/bus/ # less /proc/bus/*/* # ls /proc/driver # less /proc/dma # less /proc/iomem # less /proc/filesystems # ls /proc/ide /proc/scsi # less /proc/iomem (Provide some demos) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (2b): Know thy system. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Know thy system. %font "standard", hgap 5, size 3.0 Other things to do: o Check the specifications of your computer (E.G.: Dell) o Go to your computer BIOS/Setup and look at what is there o If you have MS Windows, look at the "Devices" in the system control panel o grep -i model# linux/Documentation/Configure.help o use google: http://www.google.com/linux o ask the mailing list members Once you have gathered, or at least know where to gather information about your system, you can then proceed on to configuration... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (3a): Configure your kernel/modules. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Configure your kernel/modules. (a) %font "standard", hgap 5, size 3.0 options/features required in a kernel for initial boot and access to files must not be modules. Driver interface for all boot media (IDE,SCSI,etc)? Filesystems mounted at boot? Use of InitRD? Use of RAMDisk? When choosing "CPU" it is ok to choose "lower", but don't choose "higher" If you have 686, choosing 386 is ok (not desirable) If you have a 386, do not choose 686 (bad!) First time through: Don't enable prompt for developmental or experimental What should be module? (Cost/Risk/Choice) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (3b): Configure your kernel/modules. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Configure your kernel/modules. (b) %font "standard", hgap 5, size 3.0 Download (ftp text file) Verify sig (same file - optional) Unpack (same file) cd and clean: NOTE: make mrproper will delete any previous ".config" file! # make clean && make mrproper Choose one configure from below: # make configure (old, user unfriendly) # make menuconfig (newer, uses ncurses/curses, may fail if not installed) # make xconfig (nicer, but limited: only runs in "X") %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (3c): Configure your kernel/modules. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Configure your kernel/modules. (c) %font "standard", hgap 5, size 3.0 Common items most people will want to enable first time through: Loadable Modules (Enable, Versions, Kernel Module Loader) Processor Type: (Machine Check Exception, SMP, & per CPU options) Plug and Play: (PNP, ISA) Block Device: (floppy, useful-- loopback, ramdisk, network block dev) RAID: DANGER: If you use software RAID on your root "/" you need the initrd install. (Not covered here) Networking: (packetsocket, UNIX Domain Sockets, TCP/IP, others as needed.) One of these will almost certainly be use: ATA/IDE/MFM/RLL support (If you use/have these disks) SCSI support (If you use/have SCSI) Network Device (Choose your card(s) driver(s), use PPP? Wireless?) Input core support (If you use USB devs or plan to) Character devices (choose your mouse, video acceleration (more risky)) Filesystem (choose what you use/plan to use how to know? *Answer*) Console Driver (VGA text console) Sound (Trickiest *details*) USB (Enable if you use it) Kernel Hacking (Magic SysKey request) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (3d): Configure your kernel/modules. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Configure your kernel/modules. (d) %font "standard", hgap 5, size 4.0 Come back here after you have built a minimal working kernel. %font "standard", hgap 5, size 3.0 Now that you have been through it once, review it again and then build if you add new features. Once you have a working kernel, you will likely want to re-configure and enable "Code maturity level options" and choose to enable the "dev options" Then, revisit all of the option sections and examine anything that looks new. If you find a new item that looks like it is something you need, then try enabling it. Limit the number of developmental items you enable at any one time to minimize troubleshooting if an option is not helpful. Build new one and test it. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (4): Build your kernel/modules. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Build your kernel/modules. %font "standard", hgap 5, size 3.0 Now that you have configured your kernel source tree, start build: Begin with build of dependencies: # make dep After the dependencies have been built without error, make kernel: # make bzImage When that is complete, you should have a kernel. However, you are not done yet! Copy the kernel to the "standard" location in many distro: # cp arch/i386/boot/bzImage /boot/your-custom-kernel-name Copy the System.map file to /boot also (unique names are good if not yet unique # cp System*.map* /boot/ After you copied your kernel, build your modules: # make modules Then install modules when that is done: # make modules_install Copy your kernel "configuration file" (the options you selected) (Not required, but will be useful later.) # cp .config /boot/KERNEL-VERSION.config.testing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (5): Build your kernel/modules. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: shortcuts and notes %font "standard", hgap 5, size 3.0 Useful "shortcut": (string together build commands with "&&") # make dep && make bzImage && cp System*.map* /boot/ && cp arch/i386/boot/bzImage /boot/yourcustomekernelname && make modules && make modules_install && cp .config /boot/KERNEL-VERSION.config.testing The shell can use "&&" to only continue the next command if the previous one worked. This will make it easier to "fix" problems before going on to the next step If no errors are encountered, you can return when all are done If they all work, you only need to set up the kernel to work with your boot loader. Some notes about the above: "i386" assumes you have Intel 386, 486, or Pentium* If nothing was configured as module, make modules/modules_install should be omitted %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (5): Install Kernel/modules. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Install Kernel/modules. %font "standard", hgap 5, size 3.0 Modification of your Boot Loader: Two choices for boot loaders Grub Lilo Using LILO: edit /etc/lilo.conf add entries for your new kernel (demo) run lilo to update the MBR (critical! must do this) Using grub: I wont cover (little time, not what I use) Grub is newer Has more user friendly features for installs Do not delete old kernels right away. Test new ones well. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 How? (6): Review Test your kernel. %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left How to build a kernel: Test your kernel. %font "standard", hgap 5, size 3.0 Now reboot your system. Test out your kernel. Check to see if all of your devices work. If something does not work, verify you enabled an options for it. Re-configure a new kernel, rebuild, re-install, retest. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 Questions? %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left Any Questions? With time remaining cover: Sample build of PCMCIA-CS from source Sample problems with NVIDIA drivers (and fix) Sample problems with vmware setup (and fix) Application of sample patch (diff) Simple review "how-to upgrade" with .config %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %bgrad 25 25 256 45 1 "blue" "blue" "white" "white" "white" "white" "blue" "blue" %size 6.5, font "standard", ccolor "black" %center, fore "Black", font "standard", hgap 5, size 6.5 Links %bar "skyblue" 6 15 70 %font "standard", hgap 0 %left Useful Links %font "standard", hgap 5, size 6.5 Kernel Howto: %font "standard", hgap 5, size 2.0 http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Kernel-HOWTO.html %font "standard", hgap 5, size 6.5 lilo howto: %font "standard", hgap 5, size 2.0 http://www.ibiblio.org/pub/Linux/docs/HOWTO/mini/other-formats/html_single/Multiboot-with-LILO.html %font "standard", hgap 5, size 6.5 grub howto: %font "standard", hgap 5, size 2.0 http://www.ibiblio.org/pub/Linux/docs/HOWTO/mini/other-formats/html_single/Multiboot-with-GRUB.html %font "standard", hgap 5, size 6.5 This presentation's home %font "standard", hgap 5, size 2.0 http://mike.passwall.com/nblug/kernel-talk/ http://mike.passwall.com/nblug/kernel-talk/nblug-kernel.mgp patch -p0 < ../patches/linux-2.4.20-ow0/linux-2.4.20-ow0.diff Copyright 2003 Michael Egan. Permission is granted to duplicate this presentation for non-profit use so long as a link remains to this original for people to ensure they have access to the most recent version.