Linux Kernel (Topic 2.201)

Review Questions

  1. You find that the make modules command fails repeatedly when trying to compile a new kernel. What can you do to solve this problem?

  2. You need to know the CPU type on a system before updating the kernel. Which of the files in the /proc directory can tell you what CPU you are using?

  3. You want to learn more about the PCI-based hardware in a typical Intel-based computer so that you can update the kernel. What command can you use?

  4. The older computer you are using does not support the make bzImage command. What commands can you execute if you want to create a smaller kernel?

  5. You have just compiled a new kernel, but it will not boot. You intend on booting a kernel on the second partition of the first hard drive. Currently, the GRUB configuration file reads as follows:

    title Test Kernel (2.6.0)
                root (hd0,2)
                kernel /boot/bzImage-2.6.1 ro root=LABEL=/
                initrd /boot/initrd-2.6.1.img

    What change needs to be made?

  6. When building and installing modules during the process of creating a new kernel, when do you need to be root?

Answers

  1. Use the make mrproper command, then make clean. If these two commands do not solve the problem, you are using the wrong configuration file for your CPU type. Go to the /usr/src/linux/configs/ kernelname directory and copy the correct file.

  2. /proc/cpuinfo.

  3. /bin/lspci -vv.

  4. Any of the following: make zImage, make zdisk, or make zlilo.

  5. Change root (hd0,2) to read root (hd0,1). GRUB uses a zero-based counting system, so the second partition of the system is indicated by a 1, not a 2.

  6. Only when installing the modules.

Exercise

Following is an exercise for creating a custom 2.6 kernel. It contains many separate steps.

  1. Make sure that you know your hardware. Use the lspci command with the -vv option to determine the type of hardware that you have. Then view the output of the /proc/cpuinfo command to find the type of CPU your system is using.

  2. Verify that you have all of the software components installed that will help you build and install a kernel. Components vary between the 2.4 series and 2.6 series of kernels. Components and utilities include:

    procps
    module-init-tools
    reiserfsprogs
    jfsutils
    binutils
    pcmcia-cs
    util-linux
    module-init-tools
    quota-tools
    nfs-utils
    Gnu C
    Gnu make
    e2fsprogs
    xfsprogs
    oprofile
  3. Once you have verified you have these components and utilities, you can obtain the source files from http://www.kernel.org or from your system's distribution repositories. For example, you can obtain the kernel files on a Red Hat or Fedora system using RPM. Novell SUSE systems provide Yast (or RPM, if you wish), and you can use apt or Synaptic for Debian-based systems.

    At this stage, you can also patch the kernel, if you wish. Once you have finished patching, you can configure the kernel. During this stage of the process, you have to determine whether you want a static kernel or a modular kernel. Most systems default to modular kernels.

  4. Once you have made this decision, find the Makefile and edit it to contain unique information for your kernel. Change the EXTRAVERSION = -1 portion of the Makefile to a unique value.

  5. Then back up the hidden .config file that is in the ../linux file of your source tree. Do this by copying the .config file to another location. Then type make mrproper to begin with a fresh installation.

  6. Now you are ready to use the make command to create a 2.6 kernel. You have a choice between the make config, make oldconfig, make menuconfig, and make xconfig commands. The make config command does not provide a menu. Rather, it runs a program that asks you a long series of questions that you have to answer. make oldconfig reads the existing file and makes the changes you have indicated. Use make oldconfig only if you have made minor changes. The make menuconfig command presents an ncurses-based menu that is considerably more user-friendly than the list of questions presented by the make config command. Finally, the make xconfig command is the most user-friendly, but may not be available on your system.

  7. Choose the options that are best for your system. You will see that the choices are grouped into several sections (e.g., General Setup, Loadable Module Support, Device Drivers). Go through each option and choose the features you want. When you are finished configuring your options, save them and exit the program.

  8. You are now ready to build the kernel. Type the following:

    make bzImage
  9. If you have chosen to build a modular kernel (the most common choice), you must then build the modules:

    make modules
  10. Now, become root and install the modules:

    su root
    make modules_install
  11. Exit root.

  12. Now you need to create an initial ramdisk image, so that the system can boot the hard drive and begin initialization. If, for example, you are creating a kernel named 2.6.10-5-686, issue the following command to create the accompanying ramdisk image:

    mkinitrd /boot/2.6.10-5-686
  13. Now copy the new kernel and system.map file you have created to the /boot directory. Following is an example:

    $ cp arch/i686/boot/bzImage /boot/bzImageYOUR_KERNEL_VERSION
    $ cp System.map /boot/System.map-YOUR_KERNEL_VERSION
    $ ln -s /boot/System.map-YOUR_KERNEL_VERSION /boot/System.map

    Notice how the final command creates a symbolic link from your new system.map file to the /boot/System.map file.

  14. After you are finished, edit your boot loader. If you are using GRUB, edit the /boot/grub/menu.lst file or possibly the /etc/grub.conf file, which is usually a symbolic link to the /boot/grub/menu.lst file. If, for example, you have created a new kernel named 2.6.10-5-686, create the following entry for GRUB:

    title           New, kernel 2.6.10-5-686
    root            (hd0,1)
    kernel          /boot/vmlinuz-2.6.10-5-686 root=/dev/hda2 ro quiet splash
    initrd          /boot/initrd.img-2.6.10-5-686
    savedefault
    boot

    You do not have to run any command to enable this file; GRUB will read the menu.lst or grub.conf file automatically at boot time. If you experience any problems, you can edit the configuration file on the fly at boot time, as described later in this chapter.

    Alternatively, if you are using LILO to use the same kernel, alter your /etc/lilo.conf file as follows:

    boot=/dev/hda
            map=/boot/map
            install=/boot/boot.b
            default=new-2.6.10-5-686
            keytable=/boot/us.klt
            lba32
            prompt
            timeout=50
            message=/boot/message
            menu-scheme=wb:bw:wb:bw
            image=/boot/vmlinuz
                label=linux
                root=/dev/hda3
                append=" ide1=autotune ide0=autotune"
                read-only
    
            image=/boot/vmlinuz-2.6.10-5-686
                label=test-2.6.10-5-686
                root=/dev/hda1
                read-only

    Then run the lilo command to update the boot sequence.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset