150 likes | 340 Views
Chapter 15 Rebuilding the Linux Kernel. Preparing the Source Code Locating the Source Code Installing the Source Code Read the Documentation Configuring and Compiling the Linux Kernel Cleaning the Source Tree Configuring the Linux Kernel Compiling the Linux Kernel
E N D
Chapter 15 Rebuilding the Linux Kernel • Preparing the Source Code • Locating the Source Code • Installing the Source Code • Read the Documentation • Configuring and Compiling the Linux Kernel Cleaning the Source Tree • Configuring the Linux Kernel Compiling the Linux Kernel • Using Loadable Kernel Modules • Installing the Kernel and Associated Files • Changing lilo.conf (RHEL) • grub.conf • Rebooting • Boot Loader • grub: The Linux Loader • Lilo: The Linux Loader (RHEL) • LOADLlN: A DOS-Based Linux Loader • dmesg: Display Kernel Messages
Boot loaders • grub – update grub.conf after binary is installed • lilo – update lilo.conf and then run lilo command to activate and rewrite your mbr • sysctl utility – modifies kernel parameters while the system is running. Can be used instead of rebuilding the kernel • Use sysctl –a to get a list of parameters • Can be used to modify /proc/sys parameters
Installing a Linux Kernel binary • Run rpm with the –i (not the –U) it is a new kernel not an upgrade • Make sure the new kernel works before you remove the old kernel • Remove the old kernel by removing the files that contain the release number from the /boot and from grub.conf and lilo.conf
Source code • Get a copy of the source code: • Check /usr/src/linux* for kernel source code • Download from kernel.org or Red Hat • Install the source code • Use up2date kernel-source • Read the documentation! • Read the documentation/README file OR • Locate the Linux Kernel-HOWTO
Configuring and Compiling the kernel • Clean the source tree • # make mrproper • Configure the linux kernel • # make config • # LANG=C make menuconfig • # make xconfig
ESTRAVERSION number • Use to prevent overwriting of older/other kernel information • Defaults to release number + custom
Next Compile the new Kernel • Clean the old files away # make clean • Compile the kernel # make bzImage
Using Loadable kernel modules # make modules # make modules_install • depmod - module dependencies • insmod – lists information about loaded modules • lsmod – list loaded modules information • modinfo – list module information • modprobe – loads, unloads modules and dependencies • rmmod – removes modules from kernel
Installing the kernel • Copy the compiled kernel and associated files to the appropriate directory (/ or /boot) • Now execute: # make install • grub – update grub.conf after binary is installed • lilo – update lilo.conf and then run lilo command to activate and rewrite your mbr
Rebooting and boot loaders • grub – update grub.conf after binary is installed, Grand Unified Boot Loader. • lilo – Linux loader, update lilo.conf and run lilo command to activate and rewrite your mbr • loadlin: is a DOS based utility that will load Linux from DOS • See Loadlin+Win95/98/ME mini-HOWTO or • elserv.ffm.fgan.de/~lermen
Use dmesg • Use the dmesg utility to see if there are any problems with the installation • If the install does not work then boot to rescue mode and change your lilo or grub configurations to point back to your old kernel • Try again
grub.conf # grub.conf generated by anaconda # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/hda2 # initrd /initrd-version.img # boot=/dev/hda default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz title Fedora Core (2.4.22-1.2199.nptl) root (hd0,0) kernel /vmlinuz-2.4.22-1.2199.nptl ro root=LABEL=/ rhgb initrd /initrd-2.4.22-1.2199.nptl.img title Fedora Core (2.4.22-1.2115.nptl) root (hd0,0) kernel /vmlinuz-2.4.22-1.2115.nptl ro root=LABEL=/ rhgb initrd /initrd-2.4.22-1.2115.nptl.img