Running a Perfect Internet Site with Linux 16-05141.doc

Notice: This material is excerpted from Running A Perfect Internet Site with Linux, ISBN: 0-7897-0514-1. The electronic version of this material has not been through the final proof reading stage that the book goes through before being published in printed form. Some errors may exist here that are corrected before the book is published. This material is provided "as is" without any warranty of any kind.

Copyright ©1996, Que Corporation. All rights reserved. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 West 103rd Street, Indianapolis, IN 46290 or at support@mcp .com.

Chapter 16 - Upgrading Your Software

You'll upgrade your site's software much more often than you'll upgrade its hardware. By software, I'm referring to everything from the kernel itself to your server programs, including new applications that you add for yourself or your users. Kernels change especially often with updates sometimes coming out every few days.

In this chapter, you learn how to:

Upgrading Your Kernel

With some software, an upgrade means completely replacing what you have, including getting a whole new version of the source. As discussed in chapter 1, "Why Create Your Own Site with Linux," the Linux kernel advances in small steps involving patches. Each time a fix or improvement is added, a patch is released. You then apply this patch to the source code.

All of the backup warnings apply heavily when you upgrade your kernel. Do backups before doing any major system changes!

Deciding Whether To Apply Patches

You won't always want to apply patches to bring your kernel up to the version you want. This is especially true if you haven't patched it in a while and are a number of patches behind. Sometimes it's easier to grab a whole new version of the kernel source than to have to apply ten small patches in a row.

It's not necessary to apply patches immediately when they come out. In fact, it's not always wise to do so. Unless you absolutely need to upgrade in order to get a driver for a piece of hardware, you probably don't want to do so more often than every six months or so. This is simply because you will likely run into problems you need to diagnose and fix with most patches, and if you have paying customers you don't want to risk having to take your site down for a major kernel problem from a new patch.

Also, if you need three or more patches to be able to move to the new kernel version you want, you may as well download the whole kernel source for that version. Using a large number of patches can get messy.

When a new patch comes out, an announcement is posted to the newsgroup comp.os.linux.announce (and often most of the other Linux groups as well).

If you're not sure of exactly what kernel version number you're using, type uname -r at the prompt to display it.

Take note of what the patch announced is declared to fix, what drivers it adds and, in some cases, what it's known to break (shown in the changes directory listed below if you didn't see the announcement on a newsgroup). In fact, if you don't need any of the new items, it's good to wait and see if anyone complains that something you need is now broken. If so, you'll want to wait for a new patch to fix that item and then apply both of them, or wait awhile through a number of patches until a feature you want is offered.

All of the kernel and patch items are available via FTP at one of its mirror sites-in a subdirectory of /pub/Linux/kernel. The kernel directory contains (according to the INDEX file) the following:Table 16.x The Contents of /pub/Linux/kernel on Sunsite

Item	Description
COPYING	The Linux kernel copyright notice
INSTALL	Installation instructions for the kernel
changes/	List of what's changed with each kernel release
changes-new/	Changes to recent kernels
cipher.tar.gz	Driver for cipher 9000 ATC-16 card w/ M995 9-track tape
config/	Various configuration utilities
images/	Floppy disk images for booting and installing Linux
kdebug-1.1.tgz	Package to allow simple kernel debugging
kernel.txt.gz	Some unofficial docs on kernel compiling
kguide-0.2.tgz	Help on compiling a new kernel
linux-1.0.patch.alpha.gz	Patch from ALPHA 1.0 to 1.0
linux-1.0.tar.gz	Source tree for Linux 1.0
menu2.01.linux.tar.gz	Menu based shell tool w/ user customizations
modules-1.1.87.tar.gz@	Utilities for making/using kernel modules
old/	Old versions of the kernel - history mostly
patches/	Various kernel enhancements and fixes
pcmcia/	Support for PCMCIA card & card services
scend-0.5.tar.gz	Full-screen editor for structured configuration data.
sound/	Support for SoundBlaster, PRO-16, GUS, etc.
tapes/	Various tape backup drivers
v1.0/	Version 1.0 patches (obsolete)
v1.1/	Version 1.1 developers track (obsolete)
v1.2/	Version 1.2 and patches (stable)
v1.3/	Latest development kernels (ALPHA)

Getting the Full Kernel Source

If you want to start from scratch and grab a full version of kernel source, first you need to move your old source directory to another location. Your kernel source, if you have it on your system, is in the directory /usr/src/linux. As root, simply move this to another directory (e.g., /usr/src/linux-old).

You could also have no real /usr/src/linux directory, and instead put kernel source into directories related to the version (e.g., /usr/src/linux-1.2.13) and then make a soft link from the current version's directory to /usr/src/linux.

Now, set up your source for compilation. Log in as root and FTP to Sunsite or your favorite mirror site.

Change to the directory /pub/linux/kernel.

Then, change to the directory v1.2 unless Linux has reached version 1.4 at the time that you are following these instructions; then, change to v1.4.

If an experimental kernel has options you want to use, it's often safe to try it out. Ask around on the Linux newsgroups and see if the problems it has will effect you, and be sure to test it out for a while before trusting it completely. If you choose to use one, you'll be going to 1.3 or 1.5.

Currently, the latest kernel version is 1.2.13, so I'll download the file linux-1.2.13.tar.gz. This is about a 2.3M file, so depending on the speed of your connection, it might take a while.Then, move the file to /usr/src, gunzip and untar it.

If you're short on hard drive space, then go ahead and delete the old kernel when you're sure the new one is working fine.

Getting Patches To Apply to Kernel Source

If you want to add a patch or a few patches to the source you already have instead of downloading a whole new source version, follow these instructions. Log in as root, and FTP to Sunsite or your favorite mirror site.

Change to the directory /pub/linux/kernel, and then to the directory v1.2 (same version notation as in previous section). All of the files that start with patch are the patch files. You must apply all patches below the one you want in the end, as they make changes to your source code. For example, if you want to apply patch 1.2.5, you need to get patches 1.2.1 through 1.2.5. Then, just move the patch files to /usr/src.

Applying Patches to Source

If you downloaded patches, you need to apply them to the source code before you can compile it. To apply your patches, log in as root and change to /usr/src. You must apply the patches in order. To actually apply a patch, type zcat patchname.gz | patch -p0 (e.g., zcat patch-2.1.1.gz | patch -p0).

You must apply the patches in numerical order. Each one makes changes to the source code, and so the source must be in the full state it's expecting.

Apply the next patch in line. Continue applying patches until you've reached the last one you need. If the patch fails, double-check and make sure you have the patch for exactly the next kernel after the source you're using. You can even look through the patch file and see the changes that are being made, and make them by hand.

If you can't seem to solve the patch problem, you can always download the full version of the source for the kernel you want to compile.

Configuring the Source To Fit Your Needs

Now, it's time to configure the kernel so it's compiled for your site's specific needs. Because the instructions here are for when this book was written, I recommend you read the README file in your new /usr/src/linux directory. In the "INSTALLING the kernel" section, you will find detailed instructions on how to proceed.

I'll walk you through the compiling of this kernel: version 1.2.13. First, I'll make sure that everything is properly in place, as follows:

  1. Change to the directory /usr/include.
  2. Type rm -rf linux to remove any old C header files.
  3. Type ln -s /usr/src/linux/include/linux linux to make a soft link that points your system to the new C header files included with the new kernel source.
  4. Type rm -rf asm to remove any old assembler header files.
  5. Type ln -s /usr/src/linux/include/asm-i386 asm to make a soft link that points your system to the new assembler header files included with the new kernel source.
  6. Change to /usr/src/linux.
  7. Type make mrproper to clean up any additional extra source that could cause problems with your compilation.

Now, to configure the kernel to suit your needs, do the following as root:

  1. Change to /usr/src/linux if you're not already there.
  2. Type make config to start the script that walks you through specific configuration options. From here, I will walk you through the questions I got and the answers I gave in this particular version.

When in doubt over whether you need a feature or not, it's generally safe to choose y for yes. Then at least, you won't have to recompile to add a needed feature. If you choose no for something, it's not included in the compiled kernel, and you'll have to go back and compile it all over again! The main difference is the more things you say yes to, the larger the kernel is.
  1. Kernel math emulation: Answer n for no unless you are running a 386 without a coprocessor on this machine.
  2. Normal floppy disk support: Answer y for yes so your kernel will support standard PC floppy disks.
  3. Normal (MFM/RLL disk and IDE disk/cdrom support: Answer y if you need support for any of this hardware. Otherwise, answer n.
  4. Now you're given a few options, and you only want to choose one of them, as follows:

The hardware discussed here is explained in more detail in chapter 2.
  1. XT hard disk support: If you intend to use this equipment, press y. If not, press n.
  2. Networking support: Because you're running an Internet site, choose y.
  3. Limit memory to low 16M: This item is directly related to some 386 machines. If you have a 386 machine and it has a DMA controller that doesn't properly handle over 16M of RAM, then choose y. Otherwise, choose n.
  4. 10. PCI bios support: If the computer you're working on uses PCI BIOS, choose y. Otherwise, choose n. If you choose yes, you'll be asked for more information on your PCI bridge organization.
  5. 11. System V IPC: Perl uses this option to allow processes to talk to one another. Choose y.
  6. 12. Kernel support for ELF binaries: You installed an all-ELF Slackware version, so choose y.
  7. 13. Use -m486 flag for 486-specific optimizations: If the computer you're working on is a 486 or Pentium machine, choose y. It will optimize things to run on its processor.
  8. 14. Set version information on all symbols for modules: This tells modules to check your kernel version and, if the module's version doesn't match, it won't run. Often, a module will work okay even if it's older than the kernel you're using, so this can be a pain as it requires you to compile modules every time you update your kernel. However, if you don't want to take the chance of running into problems, go ahead and choose y. Otherwise, choose n.

A module, or loadable module, is a piece of kernel code that isn't always needed. Instead, it's saved out into a piece of code that can be loaded into memory when it's necessary (e.g., FTAPE). This helps to keep down on how much RAM your system kernel eats up on a regular basis.
  1. 15. TCP/IP networking: Your computers need this option to speak to the Internet (which uses the TCP/IP protocol), so choose y.
  2. 16. IP forwarding/gatewaying: You need this on your main server, but not on other machines. Choose the appropriate answer.
  3. 17. IP multicasting: This is the capability of a machine to have multiple IP addresses. If you don't need this option, choose n.
  4. 18. IP firewalling: You won't need this option because if you want to use a firewall, you'll install Socks, which doesn't require it. Choose n.
  5. 19. IP accounting: Choose n.
  6. 20. You should leave the following options at their defaults:
  1. 21. SCSI support: If you have any SCSI hardware, choose y. It will ask you further configuration questions. If you don't have SCSI hardware, choose n.
  2. 22. Network device support: Choose y. You need this to connect to your provider.
  3. 23. Dummy net driver: This allows you to set up "dummy addresses," such as aliases for a machine named "ftp" that physically doesn't exist. Choose y to be able to use this.
  4. 24. SLIP (serial line) support: If you want to be able to use SLIP or allow your users to use SLIP, choose y.
  5. 25. CSLIP compressed headers: Choose y. This will make your SLIP connections more secure.
  6. 26. 16 channels instead of 4: By default, you can have only four simultaneous SLIP connections. If you want to be able to offer more than four, choose y. Otherwise, choose n.
  7. 27. PPP support: If you're using PPP, choose y.
  8. 28. PLIP support: This allows you to connect computers using parallel ports. You can only connect two machines in this way because computers generally only have one parallel port. Choose n unless you intend to use this.
  9. 29. Do you want to be offered ALPHA test drivers: Because you're running a site, you probably don't want to risk running experimental drivers unless it's a driver that isn't available otherwise. It doesn't automatically add them, so if you're not sure, choose y. Otherwise, choose n.
  10. 30. Now you'll be asked which networking card you're using. Choose n for all of those you're not using and y for the one you are:
  1. 31. Now you'll be asked if you need a number of CD-ROM drivers, none of which are for SCSI or IDE/ATAPI drives. Answer n for anything you don't have and y for anything you do:
  1. 32. Now you are asked which file systems you want to support:
  1. 33. You'll now be asked which character devices (mouse, printer, etc.) you want to use:
  1. 34. Sound card support: If you have a sound card on the machine you're configuring the kernel for, choose y. If you do, you will be asked for specific configuration information involving your sound card.
  2. 35. The Kernel hacking section: Answer n to Kernel profiling support to avoid any problems with your site.
  3. 36. Don't be startled if your system briefly compiles something! If it does, that's because there are some special configuration options it can continue with to make your life easier down the road. For example, if you said you have a sound card, it compiles a small program to configure sound support.
  4. 37. The configuration program exits. Look through the Makefile and make sure that it's what you want.

Creating Your Kernel

Now, you can create your kernel! This requires the following steps:

  1. Log in as root.
  2. Change to /usr/src/linux.
  3. Type make dep to make sure key files are in the right place.
  4. Type make clean to be assured that everything is up to date.
  5. Now, to compile the kernel itself, type make zImage.

The speed it takes to compile a kernel depends on how fast your machine is and how much RAM it has. On a 386 machine, it can take over an hour, while on a Pentium or high end 486, it may take less than 30 minutes. You'll probably want to recompile your kernel when you have something else you can do while you wait.
  1. Move /vmlinuz to /vmlinuz2 so you don't overwrite your previous kernel.
  2. Edit the file /etc/lilo.

Instead of completely replacing the old kernel at the moment, I'm going to add a reference for the new one. This way, I can reboot with the new kernel and test it to make sure it works. Then, if it works satisfactorily, I can come back and remove the old one.
  1. Locate the section

The value assigned to root may be different if you didn't use /dev/hda1 initially. Just make sure the original root reference and the following one match.
  1. Copy this section and create a new one below it.
  2. 10. Change it to read
  3. image = /zImage2
  4. label = linux-new
  5. root = /dev/hda1
  6. 11. Save and exit the file.
  7. 12. Type lilo to install the new settings.

Now, when you boot with LILO, you can type linux-new instead of linux and boot with the new kernel. When you're confident it's stable, erase the old kernel (the old zImage file) and move zImage2 to zImage.

Upgrading Your Servers

When new versions of servers come out, it often means that they have-or are meant to have-fewer bugs than previous versions. This in itself is a good reason to upgrade. There might also be new features added that are useful to you, as in more functions being automated, or even more functions available. Also, if new standards have come out, a new server will be released to support those standards.

To actually upgrade a server, first download the new source code for the server. You should be able to find its home location in its own documentation files. If you can't, try looking on Sunsite first. Then, move it to /usr/src.

Next, take a look through the information files (e.g., README) that came with the source to see what you need to do before compilation. The differences between the previous version and the new version could be minor or massive, depending on how many bug fixes there are, how many new features were added, how standards have changed, and how the interface has changed.

Back up your old server in case you find you would rather return to it, or the new server simply doesn't work.

Follow the precompilation instructions carefully. After all, if there are any options that need to be configured before you compile the program, you don't want to forget about them until you're almost finished setting up! Then you'd have to turn around and start all over. Then, once you've set it up for compilation, compile the program according to the instructions in the README files.

As you've seen throughout this book, once you get the program compiled there is often more configuration to do. Follow the instructions in the information files on any post-compilation configuration necessary.

Test the new server and make sure it does what you expected and wanted it to do. If you don't like the new server, erase it. If you do like it, erase the old server. Though, you may want to keep the old one around for a week or so in case it takes a while for problems with the new server to show themselves.

Adding New Applications

Every once in awhile, you'll see a new application that you decide you want for your site, a particular machine, or even a particular user (could be an IRC client or server, a game, a WAIS server, graphics viewer for a graphics-capable machine where you don't have to use X-Windows, fax programs, or any other number of applications available on the Internet).

To find most of the applications, go to Sunsite in /pub/Linux and look through the directories there. You can also find the Linux Software Map on the Linux Documentation Project pages, which is a catalog of applications available for Linux and where to find them.

The difficulty or ease of installing this application depends on the application itself and how diligently you read the instructions before going at it.

The basic instructions for installing a new application are similar to the instructions listed in the previous section.

Download the application, and take a look through the information files (e.g., README) that came with it. It may have come as source, or as a binary. If it came as source, see what configuration you need to do before compilation, follow the instructions, and compile the program according to the instructions in the README files.

Follow the instructions in the information files on any further setup, whether you got the file as source or as a binary. Then, test the program to make sure it does what you want and does it the way you want it done.

QUE Home Page

For technical support for our books and software contact

Copyright ©1996, Que Corporation