-->
by Kamran Husain
IN THIS CHAPTER
This chapter details the way to install XFree86 for Linux. This version of X Window
for Linux, called XFree86 Version 3.1.2, is an enhanced version of the X Window System
Version 11 Release 6 with support for many versions of UNIX, including Linux. XFree86
supports considerably more hardware than the video hardware supported by the MIT
standard release of X Window.
Note that even though I try to cover all the bases for installing X11 on your Linux system, I cannot cover all the hardware out there for PCs. In other words, this whole chapter is moot if you happen to have the one video card that this version of XFree86 on Linux will smoke! So read all the items here carefully, and see how they apply to your hardware. You can also check Chapter 2, "Types of Linux," for the listing of the hardware supported by this version of Linux. Check the HOWTO files for Hardware and XFree86 for more up-to-date information.
This chapter covers the following topics:
I also cover ways of finding information on X and XFree86 on the Internet and the ways to upgrade in the future. I discuss some of the problems you might have during installation. The list of supported hardware is found in the docs directory in the CD-ROM attached to the back of this book.
The X Windowing System refers to a windowing system for use on various operating systems such as UNIX and its clones. The X Windowing System with source code was issued by the MIT Consortium along with a set of original copyright notices. The X11 release on which XFree86 (version 3.1.1 or greater) is based is X11 Release 6 (X11R6). The MIT Consortium's work is now done by the X Consortium. The XFree86 project is a team of developers. In an effort to avoid legal problems and be a member of the X Consortium, the XFree86 devel-opment team had to become a bona fide corporation. New releases are provided only for members by the X Consortium. Incorporating paved the path to access to new releases before any official release dates. Read the XFree86-HOWTO in the docs directory for more detailed information.
You have a release of XFree86 on the CD-ROM at the back of this book. The release is located in the /slakware directory in several subdirectories: x1 through x21 (base system), xap1 through xap4 (applications), and xd1 through xd4 (documentation).
The primary source of information for obtaining and installing XFree86 on Linux is the XFree86-HOWTO document, written by Matt Welsh, in the docs directory in the CD-ROM at the back of this book. If you work with XFree86, you cannot do without this document. I have found a wealth of information and answers to a lot of questions about XFree86 in the XFree86-HOWTO document.
The XFree86 distribution consists of several gzipped tar files, some of which are too big to fit on one floppy disk, so you might have to split them with other Linux tools into smaller chunks that do fit on floppies. Not too long ago, everything for Linux was on floppies. I would advise installing from a hard drive or your CD-ROM as the first and easiest choice. Use floppies only if you must.
The main files for the XFree86 distribution you should know about are listed in
Table 21.1.
Table 21.1. Some distribution files for XFree86 on the CD-ROM.
Filename | Description |
x3270.tgz | x3270: IBM host access tool |
x_8514.tgz | An accelerated server for cards using IBM8514 chips |
x_mach32.tgz | An accelerated server for cards using Mach32 chips |
x_mach8.tgz | An accelerated server for cards using Mach8 chips |
x_mono.tgz | A monochrome server |
x_s3.tgz | An accelerated server for cards using S3 chips |
x_svga.tgz | A SuperVGA server |
_vga16.tgz | A server for 16-color EGA/VGA graphics modes |
xconfig.tgz | A collection of 24 sample XF86Config files |
xf_bin.tgz | Basic client binaries |
xf_cfg.tgz | XDM configuration, chooser, and the fvwm executable |
xf_doc.tgz | Documentation and release notes for XFree86 |
xf_kit.tgz | XFree86 Linkkit part 1 |
xf_kit2.tgz | XFree86 Linkkit part 2 |
xf_lib.tgz | Dynamic libraries and configuration files for XFree86 |
xf_pex.tgz | XFree86 PEX distribution |
xfileman.tgz | xfilemanager: easy-to-use file manager (use it!) |
xfm.tgz | xfm: another easy-to-use file manager for X |
xfnt.tgz | Base fonts |
xfnt75.tgz | 75dpi fonts |
xgames.tgz | A collection of games for X |
xgrabsc.tgz | Xgrabsc and Xgrab: screen grabbers |
xinclude.tgz | Header files for X11 programming |
xman1.tgz | Man pages for programs that come with XFree86 |
xman3.tgz | Man pages for the X11 programming libraries |
xpaint.tgz | The xpaint program |
xpm.tgz | The Xpm shared and static libraries version |
xspread.tgz | An X Window spreadsheet |
xstatic.tgz | Static versions of the X libraries |
xv.tgz | John Bradley's XV image viewer |
xv32_a.tgz | Static libraries for developing XView applications |
xv32_sa.tgz | Libraries for developing XView applications that use the shared libraries for XView |
xv32_so.tgz | Shared libraries for XView |
xv32exmp.tgz | Sample programs for XView |
xvinc32.tgz | Include files for XView programming |
xvmenus.tgz | Menus and help files for the OPEN LOOK Window Manager |
xvol32.tgz | XView configuration files, programs, and documentation |
xxgdb.tgz | X Window debugger |
You can also find the most recent versions of these files on most Linux sites. Avoid the temptation to update selected files. Get complete versions if you can. This will protect you from errors resulting from incompatible versions of files.
The version of X you get on the CD-ROM will work with the GNU C libraries. If you upgrade X yourself, you might have to upgrade libc and ld.so yourself. You can get the binary distributions of XFree86 for Linux via anonymous FTP from
tsx-11.mit.edu:/pub/linux/packages/X11/XFree86-VERSION
or
sunsite.unc.edu:/pub/Linux/X11/XFree86-VERSION
where VERSION is the latest version of XFree86. The filenames in these distributions are of the form XF86-ver-name.tar.gz (versions and 3.1.2) or xf86-name-3.1.2.tar.gz where ver is the XFree86 version and name is the name of the package. If you already know which server you need to run, you should not get the *-svr* files. The filename form is XF86-servername.tar.gz, where servername is the name of the server to run.
There are three major requirements for running X on your Linux box: You must have adequate disk space, you need lots of RAM, and you must know whether your display hardware is supported.
Let's tackle the disk-space issue first. The XFree86 distribution takes up about 17MB to 37MB of disk space, depending on how many software components you install. You can save several megabytes of disk space by removing the X servers you do not need. If, however, you plan to install more window managers than normal, you can expect to use about 35MB of disk space.
Now let's look at memory usage. Your computer needs main memory of at least 8MB and virtual memory of at least 16MB (that is, main memory plus swap memory). Yes, it is possible to run X on a 4MB machine, provided that you are very patient and do not care about performance in X applications. In any event, your computer should have 16MB of virtual memory to run X Window. So if you have 4MB of physical RAM, you should have 12MB of swap memory. Be warned, though, that disk swapping is quite slow. For best results, you should install at least 8MB of RAM in your computer. With only 4MB of physical RAM, your X programs will run terribly slowly. If you want to run "memory hog" programs from within X (for example, the C compiler gcc), you should have at least 16MB of main memory and another 16MB of swap memory.
Finally the hardware issue. Just about any SVGA card and monitor combination will work with Linux if you stay within the 640x480 size and 256-color realm. That does not mean that you cannot fry your monitor. I will repeat this [beg] WARNING: [end]An incorrect setting on your monitor can cause your monitor to fry.
Think of it this way (this is in layman's terms). Pixels on your monitor are displayed by a "gun" moving across the viewing area. The more pixels you have on your screen (that is, 800x600 versus 640x480), the faster the gun has to work. Your monitor can work with a certain range of frequencies. By specifying an out-of-range frequency for your monitor hardware, you force it to generate more heat than it is designed to sustain. The extra heat causes a meltdown of sorts. Modern monitors have a specification of frequencies at which they can run the horizontal and vertical refresh rates. When you install an X server, you are basically telling it which type of monitor you want it to run. By specifying a wrong server type, you stand the chance of damaging your hardware.
Not all video chip sets work with X. For information on some of the chip sets that work with X, you can read specific README files in /usr/X386/lib/X11/doc directory. If you can find one for the chip set you use, read it! In these READMEs, the specific options that can be used to configure the server are explained. Currently, there are special READMEs for ATI, Trident, Tseng, Western Digital, Cirrus, and manufacturer-specific chip sets. In most cases, the SVGA server is a good start if you have a newer machine (circa 1994 or later).
More information on these X servers can be found in their man pages. Another place to check is the xFree86-HOWTO file. The HOWTO document in the sunsite and tsx-11 archives might be more up-to-date than any printed information or the information included on the CD-ROM at the back of this book.
When you first install Linux on your machine using setup, you are given an option to install the X11 packages. In most cases, this is the best course of action because the setup script will handle all the hard work for you and get the base system ready for use. Of course, it's a good idea to check whether you meet the hardware requirements as discussed in the preceding section.
If you did not install X11 when you installed Linux, you should use the setup program (in /sbin/) and use the menus. This method, the easiest way to start, is detailed in Chapter 3, "Installing Linux."
The information in this particular section is really useful for you if you are upgrading or re-installing X on your Linux machine. The information in this section is also useful if you want to customize your Linux setup and want to know about files.
Before re-installing XFree86, you should back up all the files you changed. This is necessary if you are already running X. These files might not be used now, but they could hold a lot of information you want to preserve.
The most important of the files you should keep a backup of is your XF86Config file located in the /usr/lib/X11 directory. (Your old XF86Config file will not be deleted with a new installation, but it is a good idea to keep a backup just in case something goes wrong and you get a partial install--for example, if you ran out of disk space or something like that.) The other files include the startx and .xinitrc scripts in /usr/lib/X11. If you were using the standard files from a previous version, don't worry, because you will be getting new ones.
OK, so it's important enough to repeat here: You can install XFree86 on your machine in two ways: one, by using the setup utility, or two, by using a manual procedure. The setup utility is the same menu-driven utility you used in the original installation. To avoid headaches and get to sleep early, use the setup program and menus to perform the installation process. If you really are in a foul mood, proceed with the manual method.
Before beginning either procedure, determine from Table 21.2 the name of the server
type you need. For example, if you are using a color VGA monitor, you should use
the XF86_SVGA server; for monochrome monitors including some EGA monitors, you might
try XF86_Mono. You do not have to choose the server right now, but realize that you
can use only one of these servers at a time.
Table 21.2. Types of servers in XFree86.
Type of Server | Name |
Color SVGA server | XF86_SVGA |
16-color (S)VGA server | XF86_VGA16 |
Monochrome server | XF86_Mono |
S3 accelerated server | XF86_S3 |
8514/A accelerated server | XF86_8514 |
Mach8 accelerated server | XF86_Mach8 |
Mach32 accelerated server | XF86_Mach32 |
Mach32 accelerated server | XF86 Mach64 |
AGX Support | XF86_AGX |
P9000 chipset | XF86_P9000 |
The setup procedure is simple. Choose the SOURCE and TARGET disks, and answer
all the questions you are asked. The only caveat to this procedure is that you must
answer OK for the X server you want and Cancel for all others. If you answer OK to
more than one X server installation query, the last one you answered OK to will be
the default server! The problem is easy to fix. After the installation is over, go
to /usr/bin/X11 and create a link from the file X to the server of your
choice. I chose to copy XF86_SVGA onto X, just because I had disk space
to spare:
# cd /usr/bin/X11 # cp XF86_SVGA X
Now for the hard way. The manual procedure is a bit more involved, and you are liable to make mistakes. It also requires tremendous attention to detail, but it gives you more control over every step. The manual procedure lets you stop and repeat steps instead of going through the complete installation process as in the menu-driven option.
To install the binary distribution manually, perform the following steps:
gzip -rc tarfilename | tar xvof -
The flag (-r) for the gzip command tells it to recursively create all names and paths for the files in the tar file. The -c option sends the contents to the standard output, from where it will be piped to the tar command. The flags for the tar command tell tar to extract (x), being verbose (v), all files while preserving original ownership (o) from the file (f) designated by the standard input (-).
Repeat this step for all the tar files you have in your distribution. Go in sequence for all the disks--do not skip sequences.
After you finish installing XFree86, you have to configure it to match your system. Be sure to use the setup procedure before you attempt this tar procedure--you will save time and effort even if you don't completely control the installation process.
This section covers another one of the more difficult, time-consuming, and frustrating parts of installing XFree86: setting up an XF86Config file.
The full setup procedure is detailed in the file at http://www.xfree86.org/3.2/QuickStart-2.html. The QuickStart-2.html file lists the procedures of using three utilities, XF86Setup, xf86config, and xvidtune, that are available from www.xfree86.org. The exhaustive descriptions will get you started right away if you want to use a menu-driven option. The XF86Setup program provides a text mode to allow manual edits of the configuration files as well.
These utilities are not on the CD-ROM at the back of this book. The information in this chapter will deal with a manual procedure that gets you the same results. It's nice to know what those scripts do, after all!
Generally, you can use the default files that come with XFree86. Log in as root or change to root. Then go to the /usr/lib/x11 directory. Copy XF86Config.eg onto the XF86Config file. You might want to read the file and familiarize yourself with its contents. We will cover customizing this file in the section "The XF86Config File" in Chapter 22, "Configuring XFree86." For the moment, you can live with the defaults.
One final check you should do is to follow the link of /usr/lib/X11/X to the correct server. If you have an SVGA card, this link should be set, via an intermediate link if any, to /usr/bin/X11/XF86_SVGA. If the link does not point to the right server, make it point to the correct server in /usr/bin/X11. You can copy it too, if you want. For example, the X server on my machine (X) is simply a copy of XF86_SVGA.
At this point, you should be able to type xinit at the prompt and have X Window on your monitor. Actually, you have two options in starting X: use the xinit program or use the startx shell script. The advantage to using the xinit program is that you can easily start X Window. The advantage to the startx script is that you can modify the way in which the environment variables are treated in bringing up X. With xinit, you are stuck with the defaults. In most cases, the defaults are what you want anyway. The xinit program executes statements in the order in which they are found in the .xinitrc file.
You can log all the messages that zip by your text screen in a log file with this command in the bash shell:
$ startx 2>&1 > Xstartup.log
This command does not work in the C or tcsh shells. You have to use the following command instead:
% startx >& Xstartup.log
This command gets a log file of the X startup by redirecting all output from stdout and stderr to a log file, Xstartup.log. If you encounter problems, the information in this file will help you determine what happened.
If you encounter any problems, look at the XFree86 documentation files in /usr/X386/lib/X11/doc. These files provide a lot of information on what to do if problems occur. For more information, also look in the FAQs that are mentioned in those files. You can also find a very detailed set of troubleshooting documents at the following URL:
http://www.xfree86.org/3.2/QuickStart-7.html
After you are in the environment of the window manager you chose in the .xinitrc file, you must conform X Window System's way of moving around. See the next few chapters to learn how to work with windows with three window managers: mwm, olwm, and fvwm.
Here's my simple .xinitrc file, which starts two xterminals and the fvwm window manager:
$ cat .xinitrc xterm -name console & xterm -name work & fvwm
Note that all but the last command in the .xinitrc file are run in the background. It's important to run all but the last command in the background. When the last command terminates, so does your X session. Xterms can come and go, but because having a window manager is critical to working with X, killing the window manager equates to killing your X session. It's natural to place the window manager command as the last command in .xinitrc.
To stop X and get back to the text-based console, you have to stop the last application that was in the .xinitrc file. This last application could be the window manager, an xterm, or just about any application. When you quit X Window by stopping this application, you return to your character- or text-based terminal.
Another way to kill the window manager (and X) is to use the Ctrl-Alt-backspace combination. This is not the preferred way of doing things, however. A more graceful way is to have the window manager be the last program started in the .xinitrc file, and exit from it to stop X and get back to the console.
If you simply want a login shell, you can use a virtual terminal instead of stopping X altogether. Press the Ctrl-Alt-F1 keys to get the first virtual terminal. (This brings up the console.) Pressing the Ctrl-Alt-F2 keys brings up the second virtual terminal, and so on. Up to six such virtual terminals were available on my Linux machine. That is, from F1 to F6 gave me six virtual terminals. You might have more or fewer than I had. To get back to X, use the Ctrl-Alt-F7 key.
Several packages are related to X. The rest of the packages exist in the /usr/bin/X11 directory. There are calendars, clocks, bitmap editors, and so on. One of these X application programs you should be aware of is the xsetroot program. With xsetroot, you can set the foreground and background colors, the shape of cursors, the background image, and more. The man pages on xsetroot provide many examples and good documentation.
I list the following window managers explicitly because they have a great influence on the look and feel of X on your display:
Sometimes you need additional libraries to run binary distributions or to compile an application. If you need a library to run binary distributions, you should find a pointer to that library in the README file of that package. If you do not have a pointer, you should look at the /pub/Linux/libs hierarchy at sunsite. Most libraries that work on Linux can be found there. If you cannot find a library there and you have Internet access, follow the instructions on getting information in Appendix A, "FTP Sites and Newsgroups."
You can find an excellent document about XFree86 by Matt Welsh, called "The Linux XFree86 HOWTO" document, on the Internet. This document will make an excellent resource for you as you install XFree86 and will provide far more detailed information than this chapter. Look in the /docs directory for this file: XFree86-HOWTO.
The ASCII version of this HOWTO document was posted regularly to the newsgroups for X and Linux. The latest version can also be found on sunsite.unc.edu in the directory /pub/Linux/docs/HOWTO. This document will almost certainly be more current than any printed material.
For general X questions, you should read the FAQ and the Xt-FAQ. You can get these from ftp.x.org in the directory /R6contrib. Many Linux distributions include most relevant FAQs in the directory /doc. Look on the CD-ROM for this directory.
If you have questions about the XFree86 package and cannot find an answer in the documentation files (XFree86, XF86Config, XF86_* man pages, or the README files in /usr/X386/lib/X11/doc), you might want to post a question to a newsgroup. The appropriate newsgroup for that purpose is comp.windows.x.i386unix. This newsgroup is dedicated to the XFree86 system. If you have a problem with the server and want to post a question to this newsgroup, you should provide enough information for those who want to help you. Here are some things that should be included in all postings concerning server problems:
Send bug reports or questions on XFree86 directly to XFree86@XFree86.org. This is the "official" contact address of the XFree86 Project, Inc.
Here are some other newsgroups that cover X-related topics:
Note that most of these groups have FAQ lists that are posted regularly to these groups. As always with regular postings, you can obtain these from rtfm.mit.edu via anonymous FTP.
Following are some of the problems you might see when you work with XFree86:
This is not an exhaustive list. Read the XFree86-HOWTO document in /docs on the CD-ROM for more information about other video-card problems that are too specific to list here. Also, check the troubleshooting document at http://www.xfree86.org/3.2/QuickStart-7.html.
This section really did not fit in the C++ chapters. You might want to compile some programs for X on your Linux machine. Yes, you can do so. For all practical purposes, XFree86 is a simpler version of X11R6 for your programming needs. You should, however, also read the GCC-FAQ file on the F series of the installation disks and CD-ROM.
You can find this file in the /doc directories of the CD-ROM as well as in the FTP sites at sunsite and tsx-11 before compiling any X programs. Many questions on compiling programs with Linux are answered in this FAQ. Many Linux distributions include the most relevant FAQs in the directory /usr/doc, so you might look there first.
If you have the source code for a program that uses X11, it usually is shipped with an imakefile rather than a makefile.
Imakefiles are files that create makefiles for your system. Discussing imakefiles is beyond the scope of this book; however, you have to work with imakefiles if you work at all with X sources. Just remember the shell script xmkmf, and you should be OK.
Of course, before ever running xmkmf, you should read the documentation that usually comes with such packages.
Run xmkmf in the directory that contains the imakefile. If there is a hierarchy of directories with imakefiles, you usually have to run xmkmf only in the root directory of that hierarchy. The xmkmf command builds all the required makefiles in all directories in the hierarchy.
You then should run the make command with an argument to let make resolve its dependencies with the following command:
$ make depend
After that, you can make the program by running make, and you can install your new utility (usually in /usr/X11R6/bin) by running this command:
$ make install
The installation of the man pages is done like so:
$ make install.man
That's it. Now let's move on to the next chapter to learn how to further customize your X environment.
This section covered one of the hardest things you will have to do when installing a package on Linux: installing XFree86. By using setup or the free utilities from www.xfree86.org, you can make this procedure a bit easier. However, you can do the setup and re-install manually, as well. Naturally, all the possible problems you will face while installing XFree86 are too long to list here. After reading this chapter, though, you should have an idea of what you are getting yourself into and the general steps you must take.
Do not despair if things don't work out just as the instructions say they will. You should be able to look at the configuration files to determine where the problem is and what might be done to fix it. If nothing works despite your best efforts, you have the recourse of knowing where to look for answers in FAQs, newsgroups, and FTP sites on the Internet for HOWTOs and other documents on Linux.