% Linux Installation and Getting Started    -*- TeX -*-
% upgrade.tex
% Copyright (c) 1992, 1993 by Matt Welsh <mdw@sunsite.unc.edu>
%
% This file is freely redistributable, but you must preserve this copyright 
% notice on all copies, and it must be distributed only as part of "Linux 
% Installation and Getting Started". This file's use is covered by the 
% copyright for the entire document, in the file "copyright.tex".

\section{Upgrading and Installing New Software}
\label{sec-sysadm-upgrade}

\index{software!upgrading|(}
\index{software!installing|(}
Another duty of the system administrator is upgrading and installing 
new software. 

The Linux community is very dynamic. New kernel releases come out every
few weeks, and other software is updated almost as often. Because of
this, new Linux users often feel the need to upgrade their systems 
constantly to keep up the the rapidly changing pace. Not only is this
unnecessary, it's a waste of time: to keep up with all of the changes
in the Linux world, you would be spending all of your time upgrading and
none of your time using the system.

So, when should you upgrade? Some people feel that you should upgrade 
when a new distribution release is made---for example, when Slackware comes
out with a new version. Many Linux users completely reinstall their
system with the newest Slackware release every time. This, also, is a waste
of time. In general, changes to Slackware releases are small. Downloading
and reinstalling 30 disks when only 10\% of the software has been actually
modified is, of course, pointless. 

The best way to upgrade your system is to do it by hand: only upgrade
those software packages which you know that you should upgrade. This
scares a lot of people: they want to know what to upgrade, and how, and
what will break if they don't upgrade. In order to be successful with
Linux, it's important to overcome your fears of ``doing it yourself''---
which is what Linux is all about. In fact, once you have your system
working and all software correctly configured, reinstalling with
the newest release will no doubt wipe all of your configuration and
things will be broken again, just as they were when you first installed
your system. Setting yourself back in this manner is unnecessary---all
that is needed is some know-how about upgrading your system, and how to
do it right. 

You'll find that when you upgrade one component of your
system, other things should not break. For example, most of the
software on my system is left over from an ancient 0.96 MCC Interim
installation. Yet, I run the newest version of the kernel and libraries
with this software with no problem. For the most part, senselessly
upgrading to ``keep up with the trend'' is not important at all. This
isn't MS-DOS or Microsoft Windows. There is no important reason to 
run the newest version of all of the software. If you find that you
would like or need features in a new version, then upgrade. If not,
then don't. In other words, only upgrade what you have to, and when
you have to. Don't just upgrade for the sake of upgrading. That will waste
a lot of time and effort trying to keep up.

The most important software to upgrade on your system is the kernel,
the libraries, and the {\tt gcc} compiler. These are the three
essential parts of your system, and in some cases they all depend on
each other for everything to work successfully. Most of the other
software on your system does not need to be upgraded periodically. 

\subsection{Upgrading the kernel}
\index{kernel!upgrading}
Upgrading the kernel is simply a matter of getting the sources and
compiling them yourself. You must compile the kernel yourself in
order to enable or disable certain features, as well as to ensure
that the kernel will be optimized to run on your machine. The
process is quite painless.

\index{kernel!sources for}
The kernel sources may be retrieved from any of the Linux FTP sites
(see Section~\ref{app-ftp} for a list). On {\tt sunsite.unc.edu},
for instance, the kernel sources are found in {\tt /pub/Linux/kernel}.
Kernel versions are numbered using a version number and a patchlevel.
For example, kernel version 0.99 patchlevel 11 is usually written
as {\tt 0.99.pl11}, or just {\tt 0.99.11}. 

The kernel sources are released as a gzipped tar file\footnote{Often,
a patch file is also released for the current kernel version which
allows you to patch your current kernel sources from the last patchlevel
to the current one (using the program {\tt patch}). In most cases, 
however, it's usually easier to install the entire new version of the
kernel sources.}. For example,
the file containing the 0.99.pl11 kernel sources is 
{\tt linux-0.99.11.tar.gz}. 

Unpack this tar file from the
directory {\tt /usr/src}; it creates the directory
{\tt /usr/src/linux} which contains the kernel sources. You should
delete or rename your existing {\tt /usr/src/linux} before
unpacking the new version.

Once the sources are unpacked, you need to make sure that two
symbolic links in {\tt /usr/include} are correct. To create these
links, use the commands
\begin{tscreen}
\# {\em ln -sf /usr/src/linux/include/linux /usr/include/linux} \\
\# {\em ln -sf /usr/src/linux/include/asm /usr/include/asm}
\end{tscreen}
Once you have created these links once, there is no reason to create
them again when you install the next version of the kernel sources.
(See Section~\ref{sec-manage-links} for more about symbolic links.)

\index{kernel!compiling}
Note that in order to compile the kernel, you must have the {\tt gcc}
and {\tt g++} C and C++ compilers installed on your system. 
You may need to have the most recent versions of these compilers: 
see Section~\ref{sec-upgrade-gcc}, below,
for more information. 

To compile the kernel, first {\tt cd} to {\tt /usr/src/linux}.
Run the command {\tt make config}. This command will prompt you for
a number of configuration options, such as what filesystem types
you wish to include in the new kernel. 

Next, edit {\tt /usr/src/linux/Makefile}. Be sure that the
definition for {\tt ROOT\_DEV} is correct---it defines the
device used as the root filesystem at boot time. The usual
definition is 
\begin{tscreen}
ROOT\_DEV = CURRENT
\end{tscreen}
Unless you are changing your root filesystem device, there is no
reason to change this. 

Next, run the command {\tt make dep} to fix all of the
source dependencies. This is a very important step.

\index{kernel!compiling compressed image}
Finally, you're ready to compile the kernel. The command
{\tt make Image} will compile the kernel and leave the new kernel
image in the file {\tt /usr/src/linux/Image}. Alternately, the
command {\tt make zImage} will compile a compressed kernel image,
which uncompresses itself at boot time and uses less drive space.

Once you have the kernel compiled, you need to either copy it to a
boot floppy (with a command such as ``{\tt cp Image /dev/fd0}'') 
or install it using LILO to boot from your hard drive. See
Section~\ref{sec-lilo} for more information. 

\subsection{Upgrading the libraries}\label{sec-upgrade-libs}
\index{libraries!upgrading}
As mentioned before, most of the software on the system is compiled
to use shared libraries, which contain common subroutines shared
among different programs. 

If you see the message
\begin{tscreen}
Incompatible library version
\end{tscreen}
when attempting to run a program, then you need to upgrade to
the version of the libraries which the program requires. Libraries
are back-compatible; that is, a program compiled to use an older
version of the libraries should work with the new version of the
libraries installed. However, the reverse is not true. 

The newest version of the libraries can be found on the Linux FTP sites.
On {\tt sunsite.unc.edu}, they are located in {\tt /pub/Linux/GCC}.
The ``release'' files there should explain what files you need to
download and how to install them. Briefly, you should get the files
{\tt image-{\em version}.tar.gz} and {\tt inc-{\em version}.tar.gz}
where {\em version} is the version of the libraries to install, such
as {\tt 4.4.1}. These are gzipped tar files; the {\tt image} file contains
the library images to install in {\tt /lib} and {\tt /usr/lib}. The
{\tt inc} file contains include files to install in {\tt /usr/include}

The {\tt release-{\em version}.tar.gz} should explain the installation
procedure in detail (the exact instructions vary for each release). 
In general you need to install the library {\tt .a} and {\tt .sa}
files in {\tt /usr/lib}. These are the libraries used at compilation
time.

In addition, the shared library image files,
{\tt libc.so.{\em version}} are installed in {\tt /lib}. These
are the shared library images loaded at runtime by programs
using the libraries. Each library has a symbolic link using the major
version number of the library in {\tt /lib}. 

For example, the {\tt libc} library version 4.4.1 has a major version
number of {\tt 4}. The file containing the library is 
{\tt libc.so.4.4.1}. A symbolic link of the name {\tt libc.so.4} is
also in {\tt /lib} pointing to this file. You need to change this
symbolic link when upgrading the libraries. For example,
when upgrading from {\tt libc.so.4.4} to {\tt libc.so.4.4.1}, you need
to change the symbolic link to point to the new version. 

\blackdiamond It is very important that you change the symbolic link
in one step, as given below. If you somehow delete the symbolic link
{\tt libc.so.4}, then programs which depend on the link (including
basic utilities like {\tt ls} and {\tt cat}) will stop working. 
Use the following command to update the symbolic link {\tt libc.so.4}
to point to the file {\tt libc.so.4.4.1}:
\begin{tscreen}
\# {\em ln -sf /lib/libc.so.4.4.1 /lib/libc.so.4}
\end{tscreen}
You also need to change the symbolic link {\tt libm.so.{\em version}}
in the same manner. If you are upgrading to a different version of
the libraries substitute to appropriate filenames above. The library
release notice should explain the details. (See 
Section~\ref{sec-manage-links} for more information about symbolic
links.)

\subsection{Upgrading {\tt gcc}}\label{sec-upgrade-gcc}
\index{gcc@{\tt gcc}!upgrading}
The {\tt gcc} C and C++ compiler is used to compile software on your
system, most importantly the kernel. The newest version of {\tt gcc}
is found on the Linux FTP sites. On {\tt sunsite.unc.edu}, it is
found in the directory {\tt /pub/Linux/GCC} (along with the libraries).
There should be a {\tt release} file for the {\tt gcc} distribution
detailing what files you need to download and how to install them.
 
\subsection{Upgrading other software}
Upgrading other software is usually just a matter of downloading the
appropriate files and installing them. Most software for Linux is
distributed at gzipped tar files, including either sources or binaries
or both. If binaries are not included in the release, you may need
to compile them yourself; usually, this means typing {\tt make}
in the directory where the sources are held. 

\index{software!where to find releases}
Reading the USENET newsgroup {\tt comp.os.linux.announce} for
announcements of new software releases is the easiest way to find
out about new software. Whenever you are looking for software on 
an FTP site, downloading the {\tt ls-lR} index file from the FTP
site and using {\tt grep} to find the files in question is the
easiest way to locate software. If you have {\tt archie} available
to you, it can be of assistance as well\footnote{If you don't have
{\tt archie}, you can telnet to an {\tt archie} server such as 
{\tt archie.rutgers.edu}, login as ``{\tt archie}'' and use the 
command ``{\tt help}''}. See Appendix~\ref{app-info} for more
details. 

One handy source of Linux software is the Slackware distribution disk
images. Each disk contains a number of {\tt .tgz} files which are
simply gzipped tar files. Instead of downloading the disks, you can
download the desired {\tt .tgz} files from the Slackware directories
on the FTP site and install them directly. If you run the Slackware
distribution, the {\tt setup} command can be used to automatically
load and install a complete series of disks. 

Again, it's usually not a good idea to upgrade by reinstalling with
the newest version of Slackware, or another distribution. If you reinstall 
in this way, you will no doubt wreck your current installation, including 
user directories and all of your customized configuration. The best way
to upgrade software is piecewise; that is, if there is a program that
you use often that has a new version, upgrade it. Otherwise, don't bother.
Rule of thumb: If it ain't broke, don't fix it. If your current software
works, there's no reason to upgrade. 
\index{software!upgrading|)}
\index{software!installing|)}
