UNIX / Linux Tutorial
2.9.1 Upgrading The Kernel | 2.9.2 Adding A Device Driver To The Kernel
2.9.1 Upgrading The Kernel Upgrading the kernel is a matter of obtaining the kernel sources and compiling them. This is generally a painless procedure, but you can run into problems if you try to upgrade to a development kernel, or upgrade to a new kernel version. The version of a kernel has two parts, the kernel version and patchlevel. As of the time of this writing, the latest stable kernel is version 2.0.33.The2.0 is the kernel version and 33 is the patch level. Odd-numbered kernel versions like 2.1 are development kernels. Stay away from development kernels unless you want to live dangerously! As a general rule, you should be able to upgrade easily to another patch level, but upgrading to a new version requires the upgrade of system utilities which interact closely with the kernel. The Linux kernel sources may be retrieved from any of the Linux FTP sites. On sunsite.unc.edu, for instance, the kernel sources are found in /pub/Linux/kernel, organized into subdirectories by version number. Kernel sources are released as a gzipped tar file. For example, the file containing the 2.0.33 kernel sources is linux-2.0.33.tar.gz. Kernel sources are unpacked in the /usr/src directory, creating the directory /usr/src/linux. It is common practice for /usr/src/linux to be a soft link to another directory which contains the version number, like /usr/src/linux-2.0.33. This way, you can install new kernel sources and test them out before removing the old kernel sources. The commands to create the kernel directory link are: # cd /usr/src # mkdir linux-2.0.33 # rm -r linux # ln -s linux-2.0.33 linux # tar xzf linux-2.0.33.tar.gz When upgrading to a newer patchlevel of the same kernel version, kernel patch files can save file transfer time because the kernel source is around 7MB after being compressed by gzip. To upgrade from kernel 2.0.31 to kernel 2.0.33, you would download the patch files patch-2.0.32.gz and patch-2.0.33.gz, which can be found at the same FTP site as the kernel sources. After you have placed the patches in the /usr/src directory,. apply the patches to the kernel in sequence to update the source. One way to do this would be: # cd /usr/src # gzip -cd patch-2.0.32.gz j patch -p0 # gzip -cd patch-2.0.33.gz j patch -p0 After the sources are unpacked and any patches have been applied, you need to make sure that three symbolic links in /usr/include are correct for your kernel distribution. To create these links use the commands: # cd /usr/include # rm -rf asm linux scsi # ln -s /usr/src/linux/include/asm-i386 asm # ln -s /usr/src/linux/include/linux linux # ln -s /usr/src/linux/include/scsi scsi After you create the links, there is no reason to create them again when you install the next kernel patch or a newer kernel version. In order to compile the kernel, you must have the gcc C compiler installed on your system. gcc version 2.6.3 or a more recent version is required to compile the 2.0 kernel. First cd to /usr/src/linux. The command make config prompts you for a number of configuration options. This is the step where you select the hardware that your kernel will support. The biggest mistake to avoid is not including support for your hard disk controller. Without the correct hard disk support in the kernel, the system won't even boot. If you are unsure about what a kernel option means, a short description is available by pressing ? and Enter . Next, run the command make dep to update all of the source dependencies. This is an important step. make clean removes old binary files from the kernel source tree. The command: make zImage compiles the kernel and writes it to /usr/src/linux/arch/i386/boot/zImage. Linux kernels on Intel systems are always compressed. Sometimes the kernel you want to compile is too large to be compressed with the compression system that make zImage uses. A kernel which is too large will exit the kernel compile with the error message: Kernel Image Too Large. If this happens, try the command make bzImage, which uses a compression system that supports larger kernels. The kernel is written to /usr/src/linux/arch/i386/boot/bzImage. Once you have the kernel compiled, you need to either copy it to a boot floppy ( with a command like "cp zImage /dev/fd0") or install the image so LILO will boot from your hard drive. 2.9.2 Adding A Device Driver To The Kernel Support for the Iomega Zip drive, like many other devices, is not generally compiled into stock Linux distribution kernels—the variety of devices is simply too great to support all of them in a usable kernel. However, the source code for the Zip parallel port device driver is included as part of the kernel source code distribution. This section describes how to add support for an Iomega Zip parallel port drive and have it co-exist with a printer connected to a different parallel port. You must have installed and successfully built a custom Linux kernel, as described in the previous section. Selecting the Zip drive ppa device as a kernel option requires that you answer Y to the appropriate questions during the make config step, when you determine the configuration of the custom kernel. In particular, the ppa device requires answering "Y" to three options: SCSI support? [Y/n/m] Y SCSI disk support? [Y/n/m] Y IOMEGA Parallel Port Zip Drive SCSI support? [Y/n/m] Y After you have successfully run make config with all of the support options you want included in the kernel, then run make dep, make clean, and make zImage to build the kernel, you must tell the kernel how to install the driver. This is done via a command line to the LILO boot loader. As described in section 4.2.1, the LILO configuration file, /etc/lilo.conf has "stanzas" for each operating system that it knows about, and also directives for presenting these options to the user at boot time. Another directive that LILO recognizes is "append=", which allows you to add boot-time information required by various device drivers to the command line. In this case, the Iomega Zip ppa driver requires an unused interrupt and I/O port address. This is exactly analogous to specifying separate printer devices like LPT1 : and LPT2 : under MS-DOS. For example, if your printer uses the hexadecimal (base 16) port address 0x378 (see the installation manual for your parallel port card if you don't know what the address is) and is polled (that is, it doesn't require an IRQ line, a common Linux configuration), you would place the following line in your system's /etc/lilo.conf file: append="lp=0x378,0". It is worth noting that Linux automatically recognizes one /dev/lp port at boot time, but when specifying a custom port configurations, the boot-time instructions are needed. The "0" after the port address tells the kernel not to use a IRQ (interrupt request) line for the printer. This is generally acceptable because printers are much slower than CPUs, so a slower method of accessing I/O devices, known as polling, where the kernel periodically checks the printer status on its own, still allows the computer to keep up with the printer. However, devices that operate at higher speeds, like serial lines and disks, each require an IRQ, or interrupt request, line. This is a hardware signal sent by the device to the processor whenever the device requires the processor's attention; for example, if the device has data waiting to be input to the processor. The processor stops whatever it is doing and handles the interrupt request of the device. The Zip drive ppa device requires a free interrupt, which must correspond to the interrupt that is set on the printer card that you connect the Zip drive to. At the time of this writing, the Linux ppa device driver does not support "chaining" of parallel port devices, and separate parallel ports must be used for the Zip ppa device and each printer. To determine which interrupts are already in use on your system, the command: # cat /proc/interrupt displays a list of devices and the IRQ lines they use. However, you also need to be careful not to use any automatically configured serial port interrupts as well, which may not be listed in the /proc/interrupt file. The Linux Documentation Project's Serial HOWTO, available from the sources listed in Appendix A, describes in detail the configuration of serial ports. You should also check the hardware settings of various interface cards on your machine 3 by opening the machine's case and visually checking the jumper settings if necessary, to ensure that you are not co-opting an IRQ line that is already in use by another device. Multiple devices fighting for an interrupt line is perhaps the single most common cause of non-functioning Linux systems. A typical /proc/interrupt file looks like: 0: 6091646 timer 1: 40691 keyboard 2: 0 cascade 4: 284686 + serial 13: 1 math error 14: 192560 + ide0 The first column is of interest here. These are the numbers of the IRQ lines that are in use on the system. For the ppa driver, we want to choose a line which is not listed. IRQ 7 is often a good choice, because it is seldom used in default system configurations. We also need to specify the port address which the ppa device will use. This address needs to be physically configured on the interface card. Parallel I/O ports are assigned specific addresses, so you will need to read the documentation for your parallel port card. In this example, we will use the I/O port address 0x278, which corresponds to the LPT2: printer port under MS-DOS. Adding both the IRQ line and port address to our boot-time command line, above, yields the following statement as it would appear in the appropriate stanza of the /etc/lilo.conf file: append="lp=0x378,0 ppa=0x278,7" These statements are appended to the kernel's start-up parameters at boot time. They ensure that any printer attached to the system does not interfere with the Zip drive's operation. Of course, if your system does not have a printer installed, the "lp=" directive can and should be omitted. After you have installed the custom kernel itself, as described in section 2.2.1, and before you reboot the system, be sure to run the command: # /sbin/lilo to install the new LILO configuration on the hard drive's boot sector.
1.1 Introduction 1.2.10 Referring To Home Directories 1.3.4 Copying Files
1.6 Exploring The File System 1.8 Wildcards 1.9.3 Pipes 1.10.3 Permissions Dependencies
1.12.4 Stopping And Restarting Jobs 1.13.3 Inserting Text 1.13.9 Including Other Files
1.14.3 Shell Initialization Scripts System Administration 2.3.1 The /etc/imitate file
2.4 Managing File Systems 2.6 Managing Users 2.6.5 Groups 2.7.2 gzip and compress
2.8.3 Making Backups To Tape Devices 2.9.1 Upgrading The Kernel
2.9.3 Installing A Device Driver Module
BOOK: LINUX QUICK COMMAND REFERENCE
http://personal.atl.bellsouth.net/~psadler
© copyright KnowledgeWorks, Inc. (2001)