%deffont "standard" xfont "helvetica-medium-r", tfont "verdana.ttf" %deffont "timesitalic" xfont "times-medium-i", tfont "timesi.ttf" %deffont "thick" xfont "helvetica-bold-r", tfont "verdanab.ttf" %deffont "typewriter" xfont "courier-medium-r", tfont "courbd.ttf" %default 1 leftfill, size 2, fore "white", back "darkblue", font "thick" %default 2 size 7, vgap 10, prefix " ", fore "gold" %default 3 size 3, bar "lightblue" 5, vgap 100 %default 4 size 5, fore "white", vgap 30, prefix " ", font "standard" %tab 1 size 5, vgap 40, prefix " ", icon box "green" 30 %tab 2 size 4, vgap 40, prefix " ", icon arc "yellow" 30 %tab 3 size 3, vgap 40, prefix " " %tab 4 size 5, vgap 40, prefix " ", icon delta3 "red" 30 %tab tt font "typewriter" %tab ff font "standard" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %page %nodefault %back "darkblue" %center, size 13, font "thick", fore "gold", vgap 20 Building Your Own Kernel %center, size 5, font "standard", fore "white", vgap 20 Dave O'Neill and Bart Trojanowski dmo@{acm.org, linuxcare.com}, bart@{jukie.net, somanetworks.com} %page Why Build Your Own Kernel? New hardware Weird hardware Speed, stability, bugfixes Don't trust your distribution Want to learn for the sake of it %page So, what do you do? Download the kernel Validate your download Unpack it somewhere Apply any patches Configure the kernel Compile Install Reboot and enjoy %page Download the kernel Use a mirror! list of mirrors on http://kernel.org/mirrors/ Closest is ftp://ftp.ca.kernel.org/pub/linux/kernel/v2.4 Download patches if possible incremental downloads are much smaller keeps mirror providers happy keeps your download time short %page Understanding Kernel Versions So, which kernel do I get? linux-x.y.z x - major version y - minor version z - patch level Stable vs development if y is even then it's stable if y is odd then it's development Latest stable is 2.4.18 %page What about those other versions? The 'extra version' -pre# pre release -rc# release candidate -ac# Alan Cox's patches against the stable tree. Usually more "bleeding edge" -dj# Dave Jones' patches against the devel tree. Usually more "bleeding edge" %page Validating the kernel GPG get the .sign file for your kernel version get "Linux Kernel Archives Verification Key" by doing &tt gpg --keyserver wwwkeys.pgp.net --recv-keys 0x517D0F0E &ff validate the kernel with &tt gpg --verify linux-2.4.18.tar.gz.sign linux-2.4.18.tar.gz %page Unpacking Your Kernel /usr/src/linux-x.y.z preferred location for the kernel sources /usr/src/linux a sym link to the linux-x.y.z directory of the current kernel the steps cd /usr/src rm linux tar xzvf path-to-source-file.tar.gz mv linux linux-x.y.z ln -s linux-x.y.z linux alternatively using .tar.bz2 substitute 'z' with 'j' %page What's inside? Source Code Documentation Configuration Tools Build System %page Patching It's really simple... &tt bunzip2 -c /tmp/patch-foo.bz2 | \ patch -p1 --dry-run &ff Always test with --dry-run first Remember to run 'make mrproper' afterwords Alternatively using gzip substitute 'bunzip2' with 'gunzip' %page Discover what is on your system lspci lsusb lsmod proc files card documentation hieroglyphs on the hardware hardware-manager of the "other" OS Configure.help Write it all down %page Configuring Before you start... ... back up your working configuration! %page make config Simply prompts you for every option Probably not what you want to use %page make menuconfig Screen-based interface (ncurses) Simple/easy to use The interface you want to use most %page make xconfig XWindows-based interface Simple, but slow and cumbersome If you really, really want to use a mouse, here you are %page make oldconfig Line-based like 'make config' Only prompts you for new options Useful for upgrading always backup your last stable .config file! %page Configuration options Next, we will cover... modularity the major categories essential, and merely useful options %page Modules are good! Runtime loading Save on kernel memory Easy to add missing functionality Reduce kernel file size bootloader restrictions %page Modules are bad! Theoretical security risk Easy to add rogue code to the kernel More complicated boot time Slightly more complicated compile %page So, what should you do? If you're a normal user enable modules build some necessary devices into the kernel build everything else as a module If you're a security freak disable modules build everything you need into the kernel %page Major components General setup Block devices Networking ATA/IDE SCSI Character devices Multimedia File systems Sound USB Kernel hacking %page Menuconfig Tutorial Review: What comes before 'menuconfig'? Useful options Going to a new patch-version Reusing a stable configuration Compiling! %page Compiling the kernel make dep make bzImage make modules %page Installing Here, we will cover... Installing the kernel Guidelines Bootloaders Other utilities %page Installing the new code make install make modules_install %page Guidelines Keep a backup kernel around disk space is cheaper than your sanity Keep multiple kernels organized /vmlinuz-* or /boot/vmlinuz-* /System.map-* or /boot/System.map-* %page Bootloaders What the heck is a bootloader? Common bootloaders lilo grub Other tools mkbootdisk %page LILO first 'real' bootloader for Linux requires that you re-run /sbin/lilo after modifications %page GRUB new bootloader understands Linux filesystems no need to reinstall after modifications %page Booting & modules /etc/modules.conf depmod insmod and modprobe %page If you use modules If you need modules at boot-time, you'll need an initial ramdisk (initrd) &tt mkinitrd -f -v /boot/initrd-.img %page %nodefault %back "darkblue" %center, size 8, font "thick", fore "gold", vgap 20 Questions? %page %nodefault %back "darkblue" %center, size 10, font "thick", fore "gold", vgap 20 Now, go and hack!