<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<book><bookinfo><title>The Complete FreeBSD</title><author><firstname>Greg</firstname><surname>Lehey</surname></author><copyright><year>2001</year><holder>Greg Lehey</holder></copyright></bookinfo>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<chapter id="CFBSD-nchintro"><title>Introduction</title>

<para>FreeBSD is a state of the art operating system derived from AT&amp;T's <emphasis>UNIX</emphasis>
operating system.
<footnote>

<para>FreeBSD no longer contains any AT&amp;T proprietary code, so it may be distributed
freely.  See page <xref linkend="CFBSD-history"/> for more details.
</para>
</footnote>
It runs on the following platforms:
</para>
<itemizedlist>
<listitem>

<para>Personal computers based on the Intel i386 CPU architecture, including the 386,
486 and Pentium families of processors, and compatible CPUs from AMD and Cyrix.
</para>
</listitem>
<listitem>

<para>The
Compaq/Digital Alpha processor.
</para>
</listitem>
<listitem>

<para>In addition, significant development efforts are going towards porting FreeBSD
to other hardware, notably the MIPS R4000 series and the Sun Sparc.
</para>
</listitem>
</itemizedlist>

<para>This book only describes the released versions of FreeBSD for Intel and Alpha
processors.
</para>
<sect1>
<title>How to use this book</title>

<para>This book is divided into five parts:
</para>
<itemizedlist>
<listitem>

<para>The first part, chapters <xref linkend="CFBSD-nchintro"/> to <xref linkend="CFBSD-nchports"/>, tells you how to install
FreeBSD and what to do if things go wrong.
</para>
</listitem>
<listitem>

<para>Chapters <xref linkend="CFBSD-nchxsetup"/> to <xref linkend="CFBSD-nchemulate"/> introduce you to life with FreeBSD,
including setting up optional features, building custom kernels and keeping up
to date with FreeBSD.
</para>
</listitem>
<listitem>

<para>Chapters <xref linkend="CFBSD-nchnetintro"/> to <xref linkend="CFBSD-nchmicronet"/> introduce you to FreeBSD's rich
network support.
</para>
</listitem>
<listitem>

<para><indexterm><primary>man</primary><secondary>pages</secondary></indexterm>
Starting on page <xref linkend="CFBSD-partii"/> you'll find selected <emphasis>man pages</emphasis>, the definitive
documentation for most of the system.  I have chosen those pages most likely to
be needed before the system is installed, or while upgrading.  Once the system
is running, it's easier to read them on-line.
</para>
</listitem>
<listitem>

<para>The appendices start on page <xref linkend="CFBSD-first-appendix"/> and include a large amount of
reference material.
</para>
</listitem>
</itemizedlist>

<para>In more detail, we'll discuss the following subjects:
</para>
<itemizedlist>
<listitem>

<para>In the rest of this chapter, we'll look at what FreeBSD is, what you need to run
it, and what resources are available:
</para>
</listitem>
</itemizedlist>
<orderedlist>
<listitem>

<para>On page <xref linkend="CFBSD-features"/> we'll look at FreeBSD's features.
</para>
</listitem>
<listitem>

<para>Starting on page <xref linkend="CFBSD-history"/> we'll look at how FreeBSD came to be.
</para>
</listitem>
<listitem>

<para>On page <xref linkend="CFBSD-unixclones"/> we'll compare FreeBSD to other free UNIX-like operating
systems.
</para>
</listitem>
<listitem>

<para>On page <xref linkend="CFBSD-docco"/> we'll look at other sources of information about FreeBSD.
</para>
</listitem>
<listitem>

<para>On page <xref linkend="CFBSD-FreeBSD-community"/>, we'll look at the world-wide FreeBSD community.
</para>
</listitem>
<listitem>

<para>On page <xref linkend="CFBSD-support"/> we'll consider what kinds of support are available for
FreeBSD.
</para>
</listitem>
<listitem>

<para>Finally, on page <xref linkend="CFBSD-bsdd"/> we'll look at the BSD's emblem, the dćmon on the cover
of this book.
</para>
</listitem>
</orderedlist>
<itemizedlist>
<listitem>

<para><xref linkend="CFBSD-chconcepts"/>, discusses the installation requirements and theoretical
background of installing FreeBSD.  You don't <emphasis>really</emphasis> need to read this
chapter, but it'll make you feel a whole lot more confident if you do.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chthirded"/>, describes the changes that have taken place in FreeBSD since the
introduction of version 3.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chquickinstall"/>, presents a quick installation overview.  If you're
reasonably experienced, this may be all you need to install FreeBSD.  Otherwise,
read on...
</para>
</listitem>
<listitem>

<para>In <xref linkend="CFBSD-chinstall"/>, we'll walk through a typical installation.  Read this chapter
if you are installing FreeBSD on a disk by itself.
</para>
</listitem>
<listitem>

<para>In <xref linkend="CFBSD-chshareinstall"/>, we'll look at the differences you will encounter if you
install FreeBSD on a system which already contains another operating system.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chproblems"/>, discusses what to do if you run into problems during or after
installation.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chports"/>, describes the thousands of free software packages which you can
optionally install on a FreeBSD system.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chxsetup"/>, tells you how to set up XFree86, the Intel 386 architecture
implementation of the industry standard X11 Windowing System.
</para>
</listitem>
<listitem>

<para>In <xref linkend="CFBSD-chxtheory"/>, we'll look at the theory behind getting X11 working.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chunixref"/>, presents a number of aspects of FreeBSD which are of interest
to newcomers (particularly from a Microsoft environment), in particular the
concepts of <emphasis>users</emphasis> and <emphasis>processes</emphasis>.  We'll also consider the basics
of using the <emphasis>shell</emphasis>, as well as the importance of timekeeping.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chstarting"/>, describes how to start and stop a FreeBSD system and all the
things you can do to customize it.  In particular, we'll look at the more common
configuration files and what they should contain.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chfilesys"/>, contains information about the FreeBSD directory structure and
device names.  You'll find the section on device names (starting on page
<xref linkend="CFBSD-devices"/>) interesting even if you're an experienced UNIX hacker.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chdisks"/>, describes how to format and integrate hard disks, and how to handle
disk errors.
</para>
</listitem>
<listitem>

<para>FreeBSD provides professional, reliable data backup services as part of the base
system.  Don't ever let yourself lose data because of inadequate backup
provisions.  Read all about it in <xref linkend="CFBSD-chtapes"/>.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chprinters"/>, describes the BSD spooling system and how to use it both on
local and networked systems.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chdesktop"/>, describes the user's viewpoint of FreeBSD.  UNIX has come a long
way in the last few years&mdash;make yourself comfortable.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chbuild"/>, discusses how to build a customized version of FreeBSD.
</para>
</listitem>
<listitem>

<para>In <xref linkend="CFBSD-chcurrent"/>, we'll discuss how to ensure that your system is always running
the most appropriate version of FreeBSD.
</para>
</listitem>
<listitem>

<para>FreeBSD can run software written for a number of other operating systems.  Read
about it in <xref linkend="CFBSD-chemulate"/>.
</para>
</listitem>
<listitem>

<para>Starting at <xref linkend="CFBSD-chnetintro"/>, we'll look at the Internet and the more important
services.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chnetsetup"/>, describes how to set up local networking.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chisp"/>, discusses the issues in selecting an Internet Service Provider (ISP)
and establishing a presence on the Internet.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chmodems"/>, discusses serial hardware and the prerequisites for PPP and SLIP
communications.
</para>
</listitem>
<listitem>

<para>In <xref linkend="CFBSD-chppp"/>, we look at FreeBSD's two PPP implementations and what it takes to
set them up.
</para>
</listitem>
<listitem>

<para>In <xref linkend="CFBSD-chslip"/>, we look at two older serial communication protocols.
</para>
</listitem>
<listitem>

<para>In <xref linkend="CFBSD-chdns"/>, we'll consider the use of names on the Internet.
</para>
</listitem>
<listitem>

<para>Security is an increasing problem on the Internet.  In <xref linkend="CFBSD-chfirewall"/>, we'll
look at some things we can do to improve it.  We'll also look at <emphasis>IP
aliasing</emphasis>, since it goes hand-in-hand with firewalls.
</para>
</listitem>
<listitem>

<para>Networks sometimes become <emphasis>notwork</emphasis>s.  In <xref linkend="CFBSD-chnetdebug"/>, we'll see what
we can do to solve network problems.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-chnfs"/>, describes Sun's classic system for sharing file systems between
networked computers.
</para>
</listitem>
<listitem>

<para>We'll look at the basic network access programs in <xref linkend="CFBSD-chbasics"/>.
</para>
</listitem>
<listitem>

<para>Despite the World Wide Web, traditional two-way personal communication is still
very popular.  We'll look at it in <xref linkend="CFBSD-chemail"/>.
</para>
</listitem>
<listitem>

<para>Most people think the World Wide Web <emphasis>is</emphasis> the Internet.  We'll look at
both client and server access in <xref linkend="CFBSD-chwww"/>.
</para>
</listitem>
<listitem>

<para>Computers can send faxes a lot more cheaply and flexibly than fax machines.
We'll look at how to do that with FreeBSD in <xref linkend="CFBSD-chfax"/>.
</para>
</listitem>
<listitem>

<para>Before Microsoft and Novell discovered the Internet, they created a number of
less powerful networking systems, some of which are still in use.  We'll look at
them in <xref linkend="CFBSD-chmicronet"/>.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-terminology"/>, explains some of the terms used in this book.
</para>
</listitem>
<listitem>

<para>In <xref linkend="CFBSD-appcommands"/>, we'll look at Microsoft's MS-DOS commands and how to perform
similar functions with FreeBSD.
</para>
</listitem>
<listitem>

<para><xref linkend="CFBSD-biblio"/>, suggests some books for further reading.
</para>
</listitem>
<listitem>

<para>Finally, <xref linkend="CFBSD-licenses"/>, contains the licence agreements under which FreeBSD
software is distributed.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect1>
<sect1>
<title>FreeBSD features</title>

<para><anchor id="CFBSD-features"/>
As we have seen, FreeBSD runs on Intel and compatible processors.  It is derived
from ``Berkeley UNIX'', the flavour of UNIX developed by the Computer Systems
Research Group at the University of California at Berkeley and previously
released as the <emphasis>Berkeley Software Distribution</emphasis> (BSD) of UNIX.
</para>
<note>

<para>For copyright reasons, FreeBSD may not be called UNIX.  You be the judge of how
much difference this makes.
</para>
</note>

<para>FreeBSD provides you with
many advanced features previously available only on much more expensive
computers, including:
</para>
<itemizedlist>
<listitem>

<para>FreeBSD on the Intel platform is a <emphasis>32-bit operating system</emphasis>.  Unlike some
commercial so-called ``32 bit operating systems'', it contains no 16-bit code
whatsoever.  The Intel i386 architecture runs significantly faster in 32 bit
mode than in 16 bit mode, so this translates to a significantly higher
performance.
</para>
</listitem>
<listitem>

<para>On the Alpha platform, FreeBSD is a 64 bit operating system.
</para>
</listitem>
<listitem>

<para><indexterm><primary>preemptive</primary><secondary>multitasking</secondary></indexterm>
<indexterm><primary>multitasking</primary></indexterm>
FreeBSD uses <emphasis>preemptive multitasking</emphasis> with dynamic priority adjustment to
ensure smooth and fair sharing of the computer between applications and users.
</para>
</listitem>
<listitem>

<para><indexterm><primary>multiuser</primary></indexterm>
FreeBSD is a <emphasis>multi-user system</emphasis>: many people can use a FreeBSD system
simultaneously for unrelated purposes.  The system shares peripherals such as
printers and tape drives properly between all users on the system.
</para>
</listitem>
<listitem>

<para><indexterm><primary>TCP/IP</primary></indexterm>
FreeBSD provides complete <emphasis>TCP/IP networking</emphasis> including SLIP, PPP, NFS and
NIS support.  This means that your FreeBSD machine can interoperate easily with
other systems and also act as an enterprise server, providing vital functions
such as NFS (remote file access) and e-mail services, or putting your
organization on the Internet with WWW, ftp, routing and firewall (security)
services.  In addition, the Ports Collection includes software for communicating
with proprietary protocols&mdash;see <xref linkend="CFBSD-chmicronet"/> for more details.
</para>
</listitem>
<listitem>

<para><indexterm><primary>memory</primary><secondary>protection</secondary></indexterm>
<emphasis>Memory protection</emphasis> ensures that neither applications nor users can
interfere with each other.  If an application crashes, it cannot affect other
running applications.
</para>
</listitem>
<listitem>

<para><indexterm><primary>X</primary><secondary>Window System</secondary></indexterm>
<indexterm><primary>X11R6</primary></indexterm>
<indexterm><primary>graphical</primary><secondary>user interface</secondary></indexterm>
<indexterm><primary>GUI</primary></indexterm>
<indexterm><primary>XFree86</primary></indexterm>
FreeBSD includes the <emphasis>XFree86</emphasis> implementation of the industry standard
<emphasis>X Window System</emphasis> (<emphasis>X11R6</emphasis>) <emphasis>graphical user interface</emphasis>
(<emphasis>GUI</emphasis>).
</para>
</listitem>
<listitem>

<para><indexterm><primary>binary</primary><secondary>compatibility</secondary></indexterm>
<indexterm><primary>compatibility</primary><secondary>SCO</secondary></indexterm>
<indexterm><primary>compatibility</primary><secondary>BSD/OS</secondary></indexterm>
<indexterm><primary>compatibility</primary><secondary>Linux</secondary></indexterm>
<indexterm><primary>compatibility</primary><secondary>NetBSD</secondary></indexterm>
<indexterm><primary>compatibility</primary><secondary>386BSD</secondary></indexterm>
<indexterm><primary>SCO</primary><secondary>compatibility</secondary></indexterm>
<indexterm><primary>BSD/OS</primary><secondary>compatibility</secondary></indexterm>
<indexterm><primary>NetBSD</primary><secondary>compatibility</secondary></indexterm>
<indexterm><primary>386BSD</primary><secondary>compatibility</secondary></indexterm>
<indexterm><primary>Linux</primary><secondary>compatibility</secondary></indexterm>
FreeBSD can run most programs built for SCO UNIX and UnixWare, Solaris on the
i386 platform, BSD/OS, NetBSD, 386BSD, and Linux.
</para>
</listitem>
<listitem>

<para>The FreeBSD ports and packages collection includes over two thousand
ready-to-run applications.
</para>
</listitem>
<listitem>

<para>Thousands of additional and easy-to-port applications are available on the
Internet.  FreeBSD is source code compatible with most popular commercial UNIX
systems and thus most applications require few, if any, changes to compile.
Most freely available software was developed on BSD-like systems.  As a result,
FreeBSD is one of the easiest platforms you can port to.
</para>
</listitem>
<listitem>

<para><indexterm><primary>virtual</primary><secondary>memory</secondary></indexterm>
<indexterm><primary>memory</primary><secondary>virtual</secondary></indexterm>
Demand paged <emphasis>virtual memory</emphasis> (<emphasis>VM</emphasis>) and ``merged VM/buffer cache''
design efficiently satisfies applications with large appetites for memory while
still maintaining interactive response to other users.
</para>
</listitem>
<listitem>

<para><indexterm><primary>shared</primary><secondary>libraries</secondary></indexterm>
<indexterm><primary>libraries</primary><secondary>shared</secondary></indexterm>
<emphasis>Shared libraries</emphasis> (the UNIX equivalent of Microsoft's DLLs) provide for
efficient use of disk space and memory.
</para>
</listitem>
<listitem>

<para>The base system contains a full complement of C, C++ and Fortran development
tools.  Many additional languages for advanced research and development are also
available in the ports and packages collection.
</para>
</listitem>
<listitem>

<para><indexterm><primary>source</primary><secondary>code</secondary></indexterm>
FreeBSD comes with <emphasis>source code</emphasis> for the entire system, so you have the
greatest degree of control over your environment.
</para>
</listitem>
<listitem>

<para><indexterm><primary>online</primary><secondary>documentation</secondary></indexterm>
<indexterm><primary>documentation</primary><secondary>online</secondary></indexterm>
<indexterm><primary>man</primary><secondary>pages</secondary></indexterm>
<indexterm><primary>online</primary><secondary>handbook</secondary></indexterm>
<indexterm><primary>handbook</primary><secondary>online</secondary></indexterm>
Extensive <emphasis>online documentation</emphasis>, including traditional <emphasis>man pages</emphasis> and
a hypertext-based <emphasis>online handbook</emphasis>.
</para>
</listitem>
</itemizedlist>

<para></para>

<para>FreeBSD is based on the 4.4BSD-Lite release from the Computer Systems Research
Group (CSRG) at the University of California at Berkeley, and carries on the
distinguished tradition of BSD systems development.  Building on the excellent
base provided by CSRG, the FreeBSD Project has spent many thousands of hours
fine tuning the system for maximum performance and reliability in real-life load
situations.  FreeBSD's features, performance and reliability compare very
favourably with those of commercial operating systems.
</para>

<para>The applications to which FreeBSD can be put are truly limited only by your own
imagination.  From software development to factory automation, inventory control
to azimuth correction of remote satellite antennae: with FreeBSD, you can do
just about anything that you could do with a commercial UNIX product.  FreeBSD
benefits significantly from thousands of high quality applications developed by
research centers and universities around the world, often available at little or
no cost.  Commercial applications are also available and appearing in greater
numbers every day.
</para>

<para>Because the source code for FreeBSD itself is generally available, the system
can easily be customized for special applications or projects, in ways not
generally possible with operating systems from commercial vendors.  You can
easily start out small with an inexpensive 386 class PC and upgrade as your
enterprise grows.  Here is just a sampling of some of the applications in which
people currently use FreeBSD:
</para>

<para></para>
<itemizedlist>
<listitem>

<para><indexterm><primary>Internet</primary><secondary>Services</secondary></indexterm>
<emphasis>Internet Services</emphasis>: the Internet grew up around Berkeley UNIX.  The
original TCP/IP implementation, released in 1982, was based on 4.2BSD, and
nearly every current TCP/IP implementation has borrowed from it.  FreeBSD
includes this implementation, the most mature TCP/IP available at any price.
This makes it an ideal platform for a variety of Internet services such as FTP
servers, World Wide Web servers, Gopher servers, Electronic Mail servers, USENET
News servers, and Bulletin Board Systems.  Need a new router?  A DNS name
server?  A firewall to keep people out of your internal network?  FreeBSD can
easily turn that unused 386 or 486 PC sitting in the corner into an advanced
router with sophisticated packet filtering capabilities.
</para>
</listitem>
<listitem>

<para><emphasis>Education:</emphasis> Are you a student of computer science or a related engineering
field?  There is no better way of learning about operating systems, computer
architecture and networking than the hands on, under the hood experience that
FreeBSD can provide.  A number of freely available CAD, mathematical and graphic
design packages also make it highly useful to those whose primary interest in a
computer is to get <emphasis>other</emphasis> work done.
</para>
</listitem>
<listitem>

<para><emphasis>Research:</emphasis> With source code for the entire system available, FreeBSD is an
excellent platform for research in operating systems as well as other branches
of computer science.  FreeBSD's freely available nature also makes it possible
for remote groups to collaborate on ideas or shared development without having
to worry about special licensing agreements or limitations on what may be
discussed in open forums.
</para>
</listitem>
<listitem>

<para><indexterm><primary>X</primary><secondary>Window workstation</secondary></indexterm>
<emphasis>X Window workstation:</emphasis> FreeBSD makes an excellent choice for an
inexpensive X terminal solution, either using the freely available XFree86
server or one of the excellent commercial servers provided by XI Graphics,
Inc.
<footnote>

<para><indexterm><primary>XI</primary><secondary>Graphics</secondary></indexterm>
See <emphasis>http://www.xig.com</emphasis> for further information about XI Graphics.
</para>
</footnote>
Unlike an X terminal, FreeBSD allows many applications to be run locally, if
desired, thus relieving the burden on a central server.  FreeBSD can even boot
``diskless'', making individual workstations even cheaper and easier to
administer.
</para>
</listitem>
<listitem>

<para><indexterm><primary>software</primary><secondary>development</secondary></indexterm>
<emphasis>Software Development:</emphasis> The basic FreeBSD system comes with a full
complement of development tools included the renowned GNU C/C++ compiler and
debugger.
</para>

<para></para>
</listitem>
</itemizedlist>

<para></para>
</sect1>
<sect1>
<title>A little history</title>

<para><anchor id="CFBSD-history"/>
FreeBSD is a labour of love: big commercial companies produce operating systems
and charge lots of money for them.  The FreeBSD team produces a
professional-quality operating system and gives it away.  That's not the only
difference.
</para>

<para><indexterm><primary>QDOS</primary></indexterm>
<indexterm><primary>Quick</primary><secondary>and Dirty Operating System</secondary></indexterm>
In 1981, when IBM introduced their Personal Computer, the microprocessor
industry was still in its infancy.  The PC had a minimum of 16 kB and a maximum
of 64 kB on-board memory.  UNIX wouldn't run on this hardware, so Microsoft, who
at the time marketed their own version of UNIX, went looking for something
simpler.  The ``operating system'' they chose was correspondingly primitive: a
clone of Digital Resarch's successful CP/M operating system, written by Tim
Patterson of Seattle Computer Products and originally called <emphasis>QDOS</emphasis>
(<emphasis>Quick and Dirty Operating System</emphasis>).
At the time, it seemed just the
thing: it would run just fine without a hard disk (in fact, the original PC
didn't <emphasis>have</emphasis> a hard disk, not even as an option), and it didn't use up
too much memory.  The only thing that they really had to do was to change the
name.  Since the operating system was for IBM, they named it PC-DOS after
DOS/360, an operating system of the mid-60s.  Microsoft marketed its version
under the name MS-DOS.
</para>

<para><indexterm><primary>CSRG</primary></indexterm>
<indexterm><primary>Berkeley</primary><secondary>UNIX</secondary></indexterm>
By this time, a little further down the West Coast of the USA, the Computer
Systems Research Group (<emphasis>CSRG</emphasis>)
of the University of California at
Berkeley had just modified AT&amp;T's UNIX operating system to run on the new DEC
VAX 11/780 machine, which sported virtual memory, and had turned their attention
to implementing some new protocols for the ARPANET: the so-called <emphasis>Internet
Protocols</emphasis>.  The version of UNIX that they had developed was now sufficiently
different from AT&amp;T's system that it had been dubbed <emphasis>Berkeley UNIX</emphasis>.
</para>

<para><indexterm><primary>Fast</primary><secondary>File System</secondary></indexterm>
<indexterm><primary>UNIX</primary><secondary>File System</secondary></indexterm>
As time went on, both MS-DOS and UNIX evolved.  Before long MS-DOS was modified
to handle hard disks&mdash;not well, but it handled them, and for the PC users, it
was so much better than what they had before that they ignored the
inefficiencies.  After all, the PC gave you your own hard disk on your desk, and
you didn't have to share it with all the other people in the department.
Microsoft even tried to emulate the UNIX directory structure, but only succeeded
in implementing the concept of nested directories.  At Berkeley, they were
developing a higher performance disk subsystem, the <emphasis>Fast File System</emphasis>,
now known as the <emphasis>UNIX File System</emphasis>.
</para>

<para>By the late 80s, it was evident that Microsoft no longer intended to
substantially enhance MS-DOS.  New processors with support for multitasking and
virtual memory had replaced the old Intel 8088 processor of the IBM PC, but they
still ran MS-DOS by emulating the 8088 processor, which was now completely
obsolete.  The 640 kB memory limit of the original PC, which once appeared
bigger than anybody would ever need, became a serious problem.  In addition,
people wanted to do more than one thing at a time with their computers.
</para>

<para>A solution to both problems was obvious: move to the 32 bit address mode of the
new Intel 80386 processor and introduce real multitasking, which operating
systems on larger machines had had for decades.  Of course, these larger
machines were only physically larger.  The average PC of 1990 had more memory,
more disk and more processing power than just about any of the large computers
of the 70s.  Nevertheless, Microsoft still hasn't solved these problems for its
desktop ``operating system'', Windows 95.
</para>

<para><indexterm><primary>Research</primary><secondary>Version</secondary></indexterm>
<indexterm><primary>Berkeley</primary><secondary>Software Distribution</secondary></indexterm>
<indexterm><primary>System</primary><secondary>V</secondary></indexterm>
<indexterm><primary>Santa</primary><secondary>Cruz Operation</secondary></indexterm>
UNIX, on the other hand, was a relatively mature operating system at the time
when the PC was introduced.  As a result, Microsoft-based environments have had
little influence on the development of UNIX.  UNIX development was determined by
other factors: changes in legal regulations in the USA between 1977 and 1984
enabled AT&amp;T first to license UNIX to other vendors, noticably Microsoft, who
announced XENIX in 1981, and then to market it itself.  AT&amp;T developed System
III in 1982, and System V in 1983.  The differences between XENIX and System V
were initially small, but they grew: by the mid-80s, there were four different
versions of UNIX: the <emphasis>Research Version</emphasis>, used only inside AT&amp;T, the
<emphasis>Berkeley Software Distribution</emphasis> (BSD) from Berkeley, the commercial
<emphasis>System V</emphasis> from AT&amp;T, and XENIX, which no longer interested Microsoft, and
was marketed by the company which had developed it, the <emphasis>Santa Cruz
Operation</emphasis>, or <emphasis>SCO</emphasis>.
</para>

<para><indexterm><primary>USL</primary></indexterm>
<indexterm><primary>UNIX</primary><secondary>Systems
 </secondary></indexterm>
<indexterm><primary>Berkeley</primary><secondary>Software Design
 </secondary></indexterm>
<indexterm><primary>BSDI</primary></indexterm>
One casualty of UNIX's maturity was the CSRG in Berkeley.  UNIX was too mature
to be considered an object of research, and the writing was on the wall: the
CSRG would close down.  Some people decided to port Berkeley UNIX to the
PC&mdash;after all, SCO had done it years ago.  In the Berkeley tradition, however,
they wanted to give it away.  The industry's reaction was not friendly.  In
1992, AT&amp;T's subsidiary <emphasis>USL</emphasis> (<emphasis>UNIX Systems Laboratories</emphasis>) filed a
lawsuit against <emphasis>Berkeley Software Design Inc.</emphasis> (<emphasis>BSDI</emphasis>), the
manufacturer of the BSD/386 and (later) the BSD/OS operating systems, both very
similar to FreeBSD, for alleged distribution of AT&amp;T source code in violation of
licence agreements.  They subsequently extended the case to the University of
California at Berkeley.  The suit was settled out of court, and the exact
conditions were not all disclosed.  The only one that became public was that
BSDI would migrate their source base to the newer 4.4BSD-Lite sources, a thing
that they were preparing to do in any case.  Although not involved in the
litigation, it was suggested to FreeBSD that they should also move to
4.4BSD-Lite, which was done with the release of FreeBSD version 2.0 in late
1994.
</para>

<para>Now, in the late 1990s, FreeBSD is the best-known of the BSD operating systems,
one that many consider to follow in the tradition of the CSRG.  I can think of
no greater honour for the development team.  It was developed on a shoestring
budget, yet it manages to outperform commercial operating systems by an order of
magnitude.
</para>

<para>Things have changed elsewhere as well.  In 1992, AT&amp;T sold USL to Novell Inc.,
who had introduced a product based on System V.4 called UnixWare.  Although
UnixWare has much better specifications than SCO's old System V.3 UNIX, it was
never a success, and Novell finally sold their UNIX operation to SCO, who now
markets both systems.  Most FreeBSD users don't see that either system has any
significant advantage over FreeBSD, especially since FreeBSD can run
applications designed for either SCO system.
</para>
</sect1>
<sect1>
<title>Other free UNIX-like operating systems</title>

<para><anchor id="CFBSD-unixclones"/>
FreeBSD isn't the only free UNIX-like operating system available&mdash;it's not
even the best-known one.  The best-known free UNIX-like operating system is
undoubtedly Linux, but there are also a number of other BSD-derived operating
systems.  We'll look at them first:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>386/BSD</primary></indexterm>
<emphasis>386/BSD</emphasis> was the original free BSD operating system, introduced by
William F. Jolitz in 1992.  It never progressed beyond a test stage: instead,
two derivative operating systems arose, FreeBSD and NetBSD.  As far as anybody
can tell, 386/BSD is dead.
</para>
</listitem>
<listitem>

<para><indexterm><primary>NetBSD</primary></indexterm>
<emphasis>NetBSD</emphasis> is an operating system which, to the casual observer, is almost
identical to FreeBSD.  The main differences are in the fact that NetBSD runs on
just about any hardware, whereas FreeBSD concentrates on mainly Intel hardware.
FreeBSD tries harder to be easy to understand for a beginner.  For a comparison
of FreeBSD and NetBSD, somewhat biased towards NetBSD, and now also somewhat
dated, see <emphasis>http://www.cons.org/cracauer/bsd-net-vs-free.html</emphasis>.
</para>
</listitem>
<listitem>

<para><indexterm><primary>OpenBSD</primary></indexterm>
<emphasis>OpenBSD</emphasis> is a spinoff of NetBSD which focuses on security.  You can find
more information at <emphasis>http://www.openbsd.org</emphasis>.
</para>
</listitem>
</itemizedlist>

<para>You might get the impression that there are lots of different, incompatible BSD
versions.  In fact, they're all very similar.
</para>
<sect2>
<title>FreeBSD and Linux</title>

<para>Linux is a clone of UNIX written by Linus Torvalds, a student in Helsinki,
Finland.  At the time, the BSD sources were not freely available, and so Linus
wrote his own version of UNIX.
</para>

<para>Linux is a superb example of how a few dedicated, clever people can produce an
operating system that is better than well-known commercial systems developed by
a large number of trained software engineers.  It is better even than a number
of commercial UNIX systems.
</para>

<para>Obviously, I don't think Linux is as good as FreeBSD, or I wouldn't be writing
this book, but the differences between FreeBSD and Linux are more a matter of
philosophy rather than of concept.  Here are a few contrasts:
<table frame='all'><title>Differences between FreeBSD and Linux</title>
center,tab(#) ;
 lw40  lw40 .

<tgroup cols='2' align='left' colsep='1' rowsep='1'><tbody>
<row><entry>  FreeBSD is a direct descendent of the original UNIX, though it contains no residual AT&amp;T code. </entry><entry> Linux is a clone and never contained any AT&amp;T code
</entry></row>
<row><entry>  FreeBSD is a complete operating system, maintained by a central group of software developers.  There is only one distribution of FreeBSD. </entry><entry> Linux is a kernel, personally maintained by Linus Torvalds.  The non-kernel programs supplied with Linux are part of a <emphasis>distribution</emphasis>, of which there are several.
</entry></row>
<row><entry>  FreeBSD aims to be a stable production environment. </entry><entry> Linux is still a ``bleeding edge'' development environment, though many distributions aim to make it more suitable for production use.
</entry></row>
<row><entry>  As a result of the centralized development style, FreeBSD is straightforward and easy to install. </entry><entry> The ease of installation of Linux depends on the ``distribution''.  If you switch from one distribution of Linux to another, you'll have to learn a new set of installation tools.
</entry></row>
<row><entry>  FreeBSD is still relatively unknown, since its distribution was restricted for a long time due to the AT&amp;T lawsuits. </entry><entry> Linux did not have any lawsuits to contend with, so for a long time it was the only free UNIX-type system available.
</entry></row>
<row><entry>  As a result of the lack of knowledge of FreeBSD, not much commercial software is available for it. </entry><entry> A growing amount of commercial software is becoming available for Linux.
</entry></row>
<row><entry>  As a result of the smaller user base, FreeBSD is less likely to have drivers for brand-new boards than Linux. </entry><entry> Just about any new board will soon have a driver for Linux.
</entry></row>
<row><entry>  Because of the lack of commercial applications and drivers, FreeBSD will run most Linux programs, whether commercial or not.  It's also relatively simple to port Linux drivers to FreeBSD. </entry><entry> Linux appears not to need to be able to run FreeBSD programs or drivers.
</entry></row>
<row><entry>  FreeBSD has a large number of afficionados who are prepared to flame anybody who dares suggest that it's not better than Linux. </entry><entry> Linux has a large number of afficionados who are prepared to flame anybody who dares suggest that it's not better than FreeBSD.
</entry></row>
</tbody></tgroup></table>
In summary, Linux is also a very good operating system.  For many, it's better
than FreeBSD.  It's a pity that so many people on both sides are prepared to
flame
<footnote>

<para>To quote Eric Raymond's ``The New Hacker's Dictionary'':
</para>

<para>:flame: 1. /vi./ To post an email message intended to insult and provoke.
2. /vi./ To speak incessantly and/or rabidly on some relatively uninteresting
subject or with a patently ridiculous attitude.  3. /vt./ Either of senses 1 or
2, directed with hostility at a particular person or people.  4. /n./ An
instance of flaming.  When a discussion degenerates into useless controversy,
one might tell the participants ``Now you're just flaming'' or ``Stop all that
flamage!'' to try to get them to cool down (so to speak).
</para>
</footnote>
each other.  There are signs that both sides are learning to appreciate each
other, and a number of people are now running both systems.
<!--  XXX http://keystone.westminster.edu/~fullermd/bsdvlin.htm -->
</para>
</sect2>
</sect1>
<sect1>
<title>Other documentation on FreeBSD</title>

<para><anchor id="CFBSD-docco"/>
People occasionally complain that there are so few books on
FreeBSD&mdash;currently, this is about the only one in the English language, and it
can't do everything.  That looks like a pretty meagre offering, even if you do
like this book.
</para>

<para>This impression is incorrect.  In fact, FreeBSD users have access to probably
more top-quality documentation than just about any other operating system.
Remember that word UNIX\(rg.  Sure, the lawyers tell us that we can't refer to
FreeBSD as UNIX, because UNIX belongs to the Open Group.  That doesn't make the
slightest difference to the fact that just about any book on UNIX will apply
more directly to FreeBSD than any other flavour of UNIX.  Why is this?
</para>

<para>Commercial UNIX vendors have a problem, and FreeBSD doesn't help them: why
should people buy their products when you can get it free from the FreeBSD
Project (or, for that matter, from other free UNIX-like operating systems such
as NetBSD, OpenBSD and Linux)?  One obvious reason would be ``value-added
features''.  So they add features or fix weak points in the system, put a
copyright on the changes, and help lock their customers in to their particular
implementation.  As long as the changes are really useful, this is legitimate,
but it does make the operating system less compatible with ``standard UNIX'',
and the books about standard UNIX are less applicable.
</para>

<para>In addition, many books are written by people with an academic background.  In
the UNIX world, this means that they are more likely than the average user to
have been exposed to BSD.  Many general UNIX books handle primarily BSD,
possibly with an additional chapter on the commercial System V version.
</para>

<para>In <xref linkend="CFBSD-biblio"/>, you'll find a list of books which I find particularly worthwhile.
I'd like to single out some which I find particularly good, and which I
frequently use myself:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>online</primary><secondary>handbook</secondary></indexterm>
<indexterm><primary>handbook</primary><secondary>online</secondary></indexterm>
<anchor id="CFBSD-handbook"/>
<indexterm><primary>Live</primary><secondary>Filesystem</secondary></indexterm>
The FreeBSD <emphasis>online handbook</emphasis> contains a lot of information specifically
about FreeBSD, including a deeper discussion of many topics in this book.  It is
available on the World Wide Web at <emphasis>http://www.FreeBSD.org/handbook.html</emphasis>,
and it is also available on each FreeBSD system in the directory
<emphasis>/usr/share/doc/handbook</emphasis>.  Before installation, you can access it from the
<emphasis>Live Filesystem</emphasis> CD-ROM.  We'll look at how to do that in the next
section.
</para>
</listitem>
<listitem>

<para><indexterm><primary>FAQ</primary></indexterm>
<indexterm><primary>Frequently</primary><secondary>Asked Questions</secondary></indexterm>
<indexterm><primary>/usr/share/doc/FAQ</primary></indexterm>
<indexterm><primary>VIEW</primary></indexterm>
The FreeBSD <emphasis>FAQ</emphasis> (<emphasis>Frequently Asked Questions</emphasis>) is just what it
says it is: a list of questions that people frequently ask about FreeBSD, with
answers of course.  It is located in the directory <emphasis>/usr/share/doc/FAQ</emphasis>.  If
you run MS-DOS, you can view it before installation with the <emphasis>VIEW</emphasis>
program.  Check the CD-ROM booklet for the location, which could change.
</para>
</listitem>
<listitem>

<para><indexterm><primary>Peek</primary><secondary>Jerry</secondary></indexterm>
<indexterm><primary>O'Reilly</primary><secondary>Tim</secondary></indexterm>
<indexterm><primary>Loukides</primary><secondary>Mike</secondary></indexterm>
<emphasis>UNIX Power Tools</emphasis>, by Jerry Peek, Tim O'Reilly, and Mike Loukides, is a
superb collection of interesting information, including a CD-ROM.  Recommended
for everybody, from beginners to experts.
</para>
</listitem>
<listitem>

<para><indexterm><primary>Abrahams</primary><secondary>Paul W.</secondary></indexterm>
<indexterm><primary>Larson</primary><secondary>Bruce R.</secondary></indexterm>
<emphasis>UNIX for the Impatient</emphasis>, by Paul W. Abrahams and Bruce R. Larson, is more
similar to this book, but it includes a lot more material on specific products,
such as shells and the <emphasis>Emacs</emphasis> editor.
</para>
</listitem>
<listitem>

<para><indexterm><primary>Nemeth</primary><secondary>Evi</secondary></indexterm>
<indexterm><primary>Snyder</primary><secondary>Garth</secondary></indexterm>
<indexterm><primary>Seebass</primary><secondary>Scott</secondary></indexterm>
<indexterm><primary>Hein</primary><secondary>Trent R.</secondary></indexterm>
The <emphasis>UNIX System Administration Handbook</emphasis>, by Evi Nemeth, Garth Snyder,
Scott Seebass, and Trent R. Hein, is one of the best books on systems
administration I have seen.  It covers six different UNIX systems, including
BSD/OS, which is very close to FreeBSD.
</para>
</listitem>
<listitem>

<para>There are a large number of active Internet groups which deal with FreeBSD.
Read about them in the online handbook.
</para>
</listitem>
</itemizedlist>

<para></para>
<sect2>
<title>Reading the handbook</title>

<para><indexterm><primary>lynx</primary><secondary>command</secondary></indexterm>
If you're running X, you can use a browser like <emphasis>netscape</emphasis> to read the
handbook.  If you don't have X running yet, use <emphasis>lynx</emphasis>.  Both of these
programs are included on the CD-ROM.  To install them, enter:
</para>
<programlisting>
# <command>pkg_add /cdrom/packages/All/netscape-communicator-4.5.tgz</command>
<emphasis>or</emphasis>
# <command>pkg_add /cdrom/packages/All/lynx-2.8.1.1.tgz</command>
</programlisting>

<para>The numbers after the name (<emphasis>4.5</emphasis> and <emphasis>2.8.1.1</emphasis>) may change after
this book has been printed.  Use <emphasis>ls</emphasis> to list the names if you can't find
these particular versions.
</para>

<para>Note that <emphasis>lynx</emphasis> is not a complete substitute for <emphasis>netscape</emphasis>: since
it is text-only, it is not capable of displaying the large majority of web pages
correctly.  It will suffice for reading most of the handbook, however.  See
page
<indexterm><primary>pkg_add</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>pkg_add</secondary></indexterm>
for more information on <emphasis>pkg_add</emphasis>.
</para>

<para>In either case, you start the browser with the name of the handbook:
</para>
<programlisting>
$ <command>lynx /usr/share/doc/handbook/handbook.html</command>
$ <command>netscape /usr/share/doc/handbook/handbook.html &amp;</command>
</programlisting>

<para>You enter the <emphasis>&amp;</emphasis> after the invocation of <emphasis>netscape</emphasis> to free up the
window in which you invoke it: <emphasis>netscape</emphasis> opens its own window.
</para>

<para>You can look at the FAQ in the same way&mdash;just substitute the name
<emphasis>FAQ/freebsd-faq.html</emphasis> for <emphasis>handbook/handbook.html</emphasis>.
</para>

<para>If you haven't installed the handbook, you can still access it from the Live
Filesystem CD-ROM.  Assuming the CD-ROM is mounted on <emphasis>/cdrom</emphasis>, choose the
directory <emphasis>/cdrom/usr/share/doc/handbook/handbook.html</emphasis>.
</para>

<para><indexterm><primary>ghostscript</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>ghostscript</secondary></indexterm>
<indexterm><primary>dvips</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>dvips</secondary></indexterm>
Alternatively, you can print out the handbook.  This is a little more difficult,
and of course you'll lose the hypertext references, but you may prefer it in
this form.  To format the handbook for printing, you'll need a PostScript
printer or <emphasis>ghostscript</emphasis>.  See page <xref linkend="CFBSD-PostScript"/> for more details of how
to print PostScript.
</para>

<para>You can download handbook from
<emphasis>ftp://ftp.FreeBSD.ORG/pub/FreeBSD/doc/handbook.ps.gz</emphasis>.  Use <emphasis>ftp</emphasis>
(page <xref linkend="CFBSD-ftp"/>) to transfer the document.
</para>
</sect2>
<sect2>
<title>The online manual</title>

<para><anchor id="CFBSD-man"/>
<indexterm><primary>man</primary><secondary>command</secondary></indexterm>
<indexterm><primary>man</primary><secondary>page</secondary></indexterm>
<indexterm><primary>command</primary><secondary>man</secondary></indexterm>
The most comprehensive documentation on FreeBSD is in the form of <emphasis>man
pages</emphasis>.  Nearly every program on the system comes with a short reference
manual explaining the basic operation and various arguments.
</para>

<para>When online, you view the man pages with the command <emphasis>man</emphasis>.  For example, to
learn more about the command <emphasis>ls</emphasis>, type:
</para>
<programlisting>
$ <command>man ls </command>
LS(1)                      FreeBSD Reference Manual                      LS(1)

<command>NAME</command>
     ls - list directory contents

<command>SYNOPSIS</command>
     ls [-<command>ACFLRTacdfiloqrstu1</command>] [ file ... ]

<command>DESCRIPTION</command>
     For each operand that names a file of a type other than directory, <command>ls</command>
     displays its name as well as any requested, associated information.  For
     each operand that names a file of type directory, ls displays the names.
<emphasis>(etc)</emphasis>
</programlisting>

<para>In this particular example, with the exception of the first line, the text in
<command>constant width bold</command> is not input, it's the way it appears on the screen.
</para>

<para>The online manual is divided up into sections numbered:
</para>
<itemizedlist>
<listitem>

<para>User commands
</para>
</listitem>
<listitem>

<para>System calls and error numbers
</para>
</listitem>
<listitem>

<para>Functions in the C libraries
</para>
</listitem>
<listitem>

<para>Device drivers
</para>
</listitem>
<listitem>

<para>File formats
</para>
</listitem>
<listitem>

<para>Games and other diversions
</para>
</listitem>
<listitem>

<para>Miscellaneous information
</para>
</listitem>
<listitem>

<para>System maintenance and operation commands
</para>
</listitem>
<listitem>

<para>Kernel interface documentation
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>chmod</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>chmod</secondary></indexterm>
In some cases, the same topic may appear in more than one section of the on-line
manual.  For example, there is a user command <emphasis>chmod</emphasis> and a system call
<emphasis>chmod()</emphasis>.  In this case, you can tell the man command which you want by
specifying the section number:
</para>
<programlisting>
$ <command>man 1 chmod </command>
</programlisting>

<para><indexterm><primary>chmod(1)</primary></indexterm>
<indexterm><primary>chmod(2)</primary></indexterm>
This will display the manual page for the user command chmod.  References to a
particular section of the on-line manual are traditionally placed in parentheses
in written documentation.  For example, <emphasis>chmod(1)</emphasis> refers to the user
command <emphasis>chmod</emphasis>, and <emphasis>chmod(2)</emphasis> means the system call.
</para>

<para><indexterm><primary>apropos</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>apropos</secondary></indexterm>
This is fine if you know the name of the command and forgot how to use it, but
what if you can't recall the command name?  You can use man to search for
keywords in the command descriptions by using the <emphasis>-k</emphasis> option, or by
starting the program <emphasis>apropos</emphasis>:
</para>
<programlisting>
$ <command>man -k mail </command>
$ <command>apropos mail </command>
</programlisting>

<para>Both of these commands do the same thing: they show the names of the man pages
that have the keyword <emphasis>mail</emphasis> in their descriptions.
</para>

<para>Alternatively, you may browse through <emphasis>/usr/bin</emphasis> and see all these file
names, but you don't have any idea what they do.  To find out, enter one of the
lines:
</para>
<programlisting>
$ <command>cd /usr/bin; man -f * </command>
$ <command>cd /usr/bin; whatis * </command>
</programlisting>

<para>Both of these commands do the same thing: they print out a one-line summary of
the purpose of the program:
</para>
<programlisting>
$ <command>cd /usr/bin; man -f * </command>
a2p(1)           - Awk to Perl translator
addftinfo(1)     - add information to troff font files for use with groff
apply(1)         - apply a command to a set of arguments
apropos(1)       - search the whatis database for strings
<emphasis>\&amp;...etc</emphasis>
</programlisting>

<para></para>
</sect2>
<sect2>
<title>GNU <emphasis>info</emphasis> </title>

<para><indexterm><primary>info</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>info</secondary></indexterm>
<indexterm><primary>emacs</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>emacs</secondary></indexterm>
The Free Software Foundation has its own on-line hypertext browser called
<emphasis>info</emphasis>.  Many FSF programs come with either no man page at all, or with an
excuse for a man page (<emphasis>gcc</emphasis>, for example).  To read the online
documentation, you need to browse the <emphasis>info</emphasis> files with the <emphasis>info</emphasis>
program, or from <emphasis>Emacs</emphasis> with the <emphasis>info</emphasis> mode.  To start <emphasis>info</emphasis>,
simply type:
</para>
<programlisting>
$ <command>info </command>
</programlisting>

<para>In <emphasis>Emacs</emphasis>, enter <keycap>CTRL-h i</keycap> or <keycap>ALT-X</keycap> <emphasis>info</emphasis>.  Whichever way
you start <emphasis>info</emphasis>, you can get brief introduction by typing <emphasis>h</emphasis>, and a
quick command reference by typing <emphasis>?</emphasis>.
</para>
</sect2>
</sect1>
<sect1>
<title>The FreeBSD community</title>

<para><anchor id="CFBSD-FreeBSD-community"/>
FreeBSD was developed by a world-wide group of developers.  It could not have
happened without the Internet.  Most of the key players have never even met each
other in person: the main communication is via the Net.  If you have any kind of
Internet connection, you can participate as well.  If you don't have an Internet
connection, it's about time you got one.  The connection doesn't have to be
complete: if you can receive email, you can participate.  On the other hand,
FreeBSD includes all the software you need for a complete Internet connection,
not the very limited subset that most PC-based ``Internet'' packages offer you.
</para>
</sect1>
<sect1>
<title>Support</title>

<para><anchor id="CFBSD-support"/>
<indexterm><primary>Support</primary></indexterm>
<indexterm><primary>Installation</primary><secondary>support</secondary></indexterm>
As it says in the copyright, FreeBSD is supplied as-is, without any support
liability.  If you're on the Net, you're not alone, however.  Liability is one
thing, but there are plenty of people prepared to help you, most for free, some
for fee.  A good place to start is with the mailing lists
<emphasis>FreeBSD-newbies@FreeBSD.org</emphasis> and <emphasis>freebsd-questions@FreeBSD.org</emphasis>.
In conversation they are typically abbreviated to <emphasis>-newbies</emphasis> and
<emphasis>-questions</emphasis> respectively.
To sign up, send a mail message to <emphasis>majordomo@FreeBSD.org</emphasis> with the text
</para>
<programlisting>
subscribe FreeBSD-newbies
<emphasis>or</emphasis>
subscribe FreeBSD-questions
</programlisting>

<para>You'll get a reply back saying that the request must be authenticated: it'll
look something like this:
</para>
<programlisting>
Please be sure to read the charters before subscribing or sending
mail to any FreeBSD mailing list for an explanation of which topics
are relevant for a given list and what types of postings are and
are not allowed.  They may be found at:

        http://www.freebsd.org/handbook/eresources.html#ERESOURCES-MAIL

Someone (possibly you) has requested that your email address be added
to or deleted from the mailing list "freebsd-newbies@FreeBSD.ORG".

If you really want this action to be taken, please send the following
commands (exactly as shown) back to "Majordomo@FreeBSD.ORG":

        auth 7e06ee31 subscribe freebsd-newbies grog@example.org

If you do not want this action to be taken, simply ignore this message
and the request will be disregarded.

If your mailer will not allow you to send the entire command as a single
line, you may split it using backslashes, like so:

        auth 7e06ee31 subscribe freebsd-newbies \e
        grog@example.org

If you have any questions about the policy of the list owner, please
contact "freebsd-newbies-approval@FreeBSD.ORG".

Thanks!

Majordomo@FreeBSD.ORG
</programlisting>

<para>Just reply to that message, removing all the text except the <emphasis>auth</emphasis> line:
</para>
<programlisting>
        auth 7e06ee31 subscribe freebsd-newbies grog@example.org
</programlisting>

<para>Send this message to <emphasis>majordomo@FreeBSD.org</emphasis> (which is what you do if you
just reply), not to the list itself.  You'll get another reply back:
</para>
<programlisting>
Welcome to the freebsd-newbies mailing list!

Please save this message for future reference.  Thank you.

If you ever want to remove yourself from this mailing list,
you can send mail to &lt;Majordomo@FreeBSD.ORG&gt; with the following
command in the body of your email message:

    unsubscribe freebsd-newbies

or from another account, besides grog@example.org:

    unsubscribe freebsd-newbies grog@example.org

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to &lt;owner-freebsd-newbies@FreeBSD.ORG&gt; .
This is the general rule for most mailing lists when you need
to contact a human.

 Here's the general information for the list you've subscribed to,
 in case you don't already have it:

FREEBSD-NEWBIES

Welcome to FreeBSD!
This list is a gathering place for people new to FreeBSD.
Please feel free to share your experiences with others on this list.

Support questions should be sent to freebsd-questions@freebsd.org
(NOT to the newbies list please)

Full info and FAK   http://www.welearn.com.au/freebsd/newbies/
Resource list       http://www.FreeBSD.org/projects/newbies.html
</programlisting>

<para>As the welcome message says, <emphasis>-newbies</emphasis> is a discussion group for people
new to FreeBSD; it's not intended for real technical problems.  Use
<emphasis>-questions</emphasis> for that.
</para>

<para>When submitting questions to <emphasis>-questions</emphasis>, remember that people are under
no obligation to answer your question.  Make them want to answer it: submit the
question in a clear, understandable manner.  For more details, see
<emphasis>http://www.lemis.com/questions.html</emphasis>.  You may also like to check out the
FreeBSD World Wide Web (WWW) site at <emphasis>http://www.FreeBSD.org</emphasis>, in particular
the support page at <emphasis>http://www.FreeBSD.org/support.html</emphasis>.
</para>

<para>In addition, Walnut Creek CDROM supplies limited basic installation support for
purchasers of the Walnut Creek CDROM edition of FreeBSD.  Here's how to contact
Walnut Creek CDROM:
</para>
<itemizedlist>
<listitem>

<para>By phone.  Call +1 925 603 1234
<footnote>

<para>If you live in North America, you may not recognize the <emphasis>+1</emphasis>.  This is the
international dialing code for North America; replace the <emphasis>+</emphasis> symbol with
your national prefix code for international calls.  For example, in most parts
of Europe you replace the <emphasis>+</emphasis> with <emphasis>00</emphasis>; in Australia, you replace
it with <emphasis>0011</emphasis>, so the complete number becomes <emphasis>0011 1 925 603
1234</emphasis>.
</para>
</footnote>
</para>
</listitem>
<listitem>

<para>By fax.  Fax to +1 925 674 0821.
</para>
</listitem>
<listitem>

<para>By email.  Send email to <emphasis>support@cdrom.com</emphasis>.
</para>
</listitem>
</itemizedlist>

<para></para>

<para>Remember, too, that if all else fails you can return your CD-ROM to Walnut Creek
CDROM for an unconditional refund.  If you do have to go to this step, please
let us know what went wrong.  You'll get your refund either way, but if you have
problems with FreeBSD, we want to know why and how we can improve the product.
</para>
<sect2>
<title>Reporting bugs</title>

<para>If you find something wrong with FreeBSD, we want to know about it.  There are
two ways to report a bug:
</para>
<itemizedlist>
<listitem>

<para>Report it via the World Wide Web at <emphasis>http://www.FreeBSD.org/send-pr.html</emphasis>.
</para>
</listitem>
<listitem>

<para>Use the <emphasis>send-pr</emphasis> program to send it as a mail message.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
</sect1>
<sect1>
<title>The Berkeley d&aelig;gmon</title>

<para><anchor id="CFBSD-bsdd"/>
<indexterm><primary>Branagan</primary><secondary>Linda</secondary></indexterm>
<indexterm><primary>Berkeley</primary><secondary>d&aelig;gmon</secondary></indexterm>
<indexterm><primary>d&aelig;gmon</primary><secondary>Berkeley</secondary></indexterm>
<indexterm><primary>daemon</primary><secondary>Berkeley</secondary></indexterm>
<indexterm><primary>Kolstad</primary><secondary>Rob</secondary></indexterm>
<indexterm><primary>McKusick</primary><secondary>Kirk</secondary></indexterm>
The little d&aelig;gmon on the cover of this book symbolizes BSD.  It is included
with kind permission of Marshall Kirk McKusick, one of the leading members of
the former Computer Sciences Research Group at the University of California at
Berkeley, and owner of the d&aelig;gmon's copyright.
</para>

<para>The d&aelig;gmon has occasionally given rise to a certain amount of confusion.  In
fact, it's a joking reference to processes which run in the background&mdash;see
<xref linkend="CFBSD-chunixref"/>, page
for a description.  The outside world occasionally sees things differently, as
the following story indicates:
<!--  XXX.ft CW -->
Newsgroups: alt.humor.best-of-usenet
Subject: [comp.org.usenix] A Great Daemon Story
From: Rob Kolstad &lt;kolstad@bsdi.com&gt;
Newsgroups: comp.org.usenix
Subject: A Great Daemon Story
Linda Branagan is an expert on d&aelig;gmons.  She has a T-shirt that sports the
d&aelig;gmon in tennis shoes that appears on the cover of the 4.3BSD manuals and
<emphasis>The Design and Implementation of the 4.3BSD UNIX Operating System</emphasis> by
S. Leffler, M. McKusick, M. Karels, J. Quarterman, Addison-Wesley Publishing
Company, Reading, MA 1989.
She tells the following story about wearing the 4.3BSD d&aelig;gmon T-shirt:
Last week I walked into a local ``home style cookin' restaurant/watering hole''
in Texas to pick up a take-out order.  I spoke briefly to the waitress behind
the counter, who told me my order would be done in a few minutes.
So, while I was busy gazing at the farm implements hanging on the walls, I was
approached by two ``natives.''  These guys might just be the original Texas
rednecks.
``Pardon us, ma'am.  Mind if we ask you a question?''
Well, people keep telling me that Texans are real friendly, so I nodded.
``Are you a Satanist?''
Well, at least they didn't ask me if I liked to party.
``Uh, no, I can't say that I am.''
``Gee, ma'am.  Are you sure about that?'' they asked.
I put on my biggest, brightest Dallas Cowboys cheerleader smile and said, ``No,
I'm positive.  The closest I've ever come to Satanism is watching Geraldo.''
``Hmmm.  Interesting.  See, we was just wondering why it is you have the lord of
darkness on your chest there.''
I was this close to slapping one of them and causing a scene&mdash;then I stopped
and noticed the shirt I happened to be wearing that day.  Sure enough, it had a
picture of a small, devilish-looking creature that has for some time now been
associated with a certain operating system.  In this particular representation,
the creature was wearing sneakers.
They continued: ``See, ma'am, we don't exactly appreciate it when people show
off pictures of the devil.  Especially when he's lookin' so friendly.''
These idiots sounded terrifyingly serious.
Me: ``Oh, well, see, this isn't really the devil, it's just, well, it's
sort of a mascot.
Native: ``And what kind of football team has the devil as a mascot?''
Me: ``Oh, it's not a team.  It's an operating&mdash;uh, a kind of computer.''
I figured that an ATM machine was about as much technology as these guys could
handle, and I knew that if I so much as uttered the word ``UNIX'' I would only
make things worse.
Native: ``Where does this satanical computer come from?''
Me: ``California.  And there's nothing satanical about it really.''
Somewhere along the line here, the waitress noticed my predicament&mdash;but these
guys probably outweighed her by 600 pounds, so all she did was look at me
sympathetically and run off into the kitchen.
Native: ``Ma'am, I think you're lying.  And we'd appreciate it if you'd
leave the premises now.''
Fortunately, the waitress returned that very instant with my order, and they
agreed that it would be okay for me to actually pay for my food before I left.
While I was at the cash register, they amused themselves by talking to each
other.
Native #1: ``Do you think the police know about these devil computers?''
Native #2: ``If they come from California, then the FBI oughta know
about 'em.''
They escorted me to the door.  I tried one last time: ``You're really blowing
this all out of proportion.  A lot of people use this `kind of computers.'
Universities, researchers, businesses.  They're actually very useful.''
Big, big, <emphasis>big</emphasis> mistake.  I should have guessed at what came next.
Native: ``Does the government use these devil computers?''
Me: ``Yes.''
Another <emphasis>big</emphasis> boo-boo.
Native: ``And does the government pay for 'em?  With our tax dollars?''
I decided that it was time to jump ship.
Me: ``No.  Nope.  Not at all.  Your tax dollars never entered the picture at
all.  I promise.  No sir, not a penny.  Our good Christian congressmen would
never let something like that happen.  Nope.  Never.  Bye.''
Texas.  What a country.
</para>

<para>In fact, the d&aelig;gmon tradition goes back quite a way.  As recently as 1996, the
following message went through the <emphasis>FreeBSD-chat</emphasis> mailing list:
<!-- XXX.ft CW -->
To: "Jonathan M. Bresler" &lt;jmb@freefall.freebsd.org&gt;
Cc: obrien@antares.aero.org (Mike O'Brien),
        joerg_wunsch@uriah.heep.sax.de,
        chat@FreeBSD.org, juphoff@tarsier.cv.nrao.edu
Date: Tue, 07 May 1996 16:27:20 -0700
Sender: owner-chat@FreeBSD.org
&gt;         details and gifs PLEASE!
	If you insist. <emphasis>:-)</emphasis>
<indexterm><primary>Salus</primary><secondary>Peter</secondary></indexterm>
<indexterm><primary>Ferentz</primary><secondary>Mel</secondary></indexterm>
        Sherman, set the Wayback Machine for around 1976 or so (see Peter Salus'
<emphasis>A Quarter Century of UNIX</emphasis> for details), when the first really national
UNIX meeting was held in Urbana, Illinois.  This would be after the ``forty
people in a Brooklyn classroom'' meeting held by Mel Ferentz (yeah I was at that
too) and the more-or-less simultaneous West Coast meeting(s) hosted by SRI, but
before the UNIX Users Group was really incorporated as a going concern.
<indexterm><primary>Thompson</primary><secondary>Ken</secondary></indexterm>
<indexterm><primary>Ritchie</primary><secondary>Dennis</secondary></indexterm>
<indexterm><primary>Foglio</primary><secondary>Phil</secondary></indexterm>
<indexterm><primary>O'Brien</primary><secondary>Mike</secondary></indexterm>
	I knew Ken Thompson and Dennis Ritchie would be there.  I was living in
Chicago at the time, and so was comic artist Phil Foglio, whose star was just
beginning to rise.  At that time I was a bonded locksmith.  Phil's roommate had
unexpectedly split town, and he was the only one who knew the combination to the
wall safe in their apartment.  This is the only apartment I've ever seen that
had a wall safe, but it sure did have one, and Phil had some stuff locked in
there.  I didn't hold out much hope, since safes are far beyond where I was (and
am) in my locksmithing sphere of competence, but I figured ``no guts no glory''
and told him I'd give it a whack.  In return, I told him, he could do some
T-shirt art for me.  He readily agreed.
	Wonder of wonders, this safe was vulnerable to the same algorithm that
Master locks used to be susceptible to.  I opened it in about 15 minutes of
manipulation.  It was my greatest moment as a locksmith and Phil was overjoyed.
I went down to my lab and shot some Polaroid snaps of the PDP-11 system I was
running UNIX on at the time, and gave it to Phil with some descriptions of the
visual puns I wanted: pipes, demons with forks running along the pipes, a ``bit
bucket'' named <emphasis>/dev/null</emphasis>, all that.
	What Phil came up with is the artwork that graced the first decade's
worth of ``UNIX T-shirts'', which were made by a Ma and Pa operation in a
Chicago suburb.  They turned out transfer art using a 3M color copier in their
basement.  Hence, the PDP-11 is reversed (the tape drives are backwards) but
since Phil left off the front panel, this was hard to tell.  His trademark
signature was photo-reversed, but was recopied by the T-shirt people and
``re-forwardized'', which is why it looks a little funny compared to his real
signature.
	Dozens and dozens of these shirts were produced.  Bell Labs alone
accounted for an order of something like 200 for a big picnic.  However, only
four (4) REAL originals were produced: these have a distinctive red collar and
sleeve cuff.  One went to Ken, one to Dennis, one to me, and one to my
then-wife.  I now possess the latter two shirts.  Ken and Dennis were presented
with their shirts at the Urbana conference.
<indexterm><primary>Stettner</primary><secondary>Armando</secondary></indexterm>
	People ordered these shirts direct from the Chicago couple.  Many years
later, when I was living in LA, I got a call from Armando Stettner, then at DEC,
asking about that now-famous artwork.  I told him I hadn't talked to the
Illinois T-shirt makers in years.  At his request I called them up.  They'd
folded the operation years ago and were within days of discarding all the old
artwork.  I requested its return, and duly received it back in the mail.  It
looked strange, seeing it again in its original form, a mirror image of the
shirts with which I and everyone else were now familiar.
	I sent the artwork to Armando, who wanted to give it to the Ultrix
marketing people.  They came out with the Ultrix poster that showed a nice shiny
Ultrix machine contrasted with the chewing-gum-and-string PDP-11 UNIX people
were familiar with.  They still have the artwork, so far as I know.
	I no longer recall the exact contents of the letter I sent along with
the artwork. I did say that as far as I knew, Phil had no residual rights to the
art, since it was a `work made for hire', though nothing was in writing (and
note this was decades before the new copyright law).  I do not now recall if I
explicitly assigned all rights to DEC.  What is certain is that John Lassiter's
d&aelig;gmon, whether knowingly borrowed from the original, or created by parallel
evolution, postdates the first horde of UNIX d&aelig;gmons by at least a decade and
probably more.  And if Lassiter's d&aelig;gmon looks a lot like a Phil Foglio
creation, there's a reason.
        I have never scanned in Phil's artwork; I've hardly ever scanned in
anything, so I have no GIFs to show.  But I have some very very old UNIX
T-shirts in startlingly good condition.  Better condition than I am at any rate:
I no longer fit into either of them.
Mike O'Brien
creaky antique
</para>

<para>Note the date of this message: it's quite recent.  Mike has since scanned the
original teeshirt, and it may be made available.  Remember, you read it here
first.
</para>
</sect1>
</chapter>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchconcepts"><title>Before you install</title>

<para>FreeBSD will run on just about any modern PC.  You can skip this chapter and
move to <xref linkend="CFBSD-chquickinstall"/>, and you'll have a very good chance of success.
Nevertheless, it will make things easier if you know the contents of this
chapter before you start.  If you do run into trouble, this chapter will give
you the background information you need to solve the trouble quickly and simply.
</para>
<sect1>
<title>Hardware requirements</title>

<para><anchor id="CFBSD-hardware-requirements"/>
<anchor id="CFBSD-memory-requirements"/>
To run FreeBSD, you will need the following absolute minimum hardware:
</para>
<itemizedlist>
<listitem>

<para>PC with 80386 CPU, or Alpha-based machine with SRM firmware.
</para>
</listitem>
<listitem>

<para>4 MB memory (Intel) or 24 MB (Alpha?)
</para>
</listitem>
<listitem>

<para>Any display board
</para>
</listitem>
<listitem>

<para>80 MB free disk space (Intel).  Nobody has tried an installation on an Alpha
machine with less than 500 MB, though it's certainly possible to reduce this
value significantly.
</para>
</listitem>
</itemizedlist>

<para><figure><title>Absolute minimum hardware for FreeBSD</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>

<para>When I say <emphasis>absolute</emphasis> minimum, I mean it.  You can run FreeBSD <xref linkend="CFBSD-Fver"/> in
4 MB memory, but you will require at least 5 MB in order to install it.  You
can't do very much with such a minimal system, but for some purposes it might be
adequate.  For any kind of reasonable response time, you should use at least 8
MB of memory.  Before you go to the trouble to even try such a minimal
installation, consider the cost of another 4 MB of memory.  And you can pick up
better machines than this second-hand for $50.  Is the hassle worth it?
</para>

<para>To get full benefits from FreeBSD, you should be running the X Window system.
This uses more memory.  Consider 16 MB a usable minimum here, though thanks to
FreeBSD's virtual memory system, this is not such a hard limit as it is with
some other systems.
</para>
<note>

<para>The speed of a virtual memory based system such as FreeBSD depends at least as
much on memory performance as on processor performance.  If you have, say, a
486DX-33 and 8 MB of memory, upgrading memory to 16 MB will probably buy you
more performance than upgrading the motherboard to a Pentium 100 and keeping the
8 MB memory.  This applies for a usual mix of programs, in particular, programs
that don't perform number crunching.
</para>
</note>

<para>Consider the following the minimum for getting useful work done with FreeBSD and
X:
</para>
<itemizedlist>
<listitem>

<para>PC with 80486DX/2-66, or Alpha-based machine
</para>
</listitem>
<listitem>

<para>16 MB memory (i386) or 32 MB (Alpha).
</para>
</listitem>
<listitem>

<para>SVGA display board with 2 MB memory, 1024x768
</para>
</listitem>
<listitem>

<para>Mouse
</para>
</listitem>
<listitem>

<para>200 MB free disk space
</para>
</listitem>
</itemizedlist>

<para><figure><title>Recommended small FreeBSD and X11 system</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>
<note>

<para>Your mileage may vary.  During the review phase of this book, one of the
reviewers pointed out that he was very happy with his machine, which has a
486-33 processor, 16 MB main memory, and 1 MB memory on his display board.  He
says that it runs a lot faster than his Pentium 100 at work, which runs
Microsoft.  If your hardware doesn't measure up to the recommended
specification, don't be discouraged: try it out anyway.
</para>
</note>

<para>Beyond this minimum, FreeBSD supports a large number of other hardware
components.  FreeBSD is a 32 bit operating system, and it cannot use the 16 bit
drivers commonly supplied with PC extension boards.  If FreeBSD doesn't know
about the board, you probably won't be able to use it.
</para>
<sect2>
<title>Compaq/Digital Alpha machines</title>

<para><indexterm><primary>Processor</primary><secondary>AXP</secondary></indexterm>
<indexterm><primary>AXP</primary><secondary>Processor</secondary></indexterm>
<indexterm><primary>Processor</primary><secondary>Alpha</secondary></indexterm>
<indexterm><primary>Alpha</primary><secondary>architecture</secondary></indexterm>
<indexterm><primary>Console</primary><secondary>firmware</secondary></indexterm>
<indexterm><primary>SRM</primary><secondary>Console firmware</secondary></indexterm>
<indexterm><primary>Console</primary><secondary>firmware</secondary></indexterm>
<indexterm><primary>ARC</primary><secondary>Console firmware</secondary></indexterm>
<anchor id="CFBSD-alpha-concepts"/>
Since version 3.0, FreeBSD supports computers based on the Compaq (previously
Digital) <emphasis>AXP</emphasis> processor, commonly called <emphasis>Alpha</emphasis>.  FreeBSD requires
the same <emphasis>SRM</emphasis> console firmware as Digital UNIX.  It will not work with
the ARC firmware used with Microsoft NT.  The SRM firmware runs the machine in
64 bit mode, which is required to run FreeBSD, while the <emphasis>ARC</emphasis> firmware
sets 32 bit mode.  If your system is currently running Digital UNIX, then you
should be able to use the existing SRM console.  You can get firmware updates
from <emphasis>ftp://ftp.digital.com/pub/Digital/Alpha/firmware</emphasis>.  The easiest way to
access it is via a web browser at
<emphasis>http://gatekeeper.dec.com/pub/Digital/Alpha/firmware/</emphasis>.  Be careful to
transfer in binary mode.
</para>

<para>Note that the SRM firmware is board-specific, so take care to choose the correct
file that matches your exact system: near enough is not good enough.
Unfortunately, some Alpha systems do not support the SRM firmware.  You cannot
run FreeBSD on these systems.
</para>

<para>The SRM console commands differ from one version to another.  The commands
supported by your version are described in the hardware manual that was shipped
with your system.  The console <emphasis>help</emphasis> command lists all supported console
commands.  If your system has been set to boot automatically, you must type
<keycap>Ctrl-C</keycap> to interrupt the boot process and get to the SRM console prompt
(<emphasis>&gt;&gt;&gt;</emphasis>).  If the system is not set to boot automatically, it will display
the SRM console prompt after performing system checks.
</para>

<para>All SRM console versions support the <emphasis>set</emphasis> and <emphasis>show</emphasis> commands which
operate on environment variables that are stored in non-volatile memory.  The
<emphasis>show</emphasis> command lists all environment variables, including those that are
read-only.
</para>

<para>Alpha's SRM is picky about which hardware it supports.  For example, it
recognizes NCR SCSI boards, but it doesn't recognize Adaptec boards.  There are
reports of some Alphas not booting with particular video boards.  The
<emphasis>GENERIC</emphasis> kernel configuration (<emphasis>/usr/src/sys/alpha/conf/GENERIC</emphasis>)
shows what the kernel supports, but that doesn't mean that the SRM supports all
the devices.  In addition, the SRM support varies from one machine to the next,
so there's a danger that what's described here won't work for you.
</para>

<para>In the rest of this chapter, we'll look primarily at the i386 architecture.
Differences for Alpha include:
</para>
<itemizedlist>
<listitem>

<para>The disk layout for SRM is different from the layout for Microsoft.  SRM looks
for its bootstrap where Microsoft keeps its partition table.  This means that
you cannot share a disk between FreeBSD and Microsoft on an Alpha.
</para>
</listitem>
<listitem>

<para>Most SRM-based Alpha machines don't support IDE drives, so you're limited to
SCSI.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
<sect2>
<title>Laptops</title>

<para><indexterm><primary>laptop</primary></indexterm>
<indexterm><primary>Hosokawa</primary><secondary>Tatsumi</secondary></indexterm>
FreeBSD will also run on most laptops; the considerations above apply for
laptops as well.  The generic kernel does not support all laptops optimally: if
you have a laptop, you should check Tatsumi Hosokawa's Mobile Computing page at
<emphasis>http://www.jp.FreeBSD.org/PAO/</emphasis>.
</para>
</sect2>
<sect2>
<title>Drivers</title>

<para><indexterm><primary>kernel
</primary></indexterm>
<indexterm><primary>driver</primary></indexterm>
The generic FreeBSD kernel
<footnote>

<para><indexterm><primary>kernel</primary></indexterm>
The <emphasis>kernel</emphasis> is the core program of the operating system, and is resident in
memory at all times.  To start the operating system, you load the kernel into
memory and run it.
</para>
</footnote>
contains support in the form of <emphasis>drivers</emphasis> for most common hardware, but
some less common drivers have been omitted.  If you have a supported product
which is not in the generic kernel, you have two options:
</para>
<itemizedlist>
<listitem>

<para>You may be able to use a <emphasis>Kernel Loadable Module</emphasis> (<emphasis>kld</emphasis>).  A kld is
a kernel component which can be loaded (and in some cases unloaded) while the
kernel is running.
</para>
</listitem>
<listitem>

<para>If no kld exists for your product, you will need to build a special
kernel&mdash;we'll look at what this entails in <xref linkend="CFBSD-chbuild"/>.
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>/dev</primary></indexterm>
Table <xref linkend="CFBSD-generic-supported-hardware"/> shows the hardware which the i386 generic
kernel supports.  New hardware support is being added all the time, so this
table can't be definitive.  Look in the file <emphasis>/stand/help/hardware.hlp.gz</emphasis>,
from which this table was derived, or, even better, in the configuration file
<emphasis>/usr/src/sys/i386/conf/LINT</emphasis> or <emphasis>/usr/src/sys/alpha/conf/LINT</emphasis> for
authoritative information for your release of FreeBSD.
<anchor id="CFBSD-supported-hardware"/>
<table frame='all'><title>Hardware supported by FreeBSD</title>
center,box,tab(#) ;
| lfCWp8 | cfCWp8 | cfCWp8 | cfCWp8 | cfCWp8 | lw45 | .
Device#Port#IRQ#DRQ#IOMem#Description
=

<tgroup cols='191' align='left' colsep='1' rowsep='1'><tbody>
<row><entry> fdc0</entry><entry>3f0</entry><entry>6</entry><entry>2</entry><entry></entry><entry> Floppy disk controller  wdc0</entry><entry>1f0</entry><entry>14</entry><entry></entry><entry></entry><entry> IDE/MFM/RLL disk controller  wdc1</entry><entry>170</entry><entry>15</entry><entry></entry><entry></entry><entry> IDE/MFM/RLL disk controller  ncr0</entry><entry></entry><entry></entry><entry></entry><entry></entry><entry> NCR PCI SCSI controller  bt0</entry><entry>330</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry> Buslogic SCSI controller  uha0</entry><entry>330</entry><entry>\s+4\(bu\s0</entry><entry>6</entry><entry>\s+4\(bu\s0</entry><entry> Ultrastore 14f  aha0</entry><entry>330</entry><entry>\s+4\(bu\s0</entry><entry>5</entry><entry>\s+4\(bu\s0</entry><entry> Adaptec 154x SCSI controller  ahb0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry> Adaptec 174x SCSI controller  ahc0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry> Adaptec 274x/284x/294x SCSI controller  amd0</entry><entry></entry><entry></entry><entry></entry><entry></entry><entry> Tekram DC-390(T) / AMD 53c974 PCI SCSI  aic0</entry><entry>340</entry><entry>11</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry> Adaptec 152x/AIC-6360 SCSI controller  nca0</entry><entry>1f88</entry><entry>10</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry> ProAudioSpectrum cards  sea0</entry><entry>\s+4\(bu\s0</entry><entry>5</entry><entry>\s+4\(bu\s0</entry><entry>c8000</entry><entry> Seagate ST01/02 8 bit controller  wt0</entry><entry>300</entry><entry>5</entry><entry>1</entry><entry>\s+4\(bu\s0</entry><entry> Wangtek and Archive QIC-02/QIC-36  mse0</entry><entry>23c</entry><entry>5</entry><entry></entry><entry></entry><entry> Microsoft Bus Mouse  psm0</entry><entry>60</entry><entry>12</entry><entry></entry><entry></entry><entry> PS/2 Mouse (disabled by default)  mcd0</entry><entry>300</entry><entry>10</entry><entry></entry><entry></entry><entry> Mitsumi CD-ROM  matcd0</entry><entry>230</entry><entry></entry><entry></entry><entry></entry><entry> Matsushita/Panasonic CD-ROM  scd0</entry><entry>230</entry><entry></entry><entry></entry><entry></entry><entry> Sony CD-ROM  sio0</entry><entry>3f8</entry><entry>4</entry><entry></entry><entry></entry><entry> Serial Port 0 (COM1)  sio1</entry><entry>2f8</entry><entry>3</entry><entry></entry><entry></entry><entry> Serial Port 1 (COM2)  lpt0</entry><entry>\s+4\(bu\s0</entry><entry>7</entry><entry></entry><entry></entry><entry> Printer Port 0  lpt1</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry></entry><entry></entry><entry> Printer Port 1  de0</entry><entry></entry><entry></entry><entry></entry><entry></entry><entry> DEC DC21x40 PCI based cards (including 21140 100bT cards)  ed0</entry><entry>280</entry><entry>5</entry><entry>\s+4\(bu\s0</entry><entry>d8000</entry><entry> WD &amp; SMC 80xx; Novell NE1000 &amp; NE2000; 3Com 3C503; HP PC Lan+  ed1</entry><entry>300</entry><entry>5</entry><entry>\s+4\(bu\s0</entry><entry>d8000</entry><entry> Same as ed0  eg0</entry><entry>310</entry><entry>5</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry> 3Com 3C505  ep0</entry><entry>300</entry><entry>10</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry> 3Com 3C509  ex0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry></entry><entry> Intel EtherExpress Pro/10 cards  fe0</entry><entry>300</entry><entry>\s+4\(bu\s0</entry><entry></entry><entry></entry><entry> Allied-Telesis AT1700, RE2000 and Fujitsu FMV-180 series cards.  fxp0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry></entry><entry>\s+4\(bu\s0</entry><entry> Intel EtherExpress Pro/100B  ie0</entry><entry>360</entry><entry>7</entry><entry>\s+4\(bu\s0</entry><entry>d0000</entry><entry> AT&amp;T StarLAN 10 and EN100; 3Com 3C507; NI5210  ix0</entry><entry>300</entry><entry>10</entry><entry>\s+4\(bu\s0</entry><entry>d0000</entry><entry> Intel EtherExpress cards  le0</entry><entry>300</entry><entry>5</entry><entry>\s+4\(bu\s0</entry><entry>d0000</entry><entry> Digital Equipment EtherWorks 2 and EtherWorks 3  lnc0</entry><entry>280</entry><entry>10</entry><entry></entry><entry>\s+4\(bu\s0</entry><entry> Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL)  vx0</entry><entry>\s+4\(bu\s0</entry><entry>\s+4\(bu\s0</entry><entry></entry><entry>\s+4\(bu\s0</entry><entry> 3Com 3c59x / 3c9xx  ze0</entry><entry>300</entry><entry>5</entry><entry></entry><entry>d8000</entry><entry> IBM/National Semiconductor PCMCIA Ethernet Controller  zp0</entry><entry>300</entry><entry>10</entry><entry></entry><entry>d8000</entry><entry> 3Com 3c589 Etherlink III PCMCIA Ethernet Controller
</entry></row>
</tbody></tgroup></table>
The device name in this table is the name by which the device is known to the
kernel.  It usually corresponds to a name in the <emphasis>/dev</emphasis> directory, but
network interfaces such as Ethernet boards do not have device nodes.  See
<xref linkend="CFBSD-chfilesys"/> for some other exceptions.
</para>

<para>If a field is marked with a bullet (<emphasis>\s+4\(bu\s0</emphasis>), the driver is capable
of determining the board settings by itself.  If the field is empty, this board
does not use this particular feature at all.  In addition to these controllers,
the source distribution contains drivers for a number of other controllers, as
shown in the following table.  There are a number of reasons for not including
these drivers in the generic kernel: they may still be experimental, or they
take up too much space in the kernel, or they may conflict with other devices.
When configuring a driver for a kernel build, you need to specify the addresses,
so I have not included any information here.  See the discussion of the
<emphasis>LINT</emphasis> configuration in <xref linkend="CFBSD-chbuild"/>, page
for further details.
<table frame='all'><title>Additional drivers supplied in source</title>
center,box,tab(#) ;
| lfCWp9 | lw75 | .
\s10Driver name#Description
=

<tgroup cols='29' align='left' colsep='1' rowsep='1'><tbody>
<row><entry> ctx</entry><entry> Cortex-I frame grabber  cx</entry><entry> Cronyx/Sigma multiport sync/async  cy</entry><entry> Cyclades high-speed serial driver  el</entry><entry> 3Com 3C501  fea</entry><entry> DEV DEFEA EISA FDDI adater  fpa</entry><entry> DEC DEFPA PCI FDDI adapter  gp</entry><entry> National Instruments AT-GPIB and AT-GPIB/TNT board  gsc</entry><entry> Genius GS-4500 hand scanner  gus</entry><entry> Gravis Ultrasound - Ultrasound, Ultrasound 16, Ultrasound MAX  gusxvi</entry><entry> Gravis Ultrasound 16-bit PCM  joy</entry><entry> Joystick  labpc</entry><entry> National Instrument's Lab-PC and Lab-PC+  meteor</entry><entry> Matrox Meteor frame-grabber card  mpu</entry><entry> Roland MPU-401 stand-alone card  mse</entry><entry> Logitech &amp; ATI InPort bus mouse ports  mss</entry><entry> Microsoft Sound System  nic</entry><entry> Dr Neuhaus NICCY 3008, 3009 &amp; 5000 ISDN cards  opl</entry><entry> Yamaha OPL-2 and OPL-3 FM - SB, SB Pro, SB 16, ProAudioSpectrum  pas</entry><entry> ProAudioSpectrum PCM and MIDI  pca</entry><entry> PCM audio (<emphasis>/dev/audio</emphasis>) through your PC speaker  psm</entry><entry> PS/2 mouse port  rc</entry><entry> RISCom/8 multiport card  sb</entry><entry> SoundBlaster PCM - SoundBlaster, SB Pro, SB16, ProAudioSpectrum  sbmidi</entry><entry> SoundBlaster 16 MIDI interface  sbxvi</entry><entry> SoundBlaster 16  spigot</entry><entry> Creative Labs Video Spigot video-acquisition board  uart</entry><entry> Stand-alone 6850 UART for MIDI  wds</entry><entry> Western Digital WD7000 IDE
</entry></row>
</tbody></tgroup></table>
</para>

<para></para>
</sect2>
<sect2>
<title>Supported hardware&mdash;Alpha architecture</title>

<para><indexterm><primary>Alpha</primary><secondary>supported hardware</secondary></indexterm>
FreeBSD/alpha supports the following alpha platforms:
</para>

<para>UDB, Multia, AXPpci33, Noname
EB164, PC164, PC164LX, PC164SX
EB64+, Aspen Alpine, etc.
AlphaStation 200, 250, 255, 400
AlphaStation 500, 600
Digital Personal Workstation 433, 500, 600
DEC3000/300 family (netboot only)
DEC3000/[4-9]00 family (netboot only)
</para>

<para>You need the SRM console firmware for your platform. In some cases, it is
possible to switch between AlphaBIOS (or ARC) firmware and SRM. In others it
will be necessary to download new firmware from
<emphasis>ftp.digital.com/pub/DEC/Alpha/firmware</emphasis>
</para>

<para>You need a dedicated disk for FreeBSD/alpha.  Currently FreeBSD can't share a
disk with another operating system.  This disk must be attached to a SCSI
controller which is supported by the SRM firmware (currently NCR or SYMBIOS and
Qlogic ISP).
</para>
</sect2>
</sect1>
<sect1>
<title>The CD-ROM distribution</title>

<para><anchor id="CFBSD-cdrom-distribution"/>
<indexterm><primary>Installation</primary><secondary>CD-ROM</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Installation</secondary></indexterm>
<indexterm><primary>Live</primary><secondary>File System CD-ROM</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Live File System</secondary></indexterm>
Walnut Creek CDROM distributes FreeBSD <xref linkend="CFBSD-Fver"/> on four CD-ROMs:
</para>
<itemizedlist>
<listitem>

<para>The <emphasis>Installation Boot CD, packages, X11</emphasis> CD-ROM.  It contains everything
you need to install the system itself.
</para>
</listitem>
<listitem>

<para><indexterm><primary>CD-ROM</primary><secondary>CVS Repository</secondary></indexterm>
<indexterm><primary>CVS</primary><secondary>Repository</secondary></indexterm>
The <emphasis>Live filesystem, CVS Repository, web pages</emphasis> CD-ROM.
</para>
</listitem>
<listitem>

<para>The <emphasis>Packages/ports</emphasis> CD-ROM.
</para>
</listitem>
<listitem>

<para><indexterm><primary>Docs</primary><secondary>and Extras</secondary></indexterm>
The <emphasis>Distribution tarballs and packages (overflow)</emphasis> CD-ROM.
</para>
</listitem>
</itemizedlist>

<para>All are mastered in ISO 9660 with Rock Ridge extensions (see page <xref linkend="CFBSD-RockRidge"/>
for an explanation of these terms).  We'll look at them in the following
sections.
</para>
<sect2>
<title>CD-ROM 1: Installation</title>

<para>The Installation CD-ROM contains everything you need to install FreeBSD on your
system.  It supplies two categories of installable software:
</para>
<itemizedlist>
<listitem>

<para>System software is stored as <emphasis>gzip</emphasis>ped <emphasis>tar</emphasis> archives in the
directories <emphasis>bin</emphasis>, <emphasis>catpages</emphasis>, <emphasis>compat1x</emphasis>, <emphasis>compat20</emphasis>,
<emphasis>compat21</emphasis>, <emphasis>des</emphasis>, <emphasis>dict</emphasis>, <emphasis>doc</emphasis>, <emphasis>games</emphasis>, <emphasis>info</emphasis>,
<emphasis>manpages</emphasis> and <emphasis>proflibs</emphasis>.  To facilitate transport to and installation
from floppy, the archives have been divided into chunks of 240,640 bytes.  For
example, the only required set is in the files <emphasis>bin/bin.aa</emphasis> to
<emphasis>bin/bin.cx</emphasis>.
</para>
</listitem>
<listitem>

<para><indexterm><primary>packages/All</primary></indexterm>
The directory <emphasis>packages/All</emphasis> contains ported, installable software
packages as <emphasis>gzip</emphasis>ped <emphasis>tar</emphasis> archives.  They are designed to be
installed directly on a running system, so they have not been divided into
chunks.  Due to size restrictions on the CD-ROM, this directory does not contain
all the packages: some of them are on the fourth CD-ROM.
</para>

<para><emphasis>packages/All</emphasis> contains well over 1000 packages.  To make it easier for you
to find your way around them, symbolic links to appropriate packages have been
placed in the directories <emphasis>archivers</emphasis>, <emphasis>astro</emphasis>, <emphasis>audio</emphasis>,
<emphasis>benchmarks</emphasis>, <emphasis>cad</emphasis>, <emphasis>chinese</emphasis>, <emphasis>comms</emphasis>, <emphasis>converters</emphasis>,
<emphasis>databases</emphasis>, <emphasis>devel</emphasis>, <emphasis>editors</emphasis>, <emphasis>emulators</emphasis>, <emphasis>games</emphasis>,
<emphasis>german</emphasis>, <emphasis>graphics</emphasis>, <emphasis>japanese</emphasis>, <emphasis>korean</emphasis>, <emphasis>lang</emphasis>,
<emphasis>mail</emphasis>, <emphasis>math</emphasis>, <emphasis>mbone</emphasis>, <emphasis>misc</emphasis>, <emphasis>net</emphasis>, <emphasis>news</emphasis>,
<emphasis>perl5</emphasis>, <emphasis>plan9</emphasis>, <emphasis>print</emphasis>, <emphasis>russian</emphasis>, <emphasis>security</emphasis>,
<emphasis>shells</emphasis>, <emphasis>sysutils</emphasis>, <emphasis>tcl75</emphasis>, <emphasis>tcl76</emphasis>, <emphasis>tcl80</emphasis>,
<emphasis>textproc</emphasis>, <emphasis>tk41</emphasis>, <emphasis>tk42</emphasis>, <emphasis>tk80</emphasis>, <emphasis>vietnamese</emphasis> and
<emphasis>www</emphasis>.  Don't get the impression that these are different packages&mdash;they
are really pointers to the packages in <emphasis>All</emphasis>.  You will find a list of the
currently available packages in the file <emphasis>/usr/ports/INDEX</emphasis>.
</para>
</listitem>
</itemizedlist>

<para>Table
lists the files in the main directory of the installation CD-ROM.
<table frame='all'><title>The installation CD-ROM</title>
center,box,tab(#) ;
| lfI | lw64 | .
File#Contents
=

<tgroup cols='1' align='left' colsep='1' rowsep='1'><tbody>
<row><entry>
</entry></row>
<indexterm><primary>VIEW</primary></indexterm>
<row><entry> 00_index.txt</entry><entry> A description of some of the files on the CD-ROM.
</entry></row>
<row><entry> ABOUT.TXT</entry><entry> A brief description of FreeBSD.
</entry></row>
<row><entry> ERRATA.TXT</entry><entry> A list of last-minute changes.  <emphasis>Read</emphasis> this file.  It can save you a lot of headaches.
</entry></row>
<row><entry> HARDWARE.TXT</entry><entry> A list of supported hardware.
</entry></row>
<row><entry> INSTALL.TXT</entry><entry> Information about installing FreeBSD.
</entry></row>
<row><entry> LAYOUT.TXT</entry><entry> A description of the CD-ROM layout.
</entry></row>
<row><entry> README.TXT</entry><entry> The traditional first file to read.  It describes how to use the other files.
</entry></row>
<row><entry> RELNOTES.TXT</entry><entry> Release notes.
</entry></row>
<row><entry> TRANS.TBL</entry><entry> Translation table for Rock Ridge, of no interest to anybody else.
</entry></row>
<row><entry> TROUBLE.TXT</entry><entry> Information on what to do if you run into trouble.
</entry></row>
<row><entry> UPGRADE.TXT</entry><entry> Notes on upgrading from older versions of FreeBSD.
</entry></row>
<row><entry> XF86333</entry><entry> Directory containing the XFree86 <xref linkend="CFBSD-Xver"/> distribution.  The release number may change in future releases of FreeBSD.
</entry></row>
<row><entry> bin</entry><entry> Installation directory: the binary distribution of the system.  This is the only required directory for installation.  See <xref linkend="CFBSD-chinstall"/>, for more detail.
</entry></row>
<!-- XXX -->
<row><entry>
</entry></row>
<row><entry> book</entry><entry> Information relating to this book, including the complete text in ASCII.
</entry></row>
<row><entry> catpages</entry><entry> Pre-formatted man pages.  See page <xref linkend="CFBSD-man"/> for more detail.
</entry></row>
<row><entry> cdrom.cfg</entry><entry> Machine-readable file describing the CD-ROM contents for the benefit of Microsoft programs.
</entry></row>
<row><entry> cdrom.inf</entry><entry> Machine-readable file describing the CD-ROM contents for the benefit of Microsoft programs.
</entry></row>
<row><entry> commerce</entry><entry> Commercial and shareware software for FreeBSD.  Some of these packages are demos, others are supplied with restricted licenses.  Read the file <emphasis>README</emphasis> in each subdirectory for more information.
</entry></row>
<row><entry> compat1x</entry><entry> Directory containing libraries to maintain compatibility with version 1.X of FreeBSD.
</entry></row>
<row><entry> compat20</entry><entry> Directory containing libraries to maintain compatibility with version 2.0 of FreeBSD.
</entry></row>
<row><entry> compat21</entry><entry> Directory containing libraries to maintain compatibility with version 2.1 of FreeBSD.
</entry></row>
<row><entry> des</entry><entry> Encryption software.  Until recently, this software could be distributed only in the USA and Canada.
</entry></row>
<row><entry> dict</entry><entry> Installation directory: dictionaries.
</entry></row>
<row><entry> doc</entry><entry> Installation directory: documentation.
</entry></row>
<row><entry> filename.txt</entry><entry> A list of all the files on this CD-ROM.
</entry></row>
<row><entry> floppies</entry><entry> A directory containing installation floppy disk images.
</entry></row>
<row><entry> games</entry><entry> Installation directory: games.
</entry></row>
<row><entry> info</entry><entry> Installation directory: GNU info documents.
</entry></row>
<row><entry> kernel</entry><entry> The boot kernel.
</entry></row>
<row><entry> makeflp.bat</entry><entry> A Microsoft <emphasis>.BAT</emphasis> file for copying floppy images to floppy.
</entry></row>
<row><entry> manpages</entry><entry> A directory containing the man pages for installation.
</entry></row>
<row><entry> packages</entry><entry> A directory containing installable versions of the Ports Collection.  See page <xref linkend="CFBSD-install-package"/>.
</entry></row>
<row><entry> ports</entry><entry> The sources for the  Ports Collection.  See <xref linkend="CFBSD-chports"/>, page <xref linkend="CFBSD-ports-collection"/>.
</entry></row>
<row><entry> proflibs</entry><entry> A directory containing profiled libraries, useful for identifying performance problems when programming.
</entry></row>
<row><entry> setup.exe</entry><entry> An Microsoft install program for installing from a running Microsoft system.
</entry></row>
<row><entry> setup.hlp</entry><entry> Help file for <emphasis>setup.exe</emphasis>.
</entry></row>
<row><entry> src</entry><entry> A directory containing the system source files.
</entry></row>
<row><entry> tools</entry><entry> A directory containing Microsoft tools to prepare for installation.
</entry></row>
<row><entry> utils</entry><entry> More Microsoft utilities.
</entry></row>
<row><entry> view.exe</entry><entry> An Microsoft based CD-ROM browser program.  See page <xref linkend="CFBSD-VIEW"/>.
</entry></row>
<row><entry> view.pif</entry><entry> \&amp;<emphasis>.PIF</emphasis> file for <emphasis>view.exe</emphasis>.
</entry></row>
<row><entry> xperimnt</entry><entry> A number of packages which are under development and were not ready for integration into FreeBSD at the time of release.
</entry></row>
</tbody></tgroup></table>
</para>
</sect2>
<sect2>
<title>CD-ROM 2: Live File System, CVS Repository, web pages</title>

<para><indexterm><primary>Live</primary><secondary>File System CD-ROM</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Live File System</secondary></indexterm>
Although the installation CD-ROM contains everything you need to install
FreeBSD, the format isn't what you'd like to handle every day.  The second
CD-ROM in the distribution, the <emphasis>Live File System</emphasis> CD-ROM, solves this
problem: it contains substantially the same data stored in file system format in
much the same way as you would install it on a hard disk.  You can access the
files directly from this CD-ROM.
</para>

<para>The second disk also contains the ``CVS Repository''.  The repository is the
master source tree of all source code, including all update information.  We'll
look at it in more detail in <xref linkend="CFBSD-chcurrent"/>, page <xref linkend="CFBSD-repository"/>.  This disk also
contains a snapshot of the Web pages at <emphasis>www.FreeBSD.org</emphasis> (directory
<emphasis>www</emphasis>).
</para>
</sect2>
<sect2>
<title>CD-ROMs 3 and 4: The Ports Collection</title>

<para><indexterm><primary>Ports</primary><secondary>Collection</secondary></indexterm>
An important part of FreeBSD is the <emphasis>Ports Collection</emphasis>, which comprises over
2000 popular programs.  The Ports Collection automates the process of porting
software to FreeBSD.  A combination of various programming tools already
available in the base FreeBSD installation allows you to simply type
<emphasis>make</emphasis> for a given package.  The ports mechanism does the rest, so you
need only enough disk space to build the ports you want.
<indexterm><primary>Ports</primary><secondary>Collection</secondary></indexterm>
We'll look at the Ports Collection in more detail in Chapter <xref linkend="CFBSD-nchports"/>.
The files are spread over 3 CD-ROMs:
</para>
<itemizedlist>
<listitem>

<para>You'll find the <emphasis>ports</emphasis>, the instructions for building the packages, on
CD-ROM 1.
</para>
</listitem>
<listitem>

<para>The base sources for the Ports Collection fill more than one CD-ROM, even though
we were not able to include all sources due to copyright restrictions: some
source files are freely distributable on the net, but may not be distributed on
CD-ROM.  Of the rest, most are on CD-ROM 3, with an overflow into CD-ROM 4.
</para>

<para>Don't worry about the missing sources: if you're connected to the Internet, the
Ports Collection will automatically retrieve the sources from an Internet server
when you type <emphasis>make</emphasis>.
</para>
</listitem>
<listitem>

<para>The <emphasis>packages</emphasis>, the precompiled binaries of the ports, are spread between
CD-ROM 1, which includes the most popular ones, and CD-ROM 4.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
</sect1>
<sect1>
<title>PC hardware</title>

<para>In this section, we'll look at the information you need to understand in order
to install FreeBSD on the i386 architecture.  In particular, we'll look at the
following topics:
</para>
<itemizedlist>
<listitem>

<para>How FreeBSD supports hardware, and what to do if your hardware doesn't
correspond to the system's expectations.
</para>
</listitem>
<listitem>

<para>How FreeBSD and other PC operating systems handle disk space, and how to set up
your disk for FreeBSD, starting on page
</para>
</listitem>
<listitem>

<para>How to share your disk with another operating system, starting on page
</para>
</listitem>
</itemizedlist>

<para>Some of this information also applies to the Alpha architecture.  In particular,
though, an installation on an Alpha machine is a dedicated installation: you
can't share it with other operating systems.
</para>
</sect1>
<sect1>
<title>How the system detects hardware</title>

<para><indexterm><primary>probing</primary></indexterm>
When the system starts, each driver in the kernel examines the system to find
any hardware which it might be able to control.  This examination is called
<emphasis>probing</emphasis>.  Depending on the driver, the probe may be clever enough to
recognize its hardware no matter how it has been set up, or it may expect the
hardware to be set up in a specific manner in order to find it.  If the driver
only looks at specific settings, you have three possibilities:
</para>
<itemizedlist>
<listitem>

<para>You can set the board to match what the driver expects, typically by setting
jumpers or using a vendor supplied diagnostic program to set on-board
configuration memory.
</para>
</listitem>
<listitem>

<para><indexterm><primary>UserConfig</primary></indexterm>
You can use <emphasis>UserConfig</emphasis> to tell the addresses to the driver when booting
the system.  UserConfig is a part of the kernel which allows  interactive
modification of the system configuration at boot time&mdash;we'll look at it in more
detail in <xref linkend="CFBSD-chinstall"/>, on page
</para>
</listitem>
<listitem>

<para>You can build a kernel to use the current board parameters.
</para>
</listitem>
</itemizedlist>

<para>There are four main parameters that you may need to set for PC controller
boards:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>port</primary><secondary>address</secondary></indexterm>
The <emphasis>port address</emphasis> is the address of the first of possibly several control
registers which the driver uses to communicate with the board.  It is normally
specified in hexadecimal, for example <emphasis>0x320</emphasis>.
</para>
<note>

<para>If you come from a Microsoft background, you might be more comfortable with the
notation <emphasis>320H</emphasis>.  The notation <emphasis>0x320</emphasis> comes from the C programming
language.  You'll see a lot of it in UNIX.
</para>
</note>

<para>Each board needs its own address or range of addresses.  The ISA architecture
does not supply many addresses, and one of the most frequent causes of problems
when installing a board is that the port addresses overlap with those of another
board.
</para>

<para>Beware of boards with a large number of registers.  Typical port addresses end
in (hexadecimal) <emphasis>0</emphasis>.  Don't rely on being able to take any unoccupied
address ending in <emphasis>0</emphasis>, though: some boards, such as Novell NE2000
compatible Ethernet boards, occupy up to 32 registers&mdash;in our example, from
<emphasis>0x320</emphasis> to <emphasis>0x33f</emphasis>.  Note also that a number of addresses, such as
the serial and parallel ports, often end in <emphasis>8</emphasis>.
</para>
</listitem>
<listitem>

<para><anchor id="CFBSD-IRQ"/>
<indexterm><primary>interrupt</primary><secondary>requests</secondary></indexterm>
<indexterm><primary>IRQ</primary></indexterm>
Boards use an <emphasis>Interrupt Request</emphasis>, also referred to as <emphasis>IRQ</emphasis>, to get the
attention of the driver when a specific event happens.  For example, when a
serial interface reads a character, it will generate an interrupt to tell the
driver to collect the character.  Interrupt requests can sometimes be shared,
depending on the driver and the hardware.  There are even fewer interrupt
requests than port addresses: a total of 15, of which a number are reserved by
the motherboard.  You can usually expect to be able to use IRQs 3, 4, 5, 7, 9,
10, 11, 12, 14 and 15, though some motherboards use IRQ 15 for power saving
hardware.  IRQ 2 is special: due to the design of the original IBM PC/AT, it is
the same thing as IRQ 9.  FreeBSD refers to this interrupt as IRQ 9.
</para>
</listitem>
<listitem>

<para><indexterm><primary>Direct</primary><secondary>Memory Access</secondary></indexterm>
<indexterm><primary>DMA</primary></indexterm>
<indexterm><primary>DMA</primary><secondary>Request</secondary></indexterm>
<indexterm><primary>DMA</primary><secondary>Acknowledge</secondary></indexterm>
<indexterm><primary>DMA</primary><secondary>Channel</secondary></indexterm>
Some high-speed devices perform <emphasis>Direct Memory Access</emphasis>, also known as
<emphasis>DMA</emphasis>, to transfer data to or from memory without CPU intervention.  In
order to transfer data, they assert a <emphasis>DMA Request</emphasis> (DRQ) and wait for the
bus to reply with a <emphasis>DMA Acknowledge</emphasis> (DACK).  The combination of DRQ and
DACK is sometimes called a <emphasis>DMA Channel</emphasis>.  The ISA architecture supplies 7
DMA channels, numbered 0 to 3 (8 bit) and and 5 to 7 (16 bit).  The floppy
driver uses DMA channel 2.  DMA channels may not be shared.
</para>
</listitem>
<listitem>

<para><indexterm><primary>memory</primary><secondary>I/O</secondary></indexterm>
<indexterm><primary>I/O</primary><secondary>memory</secondary></indexterm>
<indexterm><primary>IOmem</primary></indexterm>
Finally, controllers may have on-board memory which is usually located at
addresses between <emphasis>0xa0000</emphasis> and <emphasis>0xeffff</emphasis>.  This is sometimes
referred to as <emphasis>I/O memory</emphasis> or <emphasis>IOmem</emphasis>.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect1>
<sect1>
<title>Disks</title>

<para><anchor id="CFBSD-disk-hardware"/>
<indexterm><primary>IDE</primary></indexterm>
<indexterm><primary>modified</primary><secondary>frequency modulation</secondary></indexterm>
<indexterm><primary>MFM</primary></indexterm>
<indexterm><primary>RLL</primary></indexterm>
<indexterm><primary>encoding</primary><secondary>run length limited</secondary></indexterm>
<indexterm><primary>run</primary><secondary>length limited encoding</secondary></indexterm>
A number of different disks are used on current PCs:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>ST-506</primary></indexterm>
<indexterm><primary>cable</primary><secondary>control</secondary></indexterm>
<indexterm><primary>cable</primary><secondary>data</secondary></indexterm>
<indexterm><primary>control</primary><secondary>cable</secondary></indexterm>
<indexterm><primary>data</primary><secondary>cable</secondary></indexterm>
<emphasis>ST-506</emphasis> disks are the oldest.  You can tell them by the fact that they
have two cables: a <emphasis>control cable</emphasis> which usually has connections for two
disks, and a thinner <emphasis>data cable</emphasis> which is not shared with any other disk.
They're just about completely obsolete by now, but FreeBSD still supports them
with the <emphasis>wd</emphasis> driver.  These disks are sometimes called by their
modulation format, <emphasis>Modified Frequency Modulation</emphasis> or <emphasis>MFM</emphasis>.  A
variant of MFM which offers about 50% more storage is <emphasis>RLL</emphasis> or <emphasis>Run
Length Limited</emphasis> modulation.
</para>
</listitem>
<listitem>

<para><indexterm><primary>ESDI</primary></indexterm>
<indexterm><primary>Enhanced</primary><secondary>Small Device Interface</secondary></indexterm>
<indexterm><primary>AT</primary><secondary>Attachment</secondary></indexterm>
<indexterm><primary>ATA</primary></indexterm>
<emphasis>ESDI</emphasis> (<emphasis>Enhanced Small Device Interface</emphasis>) disks were designed to
work around some of the limitations of ST-506 drives.  They also use the same
cabling as ST-506, but they are not hardware compatible, though most ESDI
controllers understand ST-506 commands.  They are now also obsolete, but the
<emphasis>wd</emphasis> driver supports them, too.
</para>
</listitem>
<listitem>

<para><anchor id="CFBSD-504m-limit"/>
<indexterm><primary>IDE</primary></indexterm>
<indexterm><primary>Integrated</primary><secondary>Device Electronics</secondary></indexterm>
<anchor id="CFBSD-EIDE"/>
<indexterm><primary>EIDE</primary></indexterm>
<indexterm><primary>enhanced</primary><secondary>IDE</secondary></indexterm>
<emphasis>IDE</emphasis> (<emphasis>Integrated Device Electronics</emphasis>), now frequently called
<emphasis>ATA</emphasis> (<emphasis>AT Attachment</emphasis>), is the current low-cost PC disk interface.
The disks (still a maximum of 2) are connected by a single 40-conductor flat
cable.  From a software viewpoint, they are upwards compatible with the ST-506
drives.  Most modern disks are so-called <emphasis>EIDE</emphasis> (<emphasis>Enhanced IDE</emphasis>)
drives.  The original IDE disks are were limited by the BIOS standard to a size
of 504 MB (1024 * 16 * 63 * 512, or 528,482,304 bytes).  EIDE drives exceed this
limit, but to do so they play funny games to hide the fact from Microsoft.  FreeBSD
<xref linkend="CFBSD-Fver"/> uses a new driver for all IDE disks.
</para>

<para><indexterm><primary>programmed</primary><secondary>I/O</secondary></indexterm>
<indexterm><primary>PIO</primary></indexterm>
<anchor id="CFBSD-use-DMA"/>
A problem with older IDE controllers was that they used <emphasis>programmed I/O</emphasis>
or <emphasis>PIO</emphasis> to perform the transfer.  In this mode, the CPU is directly
involved in the transfer to or from the disk.  Older controllers transferred a
byte at a time, but more modern controllers can transfer in units of 32 bits.
Either way, disk transfers use a large amount of CPU time with programmed I/O,
and it's difficult to achieve the transfer rates of modern IDE drives, which can
be as high as 10 MB/s.  During such transfers, the system appears to be
unbearably slow: it ``grinds to a halt''.
</para>

<para>To solve this problem, modern chipsets offer DMA transfers, which almost
completely eliminate CPU overhead.  FreeBSD supports DMA with most modern
chipsets.  If your chipset supports DMA, you should enable it.  See page
<xref linkend="CFBSD-IDE-DMA"/> for details of how to do this.
</para>

<para>Another factor influencing IDE performance is the fact that an IDE controller
can only perform one transfer at a time.  If you have two disks on a controller,
and you want to access both, the controller serializes the requests so that a
request to one drive completes before the other started.  This results in worse
performance than on a SCSI chain, which does not have this restriction.  If you
have two disks and two controllers, it's better to put one disk on each
controller.
</para>
</listitem>
<listitem>

<para><indexterm><primary>SCSI</primary></indexterm>
<indexterm><primary>Small</primary><secondary>Computer Systems Interface</secondary></indexterm>
<indexterm><primary>host</primary><secondary>adapter</secondary></indexterm>
<indexterm><primary>wide</primary><secondary>SCSI</secondary></indexterm>
<emphasis>SCSI</emphasis> is the <emphasis>Small Computer Systems Interface</emphasis>.  It is used for
disks, tapes, CD-ROMs and also other devices such as scanners and printers.  The
SCSI controller is more correctly called a <emphasis>host adapter</emphasis>.  SCSI devices are
connected by a single flat cable, usually with 50 conductors, which connects a
total of 8 devices, including at least one host adapter.  A newer standard, Wide
SCSI, supports up to 16 devices and has a wider cable.  Some SCSI devices have
subdevices, for example CD-ROM changers.
</para>

<para>SCSI drives have a reputation for much higher performance than IDE.  This is
mainly due to the fact that nearly all SCSI host adapters support DMA, whereas
in the past IDE controllers usually used programmed I/O.  In addition, SCSI host
adapters can perform transfers from multiple units at the same time, whereas IDE
controllers can only perform one transfer at a time.  Typical SCSI drives are
still faster than IDE drives, but the difference is nowhere near as large as it
used to be.
</para>
</listitem>
</itemizedlist>

<para>On the Alpha architecture, only SCSI drives are completely supported.  It should
be possible to use IDE drives as well once the system is running, but you can't
boot from them.
</para>

<para>Before you install FreeBSD, you need to decide how you want to use the disk
space available to you.  If desired, FreeBSD will coexist with other operating
systems.  In this section, we'll look at the way data is laid out on disk, and
what we need to do to create FreeBSD file systems on disk.
</para>
<sect2>
<title>PC BIOS and disks</title>

<para><indexterm><primary>read/write</primary><secondary>head</secondary></indexterm>
<indexterm><primary>head</primary><secondary>read/write</secondary></indexterm>
The basics of disk drives are relatively straightforward: data is stored on one
or more rotating disks with a magnetic coating similar in function to the
coating on an audio tape.  Unlike a tape, however, disk heads do not touch the
surface: the rotating disk produces an air pressure against the head which keeps
it floating very close to the surface.  The disk transfers data to and from the
disk via (usually) one <emphasis>read/write head</emphasis> for each surface.  People
frequently talk about the number of heads, not the number of surfaces, though
strictly speaking this is incorrect: if there are two heads per surface (to
speed up access), you're still interested in the number of surfaces, not the
number of heads.
</para>

<para><indexterm><primary>track</primary></indexterm>
<indexterm><primary>sectors</primary></indexterm>
<indexterm><primary>cylinder</primary></indexterm>
While transferring data, the heads are stationary, so data is written on disks
in a number of circular <emphasis>tracks</emphasis>.  Logically, each track is divided into a
number of <emphasis>sectors</emphasis>, which nowadays almost invariably contain 512 bytes.
A single positioning mechanism moves the heads from one track to another, so at
any one time all the tracks under the current head position can be accessed
without repositioning.  This group of tracks is called a <emphasis>cylinder</emphasis>.
</para>

<para><indexterm><primary>Logical</primary><secondary>Block Addressing</secondary></indexterm>
<anchor id="CFBSD-LBA"/>
<indexterm><primary>LBA</primary></indexterm>
<indexterm><primary>CHS</primary></indexterm>
To access older drives, such as ST-506 (MFM and RLL) drives, you needed to tell
the drive which cylinder, head and sector to address.  This mode of addressing
is thus called <emphasis>CHS</emphasis> addressing.  Even today, BIOS setup routines give you
the option of specifying information about disk drives in terms of the numbers
of cylinders, heads and sectors, and some insist on it.  In fact, modern disk
drives no longer have a fixed number of sectors per track, and they address
blocks sequentially, so-called <emphasis>Logical Block Addressing</emphasis> or <emphasis>LBA</emphasis>.
CHS addressing has an additional problem: the ST-506 hardware definition allows
up to 1024 cylinders, 16 heads, and 63 sectors, which limits the addressibility
of the drive to 504 MB.
</para>

<para>SCSI drives are a different matter: the BIOS doesn't know anything about them.
They are always addressed as a sequential list of sectors.  It's up to the host
adapter (or, in the case of dumb host adapters such as the Seagate ST02, the
driver software) to interrogate the drive and find out how much space is on it.
Typically, the host adapter will have a BIOS which interrogates the drive and
finds its dimensions.  The values it determines may not be correct: the
Microsoft 1 GB address limit (see page <xref linkend="CFBSD-1GB-limit"/>) might bite you.  Check
your controller documentation for details.
</para>
</sect2>
<sect2>
<title>Logical and physical disk drives</title>

<para><anchor id="CFBSD-partitions"/>
<indexterm><primary>disk</primary><secondary>drives</secondary></indexterm>
<indexterm><primary>disk</primary><secondary>drives</secondary></indexterm>
<indexterm><primary>logical</primary><secondary>disk drives</secondary></indexterm>
<indexterm><primary>physical</primary><secondary>disk drives</secondary></indexterm>
The PC world makes a distinction between <emphasis>logical disk drives</emphasis> and
<emphasis>physical disk drives</emphasis>.  Physical disks are easy enough to understand, of
course, but the term <emphasis>logical drive</emphasis> needs some explanation.  It refers to
a subdivision of a physical disk to which you can refer as if it were a disk by
itself.
</para>

<para><indexterm><primary>partitions</primary></indexterm>
<indexterm><primary>partition</primary><secondary>table</secondary></indexterm>
Microsoft divides a disk into up to four <emphasis>partitions</emphasis>, headed by a <emphasis>partition
table</emphasis>.  FreeBSD uses the term <emphasis>partition</emphasis> differently, as we will see,
so it refers to Microsoft's partitions as <emphasis>slices</emphasis>.
<indexterm><primary>slice</primary><secondary>defined</secondary></indexterm>
<anchor id="CFBSD-define-slice"/>
</para>
<note>

<para>This double usage of the word <emphasis>partition</emphasis> is really confusing.  In this
book, I follow BSD usage, but I will continue to refer to the partition table by
that name.
</para>
</note>

<para>Partitioning offers the flexibility that other operating systems need, so it has
been adopted by all operating systems that run on the PC platform.  Figure
<xref linkend="CFBSD-MS-partition-table"/> shows a disk with all four slices allocated.
</para>

<para>h = .2i
dh = .02i
dw = 2i
boxht = .4i
move right 2.35i
down
[
        [
                boxwid = dw
          M:    box ht .15i "Master Boot Record"
          P:    box ht .15i "Partition Table"
          A:    box ht boxht
          B:    box ht boxht
          C:    box ht boxht
          D:    box ht boxht
		"Partition (slice) 1" at A above
		"<emphasis>/dev/da0s1</emphasis>" at A below
		"Partition (slice) 2" at B above
		"<emphasis>/dev/da0s2</emphasis>" at B below
		"Partition (slice) 3" at C above
		"<emphasis>/dev/da0s3</emphasis>" at C below
		"Partition (slice) 4" at D above
		"<emphasis>/dev/da0s4</emphasis>" at D below
                ]
]
</para>

<para><figure><title>Partition table</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
<indexterm><primary>partition</primary><secondary>table</secondary></indexterm>
<indexterm><primary>partition</primary><secondary>active</secondary></indexterm>
The <emphasis>Partition Table</emphasis> is the most important data structure.  It contains
information about the size, location and type of the slices (Microsoft partitions).
In Microsoft, one of these slices may be designated as <emphasis>active</emphasis>: at system
startup time, its bootstrap record will be used to start the system.
</para>

<para><indexterm><primary>master</primary><secondary>boot record</secondary></indexterm>
<indexterm><primary>MBR</primary></indexterm>
Although it is not as important as the partition table, the <emphasis>Master Boot
Record</emphasis> (<emphasis>MBR</emphasis>) is located at the very beginning of the disk to make
it easier for the system BIOS to find it at boot time.  It contains code
necessary to find the correct slice from which to boot, so normally you need it
only on the first disk in the system.  The MBR and the partition table take up
the first sector on disk.
</para>

<para><indexterm><primary>Microsoft</primary><secondary>partition</secondary></indexterm>
<indexterm><primary>primary</primary><secondary>Microsoft partition</secondary></indexterm>
<indexterm><primary>extended</primary><secondary>Microsoft partition</secondary></indexterm>
Microsoft designates one slice as the <emphasis>primary Microsoft partition</emphasis>, the
<emphasis>C:</emphasis> drive.  Another slice may be designated as an <emphasis>extended Microsoft
partition</emphasis>, which contains the other ``drives'' (all together in one slice).
</para>

<para><indexterm><primary>file</primary><secondary>systems</secondary></indexterm>
<indexterm><primary>swap</primary><secondary>partition</secondary></indexterm>
<indexterm><primary>UNIX</primary><secondary>partitions</secondary></indexterm>
<indexterm><primary>partitions</primary><secondary>UNIX</secondary></indexterm>
<indexterm><primary>da0</primary><secondary>device</secondary></indexterm>
<indexterm><primary>device</primary><secondary>da0</secondary></indexterm>
UNIX systems have their own form of partitioning, which predates Microsoft and is
not compatible with the Microsoft method.  As a result, all versions of PC UNIX
which can coexist with Microsoft implement their own partitioning within a single
slice (Microsoft partition).  BSD systems define up to 8 partitions per slice.
They can be used for the following purposes:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>file</primary><secondary>system</secondary></indexterm>
A partition can be a <emphasis>file system</emphasis>, a structure in which UNIX stores files.
</para>
</listitem>
<listitem>

<para><indexterm><primary>swap</primary><secondary>partition</secondary></indexterm>
It can be used as a <emphasis>swap partition</emphasis>.  FreeBSD uses virtual memory: the
total addressed memory in the system can exceed the size of physical memory, so
we need space on disk to store memory pages which don't fit into physical
memory.
</para>
</listitem>
<listitem>

<para>The partition may not be within the slice at all: it may refer to other parts of
the physical disk.  In this case, it will probably overlap other partitions, and
you can't use it for file systems or swap space.  For obvious reasons, the
partitions which represent file systems and swap space (<emphasis>a</emphasis>, <emphasis>b</emphasis>,
and <emphasis>d</emphasis> through <emphasis>h</emphasis>) should not overlap.
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>character</primary><secondary>device</secondary></indexterm>
<indexterm><primary>device</primary><secondary>character</secondary></indexterm>
In order to understand the naming, you need to understand how UNIX treats disks.
As we have seen, you can think of a disk as a large number of sequential blocks
of data.  Looking at it like this doesn't give you a file system&mdash;it's more
like treating it as a tape.  UNIX calls this kind of access <emphasis>raw</emphasis> access.
You'll also hear the term <emphasis>character device</emphasis>.
</para>

<para>Normally, of course, you want files on your disk: you don't care where they are,
you just want to be able to open them and manipulate them.  This involves a
whole lot more work than raw devices.
<indexterm><primary>block</primary><secondary>device</secondary></indexterm>
<indexterm><primary>device</primary><secondary>block</secondary></indexterm>
The standard term for disks is <emphasis>block device</emphasis>.  You can recognize block
and character devices in an <emphasis>ls -l</emphasis> listing by the letters <emphasis>b</emphasis> and
<emphasis>c</emphasis> at the beginning of the permissions.  For example:
</para>
<programlisting>
$ <command>ls -l /dev/rwd0s1a   /dev/wd0s1a</command>
crw-r-----  1 root  operator    3, 131072 Oct 31 19:59 /dev/rwd0s1a
brw-r-----  1 root  operator    0, 131072 Oct 31 19:59 /dev/wd0s1a
</programlisting>

<para>Let's look more carefully at how BSD names its partitions:
</para>
<itemizedlist>
<listitem>

<para>Like all other devices, the device entries are stored in the directory
<emphasis>/dev</emphasis>.
</para>
</listitem>
<listitem>

<para>If the partition is raw (character), the name starts with the letter <emphasis>r</emphasis>.
If it isn't, there is no prefix.
</para>
</listitem>
<listitem>

<para>Next comes the name of the driver.  As we have seen, FreeBSD has drivers for IDE
and friends (<emphasis>wd</emphasis>), SCSI disks (<emphasis>da</emphasis>) and floppy disks (<emphasis>fd</emphasis>).
With our first SCSI disks, we now have the names <emphasis>/dev/rda</emphasis> and
<emphasis>/dev/da</emphasis>.
</para>
<note>

<para>The abbreviation <emphasis>wd</emphasis> arose because the most popular of the original MFM
controllers were made by Western Digital.  Others claim, however, that it's an
abbreviation for ``Winchester Disk''.  The name <emphasis>da</emphasis> comes from the CAM
standard and is short for <emphasis>direct access</emphasis>.
</para>
</note>

<para></para>
</listitem>
<listitem>

<para>Next comes the unit number, generally a single digit.  For example, the first
SCSI disk on the system would normally be called <emphasis>/dev/da0</emphasis>.
</para>
<note>

<para>Generally, the numbers are assigned during the boot probes, but you can reserve
numbers for SCSI disks if you want.  This prevents the absence of a single disk
from changing the numbers of all subsequent drives.  See page <xref linkend="CFBSD-wiring"/> for
more details.
</para>
</note>

<para>This gives us the names <emphasis>/dev/rda0</emphasis> and <emphasis>/dev/da0</emphasis>.
</para>
</listitem>
<listitem>

<para><indexterm><primary>slice</primary><secondary>name</secondary></indexterm>
<indexterm><primary>strict</primary><secondary>slice name</secondary></indexterm>
Next comes the partition information.  The so-called <emphasis>strict slice name</emphasis>
is specified by adding the letter <emphasis>s</emphasis> (for <emphasis>slice</emphasis>) and the slice
number (1 to 4) to the disk name.  BSD systems name partitions by appending the
letters <emphasis>a</emphasis> to <emphasis>h</emphasis> to the disk name.  Thus, the first partition of
the first slice of our disk above (which would typically be a root file system)
would be called <emphasis>/dev/rda0s1a</emphasis> and <emphasis>/dev/da0s1a</emphasis>.  Partition <emphasis>c</emphasis>
is an exception: by convention, it represents the whole BSD disk (in this case,
the slice in which FreeBSD resides).
</para>

<para><indexterm><primary>compatibility</primary><secondary>slice name</secondary></indexterm>
<indexterm><primary>slice</primary><secondary>name</secondary></indexterm>
Other versions of BSD use a more relaxed terminology for the partition name:
they omit the slice information.  Instead of calling the root file system
<emphasis>/dev/da0s1a</emphasis>, they refer to it as <emphasis>/dev/da0a</emphasis>.  FreeBSD supports this
method as well&mdash;it's called <emphasis>compatibility slice naming</emphasis>, and it's the
form you'll see most frequently.
</para>
</listitem>
</itemizedlist>

<para>Table
gives you an overview of the devices which FreeBSD defines for a single physical
disk <emphasis>/dev/da0</emphasis>:
<anchor id="CFBSD-disk-partitions"/>
<table frame='all'><title>Disk partition terminology</title>
center,box,tab(#) ;
| lfCWp9 | lw64 | .
\s10Slice name#Usage
=

<tgroup cols='46' align='left' colsep='1' rowsep='1'><tbody>
<row><entry> /dev/rda0</entry><entry> Whole disk, raw access  /dev/rda0s1</entry><entry> First slice (Microsoft ``partition''), raw access  /dev/rda0s1a</entry><entry> First slice (Microsoft ``partition''), partition a, raw access  /dev/rda0s1b</entry><entry> First slice (Microsoft ``partition''), partition b, raw access  /dev/rda0s1d</entry><entry> First slice (Microsoft ``partition''), partition d, raw access  /dev/rda0s1e</entry><entry> First slice (Microsoft ``partition''), partition e, raw access  /dev/rda0s1f</entry><entry> First slice (Microsoft ``partition''), partition f, raw access  /dev/rda0s1g</entry><entry> First slice (Microsoft ``partition''), partition g, raw access  /dev/rda0s1h</entry><entry> First slice (Microsoft ``partition''), partition h, raw access  /dev/rda0s2</entry><entry> Second slice (Microsoft ``partition''), raw access  /dev/rda0s3</entry><entry> Third slice (Microsoft ``partition''), raw access  /dev/rda0s4</entry><entry> Fourth slice (Microsoft ``partition''), raw access  /dev/rda0s5</entry><entry> First drive in extended Microsoft partition, raw access  /dev/rda0s6</entry><entry> Second drive in extended Microsoft partition, raw access  /dev/rda0s7</entry><entry> Third drive in extended Microsoft partition, raw access  /dev/rda0a</entry><entry> First partition of BSD slice, usually root file system, raw access  /dev/rda0b</entry><entry> Second partition of BSD slice, usually swap space, raw access  /dev/rda0c</entry><entry> Whole BSD slice, raw access  /dev/rda0d</entry><entry> Additional file system, raw access  /dev/rda0e</entry><entry> <emphasis>/usr</emphasis> file system, raw access  /dev/rda0f</entry><entry> Additional file system, raw access  /dev/rda0g</entry><entry> Additional file system, raw access  /dev/rda0h</entry><entry> Additional file system, raw access  /dev/da0s1</entry><entry> First slice (Microsoft ``partition'')  /dev/da0s1a</entry><entry> First slice (Microsoft ``partition''), partition a  /dev/da0s1b</entry><entry> First slice (Microsoft ``partition''), partition b  /dev/da0s1d</entry><entry> First slice (Microsoft ``partition''), partition d  /dev/da0s1e</entry><entry> First slice (Microsoft ``partition''), partition e  /dev/da0s1f</entry><entry> First slice (Microsoft ``partition''), partition f  /dev/da0s1g</entry><entry> First slice (Microsoft ``partition''), partition g  /dev/da0s1h</entry><entry> First slice (Microsoft ``partition''), partition h  /dev/da0s2</entry><entry> Second slice (Microsoft ``partition'')  /dev/da0s3</entry><entry> Third slice (Microsoft ``partition'')  /dev/da0s4</entry><entry> Fourth slice (Microsoft ``partition'')  /dev/da0s5</entry><entry> First drive in extended Microsoft partition  /dev/da0s6</entry><entry> Second drive in extended Microsoft partition  /dev/da0s7</entry><entry> Third drive in extended Microsoft partition  /dev/da0a</entry><entry> First partition of BSD slice, usually root file system  /dev/da0b</entry><entry> Second partition of BSD slice, usually swap space  /dev/da0c</entry><entry> Whole BSD slice  /dev/da0d</entry><entry> Additional file system  /dev/da0e</entry><entry> <emphasis>/usr</emphasis> file system  /dev/da0f</entry><entry> Additional file system  /dev/da0g</entry><entry> Additional file system  /dev/da0h</entry><entry> Additional file system
</entry></row>
</tbody></tgroup></table>
In the interests of space, I haven't included the names of possible FreeBSD
partitions in slices 1, 2, and 3.
</para>

<para></para>

<para>h = .2i
dh = .02i
dw = 1.7i
move right .5i
down
[
	boxht = h; boxwid = 1.8i
	box ht .15i "Master Boot Record"
        box ht .15i "Partition Table"
    P1: box ht .4i
    P2: box ht .4i
    P3: box ht .4i

	move right 1.6i from P1.ne
	boxwid = 2i
	down
     C: box ht .25i "Microsoft <emphasis>C:</emphasis> drive"
	move .1i
     D: box ht .25i "Microsoft <emphasis>D:</emphasis> drive <emphasis>/dev/da0s5</emphasis>"
     E: box ht .25i "Microsoft <emphasis>E:</emphasis> drive <emphasis>/dev/da0s6</emphasis>"

	move .25i
    FA: box ht .2i "disk label and bootstrap"
        box ht .2i "<emphasis>/dev/da0s3a</emphasis>: <emphasis>/</emphasis> file system"
        box ht .2i "<emphasis>/dev/da0s3b</emphasis>: swap"
        box ht .2i "<emphasis>/dev/da0s3d</emphasis>"
	box ht .2i "<emphasis>/dev/da0s3e</emphasis>: <emphasis>/usr</emphasis> file system"
        box ht .2i "<emphasis>/dev/da0s3f</emphasis>"
        box ht .2i "<emphasis>/dev/da0s3g</emphasis>"
        box ht .2i "<emphasis>/dev/da0s3h</emphasis>"

	arrow from P1.e to C.w
	arrow from P2.e to D.w
	arrow from P3.e to FA.w
	move up .08i from P1.c	"Slice 1 - Microsoft primary"
	move down .08i from P1.c  "<emphasis>/dev/da0s1</emphasis>"
	move up .08i from P2.c	"Slice 2 - Microsoft extended"
	move down .08i from P2.c  "<emphasis>/dev/da0s2</emphasis>"
	move up .08i from P3.c	"Slice 3 - FreeBSD"
	move down .08i from P3.c  "<emphasis>/dev/da0s3</emphasis>"
	]
</para>

<para><figure><title>Partition table with FreeBSD file system</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
Figure <xref linkend="CFBSD-shared-partitions"/> shows a typical layout on a system with a single
SCSI disk, shared between Microsoft and FreeBSD.  You'll note that partition
<emphasis>/dev/da0s3c</emphasis> is missing from the FreeBSD slice, since it isn't a real
partition.  Like the Microsoft partition table, the disk label contains information
necessary for FreeBSD to manage the FreeBSD slice, such as the location and the
lengths of the individual partitions.  The bootstrap is needed to load the
kernel into memory.  If you install the FreeBSD boot manager, it uses the slice
which was active at the time of installation, even when booting from other
slices.  This is not the only way things could have been done, but it makes life
easier, since the size of the MBR is limited.  If you remove FreeBSD from your
system, you will need to either replace the MBR or to create a dummy FreeBSD
slice with a bootstrap record only.
</para>
<note>

<para><indexterm><primary>FDISK</primary><secondary>MS-DOS command</secondary></indexterm>
<indexterm><primary>MS-DOS</primary><secondary>command</secondary></indexterm>
<indexterm><primary>Master</primary><secondary>Boot Record</secondary></indexterm>
<indexterm><primary>MBR</primary></indexterm>
If you need to replace the MBR, and you no longer have FreeBSD installed, you
can use the MS-DOS <emphasis>FDISK</emphasis> command to do this:
	<emphasis>C: </emphasis><command>FDISK /MBR</command>
</para>
</note>

<para>This command doesn't change the partition table: it only writes the Master Boot
Record.
<!--  .H 3 "Partition table or no partition table?" -->
<!--  Often, this subdivision seems to be overkill.  If you only want to run FreeBSD -->
<!--  on the disk, you need a master boot record, a partition table with only one -->
<!--  partition, and this partition is further subdivided into eight partitions, which are -->
<!--  really just another name for partition.  So what good is the partition table? -->
<!--  None.  You can do without it.  You only need a partition table if you're going -->
<!--  to share the disk between FreeBSD and other operating systems. -->
</para>
</sect2>
</sect1>
<sect1>
<title>Making the file systems</title>

<para><anchor id="CFBSD-make-fs"/>
Armed with this knowledge, we can now proceed to make some decisions about how
to install our systems.  First, we need to answer a number of questions:
</para>
<itemizedlist>
<listitem>

<para>Do we want to share this disk with any other operating system?
</para>
</listitem>
<listitem>

<para>If so, do we have data on this disk which we want to keep?
</para>
</listitem>
</itemizedlist>

<para></para>

<para><indexterm><primary>FDISK</primary><secondary>MS-DOS command</secondary></indexterm>
<indexterm><primary>MS-DOS</primary><secondary>command</secondary></indexterm>
If you already have another system installed on the disk, it is best to use that
system's tools for manipulating the partition table.  FreeBSD does not normally
have difficulty with partition tables created by other systems, so you can be
reasonably sure that the other system will understand what it has left.  If the
other system is Microsoft, and you have a slice which you don't need, you use the
MS-DOS <emphasis>FDISK</emphasis> program to free up enough space for you to install FreeBSD.
If you don't have a slice to delete, you can use the <emphasis>FIPS</emphasis> program to
create one&mdash;see <xref linkend="CFBSD-chinstall"/>, page
</para>

<para><indexterm><primary>fdisk</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>fdisk</secondary></indexterm>
<anchor id="CFBSD-fdisk"/>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
If for some reason you can't use MS-DOS <emphasis>FDISK</emphasis>, for example because you're
installing FreeBSD by itself, FreeBSD also supplies a program called
<emphasis>fdisk</emphasis> which manipulates the partition table.  Normally you will invoke
it indirectly via the <emphasis>sysinstall</emphasis> program&mdash;see page
<xref linkend="CFBSD-building-partition-table"/>.
</para>
</sect1>
<sect1>
<title>Using a boot manager</title>

<para><indexterm><primary>boot</primary><secondary>manager</secondary></indexterm>
If you choose to share your disk between FreeBSD and another operating system,
you need to make an additional decision every time you boot the machine: which
operating system do you want to run?  FreeBSD helps you make this decision with
<emphasis>booteasy</emphasis>, a so-called <emphasis>Boot Manager</emphasis>, which is installed in the
Master Boot Record.  If you install <emphasis>booteasy</emphasis>, it will prompt you for the
system to install every time you boot the system, for example:
</para>
<programlisting>
F1  .  .  .  BSD
F2  .  .  .  DOS
F5  .  .  .  Disk 2

Default: F1
</programlisting>

<para>When you boot the system, it records what slice you booted from, and offers it
as a default the next time you boot&mdash;in this case, it suggests <keycap>F1</keycap> for
FreeBSD.  If you don't respond within 10 seconds, it will accept this default
automatically and boot the system accordingly.
</para>

<para>If you're only running one system on the disk, the boot manager will still work,
but it just holds you up.  When you come to specify the choice of MBR, you
should specify a standard MBR, which will just boot from the currently active
slice.  See <xref linkend="CFBSD-chinstall"/>, page
for further details.
</para>
</sect1>
<sect1>
<title>Interaction with Microsoft</title>

<para><anchor id="CFBSD-DOS-interaction"/>
If you're coming from a Microsoft or a similar operational environment, you
might find things strange at first.  In particular, you'll probably want to
share programs and data between the two systems.  You can do this if you have an
i386 architecture machine, but not with the Alpha.  In the following sections,
we'll examine what you can and can't do.
</para>
<sect2>
<title>Sharing a disk with Microsoft</title>

<para>If you wish, you can install both Microsoft and FreeBSD on the same disk, subject
to space constraints. We will go into great depth about how to do this in
<xref linkend="CFBSD-chshareinstall"/>, page
</para>
</sect2>
<sect2>
<title>Using compressed MS-DOS file systems from FreeBSD</title>

<para><indexterm><primary>Stacker</primary><secondary>MS-DOS command</secondary></indexterm>
<indexterm><primary>DoubleSpace</primary><secondary>MS-DOS command</secondary></indexterm>
If you are using a utility such as <emphasis>Stacker</emphasis>\(tm or
<emphasis>DoubleSpace</emphasis>\(tm, FreeBSD will only be able to use whatever portion of
the file system you leave uncompressed.  The rest of the file system will show up
as one large file with a funny name.  Don't let this confuse you: this file is
<emphasis>not</emphasis> superfluous, it's everything you have.
</para>

<para>Your best choice here is to leave one Microsoft partition uncompressed and use it
for communications between Microsoft and FreeBSD.
</para>
</sect2>
<sect2>
<title>Running Microsoft binaries under FreeBSD</title>

<para><indexterm><primary>pcemu</primary></indexterm>
FreeBSD has very limited support for running Microsoft binaries.  Work is in
progress, but at the moment only two packages are available, both in the Ports
Collection:
</para>
<itemizedlist>
<listitem>

<para><emphasis>pcemu</emphasis> runs under the X Window System and emulates an 8088 and enough
BIOS services to run MS-DOS text mode applications.
</para>
</listitem>
<listitem>

<para><indexterm><primary>WINE</primary></indexterm>
<indexterm><primary>Windows</primary><secondary>Emulator</secondary></indexterm>
<emphasis>WINE</emphasis> (<emphasis>Windows Emulator</emphasis>) can run some Windows applications.  It's
still more experimental than usable.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
</sect1>
<sect1>
<title>Disk size limitations</title>

<para>Disk storage capacity has grown by an order of magnitude in the last few years.
As it did so, a number of limits became apparent:
</para>
<itemizedlist>
<listitem>

<para>The first was the BIOS <emphasis>504 MB limit</emphasis> on IDE disks, imposed by their
similarity with ST-506 disks, and discussed on page <xref linkend="CFBSD-504m-limit"/>.  Microsoft
and other vendors work around this problem in much the same way as FreeBSD:
after starting, they load their own driver and disable the BIOS, so they can
address disks up to (normally) 8 GB with no problems.  The only problem is
booting: you must boot from the first 504 MB.  If your BIOS has this limitation,
you will not be able to boot FreeBSD reliably from a root file system on an IDE
if it goes beyond this limit.  See below for one solution.
</para>
</listitem>
<listitem>

<para><anchor id="CFBSD-1GB-limit"/>
The next limit was the 1 GB limit, which affected some older SCSI host adapters.
Although SCSI drives always use LBA addressing internally, the BIOS needed to
simulate CHS addressing for Microsoft.  Early BIOSes were limited to 64 heads,
32 sectors and 1024 tracks (64 \(mu 32 \(mu 1024 \(mu 512 = 1 GB).  This
wouldn't be such a problem, except that modern Adaptec controllers offer a 1 GB
compatibility option.  Don't use it: it's only needed for systems which were
installed with the old mapping.
</para>
</listitem>
<listitem>

<para>After that, it's logical that the next limit should come at 2 GB.  There are
several different problems here.  The only one which affects FreeBSD appears to
be a bug in some IDE controllers, which don't work beyond this limit.  All of
these are old, and IDE controllers don't cost anything, so if you are sure you
have this problem, you can solve it by replacing the controller.  In the
process, make sure you get one which supports DMA.
</para>

<para>Other systems, including UNIX System V, have problems with this limit because
2\u\s-431\s0\d is the largest number which can be represented in a 32 bit signed
integer.  FreeBSD does not have this limitation, since file sizes are
represented in 64 bit quantities.
</para>
</listitem>
<listitem>

<para>At 4 GB, some IDE controllers have problems because they convert this to a CHS
mapping with 256 heads, which doesn't work: the largest number is 255.  Again,
if you're sure this is the cause of problems you may be having, a new controller
can help.
</para>
</listitem>
<listitem>

<para>Finally, at 8 GB, the CHS system runs out of steam.  It can't describe more than
1024 cylinders, 255 heads or 63 sectors.  Beyond this size, you must use LBA
addressing&mdash;if your BIOS supports it.
</para>
</listitem>
</itemizedlist>

<para>Most of these problems don't affect FreeBSD directly, but FreeBSD uses the
system BIOS to load the first bootstrap, so it is bound by the restrictions of
the BIOS and the controller.  If you have the choice, use LBA addressing.
Unfortunately, you can't do so if the disk already contains software which uses
CHS addressing.
</para>

<para>What do you do if you have an old-style BIOS with the 504 MB limit, a 2 GB IDE
disk and you want to allocate 1.3 GB for Microsoft and 700 MB for FreeBSD?
Clearly, whichever way round you put the slices, you can't get them both in the
first 504 MB.  In this case, you should allocate a reasonably sized primary
partition for Microsoft, for example 400 MB, then your FreeBSD slice, then a
Microsoft extended partition for the remaining 900 MB, as shown in figure
<anchor id="CFBSD-EIDE-layout"/>
</para>

<para>h = .2i
dh = .02i
dw = 2i
move right .5i
down
[
        [
                boxht = h; boxwid = dw
          M:    box ht .15i "Master Boot Record"
          P:    box ht .15i "Partition Table"
          A:    box ht .4i
          B:    box ht .7i
          C:    box ht 1.1i
		"<emphasis>C:</emphasis>" at A
		"<keycap>Microsoft primary partition</keycap>" at A.e+(.9i,0)  ljust
		"<keycap>FreeBSD slice</keycap>" at B.e+(.9i,-.125i)  ljust
		"<emphasis>D:</emphasis>, <emphasis>E</emphasis>, etc." at C
		"<keycap>Extended Microsoft partition</keycap>" at C.e+(.9i,0)  ljust

		line dotted from B.nw-(0,.2) right boxwid
		line dotted from B.nw-(0,.4) right boxwid
		"root file system" at B.n-(0,.075)
		"swap partition" at B.n-(0,.3)
		"/usr file system" at B.n-(0,.55)

	   A1:	arrow from A.se+(.2i,0) to A.se+(.02,0); move right .4i; "400 MB" ljust
	   A2:	arrow from B.se+(.2i,0) to B.se+(.02,0); move right .4i; "1.1 GB" ljust
	   A3:	arrow from A.se+(.2i,-.25) to A.se+(.02,-.25); move right .4i;
		"504 MB (after end of root file system)" ljust
	   A4:	arrow from C.se+(.2i,0) to C.se+(.02,0); move right .4i; "2.0 GB" ljust

                ]
]
</para>

<para><figure><title>Sharing a disk between Microsoft and FreeBSD</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
Make particularly sure that the <emphasis>end</emphasis> of the root partition falls within
the first 504 MB.  There is no way to ensure that the kernel and bootstrap will
be at the beginning of the partition.
</para>

<para>Other things to consider are:
</para>
<itemizedlist>
<listitem>

<para>If you have other software already installed on the disk, and you want to keep
it, <emphasis>do</emphasis> not change the drive geometry.  If you do so, you will no longer
be able to run the other software.
</para>
</listitem>
<listitem>

<para>Use LBA addressing if your hardware supports it.
</para>
</listitem>
<listitem>

<para>If you have to use CHS, and you don't have any other software on the drive, use
the drive geometry specified on the disk itself or in the manual, if you're
lucky enough to get a manual with the disk.  Many BIOSes remap the drive
geometry in order to get Microsoft to agree to work with the disk, but this can
break FreeBSD disk mapping.  Check that the partition editor has these values,
and change them if necessary.
</para>
</listitem>
<listitem>

<para>If all else fails, install Microsoft in a small slice at the start of the disk.
This will create a valid partition table for the drive, and the installation
software will understand it.  Once you have started the installation process,
the Microsoft partition has fulfilled its purpose, and you can delete it again.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect1>
</chapter>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchquickinstall"><title>Quick Installation</title>

<para><anchor id="CFBSD-quick-install"/>
In chapters <xref linkend="CFBSD-nchinstall"/> to <xref linkend="CFBSD-nchxsetup"/>, we'll go into a lot of detail about
how to install the system.  Maybe this is too much detail for you.  If you're an
experienced UNIX user, you should be able to get by with significantly less
reading.  This chapter presents checklists for some of the more usual kinds of
installation.  Each of them refer you to the corresponding detailed descriptions
in chapters <xref linkend="CFBSD-nchinstall"/> through <xref linkend="CFBSD-nchxsetup"/>.
</para>

<para>On page <xref linkend="CFBSD-exclusive-install"/> we'll look at the simplest installation, where
FreeBSD is the only system on the disk.  Starting on page <xref linkend="CFBSD-shared-disk"/> we'll
look at sharing the disk with Microsoft, and on page <xref linkend="CFBSD-X-install-checklist"/>
we'll look at how to install XFree86.  You may find it convenient to photocopy
these pages and to mark them up as you go along.
</para>
<sect1>
<title>Making things easy for yourself</title>

<para>It is probably easier to install FreeBSD than any other PC operating system,
including Microsoft products.  Well, anyway, most of the time.  Some people
spend days trying to install FreeBSD, and finally give up.  That happens with
Microsoft's products as well, but unfortunately it happens more often with
FreeBSD.
</para>

<para>Now you're probably saying, ``That doesn't make sense.  First you say it's
easier to install, then you say it's more likely to fail.  What's the real
story?''
</para>

<para>As you might expect, the real story is quite involved.  In <xref linkend="CFBSD-chconcepts"/>, I
went into some of the background.  Before you start, let's look at what you can
do to make the installation as easy as possible:
</para>
<itemizedlist>
<listitem>

<para>Use known, established hardware.  New hardware products frequently have
undocumented problems.  You can be sure that they work under Microsoft, because
the manufacturer has tested them in that environment.  In all probability, he
hasn't tested them under any flavour of UNIX, let alone FreeBSD.  Usually the
problems aren't serious, and the FreeBSD team will solve them pretty quickly,
but if you get the hardware before the software is ready, you'll be the guinea
pig.
</para>
</listitem>
<listitem>

<para>Perform a standard installation.  The easiest way to install FreeBSD is by
booting from a floppy disk and installing on an empty hard disk from the CD-ROM.
If you proceed as discussed in <xref linkend="CFBSD-chinstall"/>, you shouldn't have any difficulty.
</para>
</listitem>
<listitem>

<para><indexterm><primary>FIPS</primary></indexterm>
If you need to share your hard disk with another operating system, it's easier
to install both systems from scratch.  If you do already have a Microsoft system
on the disk, you can use <emphasis>FIPS</emphasis> (see page <xref linkend="CFBSD-FIPS"/>), to make space for it,
but this requires more care.
</para>
</listitem>
<listitem>

<para><indexterm><primary>RTFM</primary></indexterm>
If you run into trouble, <emphasis>RTFM</emphasis>.
<footnote>

<para>Hackerspeak for ``Read The Manual''&mdash;the <keycap>F</keycap> is usually silent.
</para>
</footnote>
I've gone to a lot of trouble to anticipate the problems you might encounter,
and there's a good chance that you will find something here to help.
</para>
</listitem>
<listitem>

<para>If you do all this, and it still doesn't work, see page <xref linkend="CFBSD-support"/> for ways of
getting external help.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect1>
<sect1>
<title>FreeBSD alone on the disk</title>

<para><anchor id="CFBSD-exclusive-install"/>
To install FreeBSD from CD-ROM on a disk alone, go through the following steps:
</para>
<itemizedlist>
<listitem>

<para>If your BIOS supports direct booting from CD-ROM, boot from CD-ROM.  Otherwise,
</para>
</listitem>
</itemizedlist>
<orderedlist>
<listitem>

<para>Create two boot floppies by copying the images <emphasis>/cdrom/kern.flp</emphasis> and
<emphasis>/cdrom/mfsroot.flp</emphasis> to 3\(12<emphasis>"</emphasis> diskettes.  Refer to page
<xref linkend="CFBSD-create-floppies"/> for more details.
</para>
</listitem>
<listitem>

<para>Insert the CD-ROM in the drive before booting.
</para>
</listitem>
<listitem>

<para>Boot from the <emphasis>kern.flp</emphasis> floppy.  After loading, insert the
<emphasis>mfsroot.flp</emphasis> floppy when the system prompts you to do so, then press
<keycap>Enter</keycap>.
</para>
<note>

<para>If you have a larger floppy, such as 2.88 MB or LS-120, you can copy the image
<emphasis>/cdrom/boot.flp</emphasis> to it and boot from it.  In this case you don't need to
change disks.
</para>
</note>

<para></para>
</listitem>
</orderedlist>
<itemizedlist>
<listitem>

<para>Select the <emphasis>Novice</emphasis> installation, even if you're an experienced UNIX
hacker.  Refer to page <xref linkend="CFBSD-floppy-boot"/>.
</para>
</listitem>
<listitem>

<para>In the partition editor, delete any existing Microsoft slices, and allocate a
single FreeBSD slice which takes up the entire disk.  Don't use a true partition
entry; you don't need compatibility.  Refer to pages
<xref linkend="CFBSD-building-partition-table"/> and <xref linkend="CFBSD-dangerously-dedicated"/>.
</para>
</listitem>
<listitem>

<para>On exiting from the partition editor, select the <emphasis>Standard</emphasis> MBR.  Refer to
page <xref linkend="CFBSD-select-mbr"/>.
</para>
</listitem>
<listitem>

<para>In the disk label editor, delete any existing UNIX partitions.  If you're not
too worried about the exact size of the partitions, select automatically
generated disk labels.  Refer to page <xref linkend="CFBSD-automatic-labels"/>.
</para>
</listitem>
<listitem>

<para>Alternatively, if you want to specify your file systems yourself, start on the
basis of a root file system with 50 MB, a swap partition with 256 MB, and
allocate the rest of the space on the disk to the <emphasis>/usr</emphasis> file system.
Refer to page <xref linkend="CFBSD-disklabel-editor"/>.
</para>

<para>Note particularly that, if you don't create a <emphasis>/var</emphasis> file system, as I'm
recommending here, you'll need to create a symlink later on.
</para>
</listitem>
<listitem>

<para>Choose the distributions you want.  Refer to page <xref linkend="CFBSD-select-distribution"/>.
</para>
</listitem>
<listitem>

<para>Select CD-ROM as installation medium.  Refer to page <xref linkend="CFBSD-select-medium"/>.
</para>
</listitem>
<listitem>

<para>If you intend to run the X11 windowing system, select the installation now.
It's easier than doing it after the system is up and running.  Refer to
page <xref linkend="CFBSD-xinstall"/>.
</para>
</listitem>
<listitem>

<para>Give final confirmation.  The system will be installed.  Refer to page
<xref linkend="CFBSD-commit"/>.
</para>
</listitem>
<listitem>

<para>After installation, set up at least a user ID for yourself.  Refer to page
<xref linkend="CFBSD-logging-in"/>.
</para>
</listitem>
<listitem>

<para>Do you have a separate <emphasis>/usr</emphasis> file system and no <emphasis>/var</emphasis> file system?
Then create a directory <emphasis>/usr/var</emphasis> and make sure that you make
<emphasis>/var</emphasis> point to <emphasis>/usr/var</emphasis>&mdash;see page <xref linkend="CFBSD-symlink-var"/> for further
details.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect1>
<sect1>
<title>Installing XFree86</title>

<para><anchor id="CFBSD-X-install-checklist"/>
As mentioned above, it's much easier to install and configure the XFree86
software during the initial software installation than after you have FreeBSD up
and running.  If your system is already up and running, however, perform the
following steps, which assume the the XFree86 3.3.1 distribution.  If you are
installing a different distribution, change the name XF86331 accordingly.
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>XF86331</primary></indexterm>
Log in as <emphasis>root</emphasis>, <emphasis>cd</emphasis> to <emphasis>/usr</emphasis>, and extract all the archives
in <emphasis>/cdrom/dists/XF86331</emphasis> with <emphasis>tar</emphasis>.  If you're using <emphasis>sh</emphasis> or
similar, do this with:
</para>
<programlisting>
# <command>cd /usr</command>
# <command>for i in /cdrom/dists/XF86331/X331*.tgz; do</command>
# <command>  tar xzf $i</command>
# <command>done</command>
</programlisting>

<para>If you're using <emphasis>csh</emphasis> or <emphasis>tcsh</emphasis>, do it with:
</para>
<programlisting>
% <command>cd /usr</command>
% <command>foreach i (/cdrom/dists/XF86331/X331*.tgz)</command>
% <command>  tar xzf $i</command>
% <command>end</command>
</programlisting>

<para></para>
</listitem>
<listitem>

<para>Identify the type and memory size of your video board, and the type and serial
port name of your mouse.
</para>
</listitem>
<listitem>

<para>Select the name of an X server which will work with your video board.  Refer to
page <xref linkend="CFBSD-server-table-page"/> for further details.  Look at the list of servers in
table <xref linkend="CFBSD-server-table"/> on page <xref linkend="CFBSD-server-table-page"/>
<indexterm><primary>X</primary></indexterm>
and create a link between the one you want to use and <emphasis>/usr/X11R6/bin/X</emphasis>.
</para>
</listitem>
<listitem>

<para><indexterm><primary>xf86config</primary><secondary>command</secondary></indexterm>
Run <emphasis>xf86config</emphasis> to create a configuration file.  Refer to page
<xref linkend="CFBSD-xf86config"/> for further details.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect1>
<sect1>
<title>FreeBSD shared with Microsoft</title>

<para><anchor id="CFBSD-shared-disk"/>
To install FreeBSD on a disk on which Microsoft is already installed, go through
the following steps:
</para>
<itemizedlist>
<listitem>

<para><emphasis>Make</emphasis> a backup! There's every possibility of erasing your data, and
there's absolutely no reason why you should take the risk.
</para>
</listitem>
<listitem>

<para>If you have an IDE disk larger than 504 MB, you may run into problems.  Refer to
page <xref linkend="CFBSD-EIDE"/> for further details.
</para>

<para>If you haven't read the documentation in Chapter <xref linkend="CFBSD-nchconcepts"/>, consider
performing the next couple of steps using <emphasis>VIEW</emphasis>, which can show you the
on-line documentation and start the programs for you.  Refer to page <xref linkend="CFBSD-VIEW"/>
for more information about <emphasis>VIEW</emphasis>.
</para>
</listitem>
<listitem>

<para>Repartition your disk with <emphasis>FIPS</emphasis>.  Refer to page <xref linkend="CFBSD-FIPS"/>.  You can start
<emphasis>FIPS</emphasis> directly or via the <emphasis>VIEW</emphasis> program.
</para>
</listitem>
<listitem>

<para>Insert the CD-ROM in the drive before booting.
</para>
</listitem>
<listitem>

<para>Boot the FreeBSD system.  If your Microsoft system is configured in a
FreeBSD-friendly manner, you can boot directly from Microsoft using the program
<emphasis>INSTALL.BAT</emphasis> for most CD-ROMs, or <emphasis>INST_IDE.BAT</emphasis> for IDE CD-ROM
drives.  You can also start either of these programs from the <emphasis>VIEW</emphasis>
program.
</para>
</listitem>
<listitem>

<para>If the direct boot doesn't work, it's probably due to your Microsoft
configuration.  It's not worth trying to reconfigure your Microsoft system to
make it work: it's easier to boot from CD-ROM or boot floppy, as described above
on page <xref linkend="CFBSD-exclusive-install"/> and in more detail on page <xref linkend="CFBSD-create-floppies"/>.
</para>
</listitem>
<listitem>

<para>Select the <emphasis>Novice</emphasis> installation, even if you're an experienced UNIX
hacker.  Refer to page <xref linkend="CFBSD-floppy-boot"/>.
</para>
</listitem>
<listitem>

<para>In the partition editor, delete <emphasis>only</emphasis> the second primary Microsoft slice.
The first primary Microsoft partition contains your Microsoft data, and if there
is an extended Microsoft partition, it will also contain your Microsoft data.
Then create a FreeBSD slice in the space that has been freed.  Refer to page
<xref linkend="CFBSD-building-partition-table"/>.
</para>
</listitem>
<listitem>

<para>On exiting from the partition editor, select the <emphasis>BootMgr</emphasis> MBR.  Refer to
page <xref linkend="CFBSD-select-mbr"/>.
</para>
</listitem>
<listitem>

<para>In the disk label editor, select the FreeBSD slice.  If you proceeded as above,
it should be empty, but if it contains existing UNIX partitions, delete them.
If you're not too worried about the exact size of the partitions, select
automatically generated disk labels.  Refer to page <xref linkend="CFBSD-automatic-labels"/>.
</para>
</listitem>
<listitem>

<para>Before leaving the disk label editor, also select mount points for your DOS
partitions if you intend to mount them under FreeBSD.  Refer to page
<xref linkend="CFBSD-dos-mount-point"/>.
</para>
</listitem>
<listitem>

<para>Alternatively, if you want to specify your file systems yourself, start on the
basis of a root file system with 50 MB, a swap partition with 256 MB, and
allocate the rest of the space on the disk to the <emphasis>/usr</emphasis> file system.
Refer to page <xref linkend="CFBSD-disklabel-editor"/>.
</para>

<para>Note particularly that, if you don't create a <emphasis>/var</emphasis> file system, you'll
need to create a symlink later on.
</para>
</listitem>
<listitem>

<para>Choose the distributions you want.  Refer to page <xref linkend="CFBSD-select-distribution"/>.
</para>
</listitem>
<listitem>

<para>Select CD-ROM as the installation medium.  Refer to page <xref linkend="CFBSD-select-medium"/>.
</para>
</listitem>
<listitem>

<para>If you intend to run the X window system, select the installation now.  It's
much easier than doing it after the system is up and running.  Refer to page
<xref linkend="CFBSD-xinstall"/>.
</para>
</listitem>
<listitem>

<para>Confirm installation.  The system will be installed.  Refer to page <xref linkend="CFBSD-commit"/>.
</para>
</listitem>
<listitem>

<para>After installation, set up at least a user ID for yourself.  Refer to page
<xref linkend="CFBSD-logging-in"/>.
</para>
</listitem>
<listitem>

<para>Do you have a separate <emphasis>/usr</emphasis> file system and no <emphasis>/var</emphasis> file system?
Then create a directory <emphasis>/usr/var</emphasis> and make sure that you make
<emphasis>/var</emphasis> point to <emphasis>/usr/var</emphasis>&mdash;see page <xref linkend="CFBSD-symlink-var"/> for further
details.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect1>
</chapter>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchshareinstall"><title>Shared OS Installation</title>

<para>In the previous chapter, we looked at how to install FreeBSD on a disk by
itself.  Unfortunately, you might not be able to afford this luxury: you may
only have one disk, and you need to use other operating systems as well.
</para>
<note>

<para>Before you start the installation, read this chapter carefully.  It's easy to
make a mistake, and one of the most frequent results of mistakes is the total
loss of all data on the hard disk.
</para>
</note>

<para>In this chapter, we'll look at what you need to do to share a disk between
FreeBSD and another operating system.  In most cases, you will share your disk
with a Microsoft platform, but most of this chapter applies to other operating
systems as well.  You may want to refer to the discussion of Microsoft and FreeBSD
disk layouts on page
The first question is: is there enough space on the disk for FreeBSD?  How much
you need depends on what you want to do with FreeBSD, of course, but for the
sake of example we'll take 120 MB as a ballpark figure.  In the following
section, we'll consider what to do if you need to change your partitions.  If
you already have enough space for a FreeBSD partition (for example, if you have
just installed Microsoft specifically for sharing with FreeBSD, and thus have
not filled up the disk), continue reading on page
</para>
<sect1>
<title>Repartitioning with FIPS</title>

<para><indexterm><primary>FIPS</primary><secondary>MS-DOS command</secondary></indexterm>
<indexterm><primary>MS-DOS</primary><secondary>command</secondary></indexterm>
<anchor id="CFBSD-FIPS"/>
Typically, if you've been running Microsoft on your machine, it will occupy the
entire disk.  If you need all this space, of course, there's no way to install
another operating system as well.  Frequently, though, you'll find that you have
enough free space in the partition.  Unfortunately, that's not where you want
it: you want a new partition with this much space.  There are a number of ways
of getting this space:
</para>
<itemizedlist>
<listitem>

<para>You can reinstall the software.  This approach is common in the Microsoft world,
but FreeBSD users try to avoid it.
</para>
</listitem>
<listitem>

<para>You can use <emphasis>FIPS</emphasis> shrink a Microsoft partition, leaving space for
FreeBSD.  <emphasis>FIPS</emphasis> is a public domain utility, and it is included on the
FreeBSD CD-ROM.  Unfortunately, it cannot shrink more recent Microsoft file
systems.
</para>
</listitem>
<listitem>

<para>If you can't use <emphasis>FIPS</emphasis>, use a commercial utility like <emphasis>PartitionMagic</emphasis>.
This is not included on the CD-ROMs, and we won't discuss it further.
</para>
</listitem>
</itemizedlist>

<para>In the rest of the section, we'll look at how to shrink a partition with
<emphasis>FIPS</emphasis>.  If you do it with PartitionMagic, the details are different, but
the principles are the same.  In particular:
</para>
<note>

<para>Before repartitioning your disk, make a backup.  You can shoot yourself in the
foot with this method, and the result will almost invariably be loss of data.
</para>
</note>

<para><indexterm><primary>DEFRAG</primary><secondary>MS-DOS command</secondary></indexterm>
<indexterm><primary>MS-DOS</primary><secondary>command</secondary></indexterm>
<indexterm><primary>Norton</primary><secondary>disk tools</secondary></indexterm>
If you've been running Microsoft on your system for any length of time, the data
in the partition will be spread all around the partition.  If you just truncate
the partition, you'll lose a lot of data, so you first need to move all the data
to the beginning of the partition.  Fortunately, MS-DOS 6.x (part of the
``Windows'' environment) supplies such a tool, called <emphasis>DEFRAG</emphasis>.
Alternatively, you can use a third-party defragmenter such as the one supplied
with the Norton Disk tools.  Before proceeding, consider a few gotchas:
</para>
<itemizedlist>
<listitem>

<para>The new Microsoft partition needs to be big enough to hold all the data.  If you
make it exactly the size of the data, it will effectively be full, and you won't
be able to write anything to it.
</para>
</listitem>
<listitem>

<para>The second partition is also a Microsoft partition.  To install FreeBSD on it, you
need to delete it and create a new FreeBSD partition.
</para>
</listitem>
<listitem>

<para>Most older BIOSes require the root file system in the FreeBSD partition to end
before cylinder 1024, otherwise the installation will complete correctly, but
you won't be able to boot from it.  See the diagram on page <xref linkend="CFBSD-EIDE-layout"/>.
</para>
</listitem>
<listitem>

<para><indexterm><primary>MSCDEX</primary><secondary>Microsoft driver</secondary></indexterm>
<emphasis>FIPS</emphasis> may result in configuration problems with your Microsoft machine.
Since it adds a partition, any automatically assigned partitions which follow
will have a different drive letter.  In particular, this could mean that your
CD-ROM drive will ``move''.  After you delete the second Microsoft partition and
change it into a FreeBSD partition, it will ``move'' back again.
</para>
</listitem>
</itemizedlist>

<para>For further information, read the <emphasis>FIPS</emphasis> documentation in
<emphasis>/cdrom/tools/srcs/fips/fips.doc</emphasis>.  In particular, note these limitations:
</para>
<itemizedlist>
<listitem>

<para><emphasis>FIPS</emphasis> works only with Hard Disk BIOSes that use interrupt <emphasis>0x13</emphasis>
for low level hard disk access.  This is generally not a problem.
</para>
</listitem>
<listitem>

<para><emphasis>FIPS</emphasis> splits only partitions with 16 bit FATs.  Older versions of
Microsoft use 12 bit FATs, which are too small to be worth splitting.
</para>
</listitem>
<listitem>

<para><indexterm><primary>Linux</primary></indexterm>
<emphasis>FIPS</emphasis> splits only Microsoft partitions.  The partition table and boot
sector must conform to the MS-DOS 3.0+ conventions.  This is marked by the
system indicator byte in the partition table, which must have the value 4 (16
bit sector number) or 6 (32 bit sector number).  In particular, it will
<emphasis>not</emphasis> split Linux partitions.
</para>
</listitem>
<listitem>

<para><emphasis>FIPS</emphasis> does not yet work on extended Microsoft partitions.
</para>
</listitem>
<listitem>

<para><emphasis>FIPS</emphasis> needs one free partition entry, so it will not work if you already
have four partitions.
</para>
</listitem>
<listitem>

<para><emphasis>FIPS</emphasis> will not reduce the original partition to a size of less than 4085
clusters, because this would involve rewriting the 16 bit FAT to a 12 bit FAT.
</para>
</listitem>
</itemizedlist>

<para></para>
<sect2>
<title>Repartitioning&mdash;an example</title>

<para>In this section, we'll go through the mechanics of repartitioning a disk.  We'll
start with a Western Digital Caviar 2200 disk, the same one we used for the
example on page
This time it starts off with a complete MS-DOS 6.21 system.
</para>

<para><indexterm><primary>CHKDSK</primary><secondary>MS-DOS program</secondary></indexterm>
<indexterm><primary>SCANDISK</primary><secondary>MS-DOS program</secondary></indexterm>
First, run <emphasis>CHKDSK</emphasis> or <emphasis>SCANDISK</emphasis> on the partition you want to
split.  If you have Norton Disk Doctor or something similar, you can use it
instead.  Make sure no ``dead'' clusters remain on the disk.
</para>

<para><indexterm><primary>RESTORRB</primary><secondary>MS-DOS program</secondary></indexterm>
Next, prepare a bootable floppy.  When you start <emphasis>FIPS</emphasis>, you will be given
the opportunity to write backup copies of your root and boot sector to a file on
drive <emphasis>A:</emphasis>.  These will be called <emphasis>ROOTBOOT.00<emphasis>x</emphasis></emphasis>, where <emphasis>x</emphasis>
represents a digit from <emphasis>0</emphasis> to <emphasis>9</emphasis>.  If anything goes wrong while
using <emphasis>FIPS</emphasis>, you can restore the original configuration by booting from
the floppy and running <emphasis>RESTORRB</emphasis>.
</para>
<note>

<para><indexterm><primary>ROOTBOOT</primary><secondary>file</secondary></indexterm>
If you use <emphasis>FIPS</emphasis> more than once (this is normally not necessary, but it
might happen), your floppy will contain more than one <emphasis>ROOTBOOT</emphasis> file.
<emphasis>RESTORRB</emphasis> lets you choose which configuration file to restore.  The file
<emphasis>RESTORRB.000</emphasis> contains your original configuration.  Try not to confuse
the versions.
</para>
</note>

<para>Before starting <emphasis>FIPS</emphasis> you <emphasis>must</emphasis> defragment your disk in order to
ensure that the space to be used for the new partition is free.  This is not as
straightforward as it seems:
</para>
<itemizedlist>
<listitem>

<para>Most defragmentation programs don't move the windows swap file.  You have to
uninstall it (in the <emphasis>386enhanced</emphasis> part of the Windows Control Panel) and
reinstall it after using <emphasis>FIPS</emphasis>.
</para>
</listitem>
<listitem>

<para><indexterm><primary>IMAGE</primary><secondary>MS-DOS program</secondary></indexterm>
<indexterm><primary>MIRROR</primary><secondary>MS-DOS program</secondary></indexterm>
Programs like <emphasis>IMAGE</emphasis> or <emphasis>MIRROR</emphasis> store a hidden system file with a
pointer to your mirror files in the last sector of the hard disk.  You
<emphasis>must</emphasis> delete this file before using <emphasis>FIPS</emphasis>.  It will be recreated the
next time you run <emphasis>MIRROR</emphasis>.  To delete it, in the root directory enter:
</para>
<programlisting>
C&gt; <command>attrib -r -s -h image.idx			<emphasis>for IMAGE<emphasis>
C&gt; </emphasis></emphasis></command><command>attrib -r -s -h mirorsav.fil			<emphasis>for MIRROR
</emphasis></command></programlisting>

<para>Then delete the file.
</para>
</listitem>
</itemizedlist>

<para>If <emphasis>FIPS</emphasis> does not offer as much disk space for creation of the new
partition as you expect, this may mean that:
</para>
<itemizedlist>
<listitem>

<para>You still have too much data in the remaining partition.  Consider making the
new partition smaller or deleting some of the data.  If you delete data, you
must run <emphasis>FIPS</emphasis> again.
</para>
</listitem>
<listitem>

<para>There are hidden files in the space of the new partition that have not been
moved by the defragmentation program.  Make sure to which program they belong.
If a file is a swap file of some program (for example NDOS) it is possible that
it can be safely deleted (and will be recreated automatically later when the
need arises).  See your manual for details.
</para>

<para>If the file belongs to some sort of copy protection, you must uninstall the
program to which it belongs and reinstall it after repartitioning.
</para>
</listitem>
</itemizedlist>

<para></para>
<note>

<para>If you are running early versions of MS-DOS (before 5.0), or another operating
system, such as Linux or OS/2, or you are using programs like Stacker,
SuperStor, or Doublespace, read the FIPS documentation for other possible
problems.
</para>
</note>

<para></para>
<sect3>
<title>Running FIPS</title>

<para>After defragmenting your Microsoft partition, you can run <emphasis>FIPS</emphasis>.  In
<emphasis>VIEW</emphasis>, select <emphasis>tools</emphasis>, then <emphasis>fips</emphasis>.  It's easier to do it from
the command line:
</para>
<programlisting>
<!--  For some reason, this next line formats differently for the complete -->
<!--  book and for the individual chapter. -->
C&gt; </emphasis><command>R:</command>							<emphasis>change to CD-ROM
R&gt; <command>cd \etools</emphasis>					<emphasis>make sure you're in the tools directory</command>
R&gt; </emphasis><command>fips</command>						<emphasis>and start the FIPS program
<emphasis>\&amp;... a lot of copyright information omitted</emphasis>
Press any key					<emphasis>do what the computer says</emphasis>
Which Drive (1=0x80/2=0x81)?
</programlisting>

<para>The message <emphasis>Which Drive</emphasis> may seem confusing, since it refers to Microsoft
internal numbering.  Don't worry about it: if you want to partion the first
physical drive in the system, (<emphasis>C:</emphasis>), enter <emphasis>1</emphasis>, otherwise enter
<emphasis>2</emphasis>.  Like MS-DOS, <emphasis>FIPS</emphasis> handles only two hard disks.
</para>

<para>If you start <emphasis>FIPS</emphasis> under Windows or DESQview, it will complain and tell
you to boot from a floppy disk.  It won't stop you from continuing, but it is a
Bad Idea to do so.
</para>

<para>Next, <emphasis>FIPS</emphasis> reads the root sector of the hard disk and displays the
partition table:
</para>
<programlisting>
     |        |     Start      |      |      End       | Start  |Number of|
Part.|bootable|Head Cyl. Sector|System|Head Cyl. Sector| Sector |Sectors  |  MB
-----+--------+----------------+------+----------------+--------+---------+----
1    |    yes |   0    0      1|   06h|  11  987     34|       0|   414960|  212
2    |     no |   0    0      0|   00h|   0    0      0|       0|        0|   0
3    |     no |   0    0      0|   00h|   0    0      0|       0|        0|   0
4    |     no |   0    0      0|   00h|   0    0      0|       0|        0|   0
</programlisting>

<para>This shows that only first partition is occupied, that it is bootable, and that
it occupies the whole disk (212 MB, from Cylinder 0, Head 0, Sector 1 to
Cylinder 987, Head 11, Sector 34).  Don't worry about the ``bootable'' flag
here&mdash;we'll deal with that in the FreeBSD installation.  First, <emphasis>FIPS</emphasis>
does some error checking and then reads and displays the boot sector of the
partition:
</para>
<programlisting>
Checking Rootsector ... OK
Press any Key			<emphasis>do what it says</emphasis>
Bytes per sector: 512
Sectors per cluster: 8
Reserved sectors: 1
Number of FATs: 2
Number of rootdirectory entries: 512
Number of sectors (short): 0
Media descriptor byte: f8h
Sectors per FAT: 145
Sectors per track: 35
Drive heads: 12
Hidden sectors: 63
Number of sectors (long): 414960
Physical drive number: 80h
Signature: 29h
</programlisting>

<para>After further checking, <emphasis>FIPS</emphasis> asks you if you want to make a backup
floppy.  Enter your formatted floppy in drive <emphasis>A:</emphasis> and make the backup.
Next, you see:
</para>
<programlisting>
Enter start cylinder for new partition (263 - 987):
Use the cursor keys to choose the cylinder, &lt;enter&gt; to continue
Old partition      Cylinder       New Partition
   53.9 MB          263            148.7 MB
</programlisting>

<para>Use the <keycap>Cursor Left</keycap> and <keycap>Cursor Right</keycap> keys to adjust the cylinder
number at which the new partition starts.  You can also use the keys <keycap>Cursor
Up</keycap> and <keycap>Cursor Down</keycap> to change in steps of ten cylinders.  <emphasis>FIPS</emphasis>
updates the bottom line of the display to show the new values selected.
Initially, <emphasis>FIPS</emphasis> chooses the smallest possible Microsoft partition, so
you can only increase the size of the old partition (with the <keycap>Cursor Right</keycap>
key).  When you're happy with the sizes, press <keycap>Enter</keycap> to move on to the
next step.
</para>
<note>

<para>Be very sure you're happy before you continue.  If you make the first partition
too small, there is no way to make it larger again.  On the other hand, if you
make it too large, you can split it again and then use fdisk or MS-DOS
FDISK to remove the superfluous partitions.
</para>
</note>

<para>In this example, we choose the following combination:
</para>
<programlisting>
Old partition      Cylinder       New Partition
   82.0 MB          400            120.6 MB
<emphasis>(pressed </emphasis><keycap>Enter<emphasis>
     |        |     Start      |      |      End       | Start  |Number of|
Part.|bootable|Head Cyl. Sector|System|Head Cyl. Sector| Sector |Sectors  |  MB
-----+--------+----------------+------+----------------+--------+---------+----
1    |    yes |   0    0      1|   06h|  11  399     34|       0|   167965|  53
2    |     no | 400    0      0|   06h|  11  987     34|       0|   246960| 120
3    |     no |   0    0      0|   00h|   0    0      0|       0|        0|   0
4    |     no |   0    0      0|   00h|   0    0      0|       0|        0|   0

Do you want to continue or reedit the partition table (c/r)? </emphasis></keycap><command>c</command>
</programlisting>

<para><indexterm><primary>CONFIG.SYS</primary></indexterm>
<indexterm><primary>AUTOEXEC.BAT</primary></indexterm>
<indexterm><primary>MIRROR</primary><secondary>MS-DOS program</secondary></indexterm>
<indexterm><primary>IMAGE</primary><secondary>MS-DOS program</secondary></indexterm>
<indexterm><primary>CHKDSK</primary><secondary>MS-DOS program</secondary></indexterm>
In order for the partition to be recognized, reboot immediately.  Make sure to
disable all programs that write to your disk in <emphasis>CONFIG.SYS</emphasis> and
<emphasis>AUTOEXEC.BAT</emphasis> before rebooting.  It might be easier to to rename the
files or to boot from floppy.  Be particularly careful to disable programs like
<emphasis>MIRROR</emphasis> and <emphasis>IMAGE</emphasis>, which might get confused if the partitioning
is not to their liking.  After rebooting, use <emphasis>CHKDSK</emphasis> or Norton Disk
Doctor to make sure the first partition is OK.  If you don't find any errors,
you may now reboot with your normal <emphasis>CONFIG.SYS</emphasis> and <emphasis>AUTOEXEC.BAT</emphasis>.
Start some programs and make sure you can still read your data.
</para>

<para>After that, you have two valid Microsoft partitions on your disk.  Read the next
section to install FreeBSD on the second one.
</para>
</sect3>
</sect2>
</sect1>
<sect1>
<title>Installing FreeBSD on a second partition</title>

<para><anchor id="CFBSD-2-partitions"/>
In this section we'll discuss how to install FreeBSD on the second partition of
a hard disk which contains a valid image in the first partition, either because
you installed it that way or because you have just used <emphasis>FIPS</emphasis> to make it
that way.  The first step is to boot the FreeBSD as described on page
Follow the installation as discussed there until you get to the step <emphasis>Building
a partition table</emphasis> on page
</para>

<para>When you enter the partition editor, you will see something like:
</para>
<programlisting>
<command>D</command>isk name:      <command>wd0</command>                                      <emphasis>FDISK Partition Editor</emphasis>
BIOS Geometry:  989 cyls/12 heads/35 sectors

     Offset       Size        End     Name      PType     Desc  Subtype    Flags

          0         35         34        -          6   unused        0
         35     167965     167999    wd0s1          2      fat        6   =
     168000     246960     414959    wd0s2          2      fat        6   =
     414960        420     415379        -          2   unused        0

The following commands are supported (in upper or lower case):
A = Use Entire Disk    B = Bad Block Scan     C = Create Partition
D = Delete Partition   G = Set BIOS Geometry  S = Set Bootable
U = Undo All Changes   Q = Finish             W = Write Changes

The currently selected partition is displayed in <command>reverse video</command>
Use F1 or ? to get more help, arrow keys to move.
</programlisting>

<para>This display shows the two Microsoft partitions, <emphasis>wd0s1</emphasis> and <emphasis>wd0s2</emphasis>. To
install FreeBSD, you need to remove one of them.  <emphasis>Be</emphasis> very careful to remove
the correct partition.  It's always the second of the two partitions, in this
case <emphasis>wd0s2</emphasis>.  We remove the partition with the <emphasis>d</emphasis> command.  After
this, our display looks like:
</para>
<programlisting>
          0         35         34        -          6   unused        0
         35     167965     167999    wd0s1          2      fat        6   =
     168000     247380     415379        -          2   unused        0
</programlisting>

<para>The next step is to allocate a FreeBSD partition with the <emphasis>C</emphasis> command.
The menu asks us the size of the partition, and suggests a value of 247380
sectors, the complete size of the unused area at the end.  We can edit this
value if we wish, but in this case it's what we want, so we just press ENTER.
Now the display looks like this:
</para>
<programlisting>
          0         35         34        -          6   unused        0
         35     167965     167999    wd0s1          2      fat        6   =
     168000     247380     415379    wd0s2          3   freebsd     165   C
</programlisting>

<para><indexterm><primary>fdisk</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>fdisk</secondary></indexterm>
The new partition uses the rest of the disk, including the last 420 sectors
which Microsoft rejected, and it has a partition type 3 (extended partition) and
subtype 165 (<emphasis>0xa5</emphasis>), which identifies it as a FreeBSD partition.
</para>

<para>All we need to do now is to mark the partition active or bootable, by pressing
<emphasis>s</emphasis>.  The <emphasis>a</emphasis> flag appears at the end of the partition line:
</para>
<programlisting>
          0         35         34        -          6   unused        0
         35     167965     167999    wd0s1          2      fat        6   =
     168000     247380     415379    wd0s2          3   freebsd     165   CA
</programlisting>

<para>After this, we select a boot method as described on page
Since we have two operating systems on the disk, we select the <emphasis>BootMgr</emphasis>
option.
</para>

<para><indexterm><primary>slice</primary><secondary>disk</secondary></indexterm>
<indexterm><primary>partition</primary><secondary>disk</secondary></indexterm>
At this point, we need to change our terminology.  So far, we have been using
Microsoft terminology, and we have talked of partitions.  FreeBSD calls these same
divisions of the disk <emphasis>slices</emphasis>.  That wouldn't be bad in itself, but it also
uses the term <emphasis>partition</emphasis> to refer to the contents of the slice.  See page
for further details.
</para>

<para>Our next step is to select FreeBSD partitions within the FreeBSD slice.  We have
already discussed this on page
so we'll look at it more briefly here.  As we saw on page
<indexterm><primary>/usr</primary></indexterm>
we will typically need a root file system, a <emphasis>/usr</emphasis> file system and swap
space.  When we select <emphasis>Label</emphasis>, we get the following screen:
</para>
<programlisting>
                         FreeBSD Disklabel Editor

<command>Disk: wd0  Partition name: wd0s2   Free: 247380 blocks (120MB)</command>


Part    Mount             Size Newfs   Part    Mount             Size Newfs
----    -----             ---- -----   ----    -----             ---- -----
wd0s1   &lt;none&gt;            82MB DOS
</programlisting>

<para><emphasis>Be</emphasis> careful here.  The partition shown in the list is the active
Microsoft partion, <emphasis>not</emphasis> the FreeBSD partition.  At this point, we have
two choices: decide for ourselves what we want, or let the disk label editor do
it for us.  We looked at automatically generated labels on page
<indexterm><primary>/usr</primary></indexterm>
so we'll just look at the manual generation here.  If we enter <emphasis>c</emphasis> to
create a disk partition, the disk label editor prompts us for details of the
partition.  Let's assume that we've decided that, for this disk, we want a 20 MB
root file system, 32 MB swap and the rest for <emphasis>/usr</emphasis>.  We hit <emphasis>c</emphasis> and
get a prompt window asking how much we want, suggesting the whole disk.  We
replace this with <emphasis>20m</emphasis> (the trailing <emphasis>m</emphasis> says the the value is in
units of megabytes), and get another question asking whether this is a file
system or swap space.  We choose <emphasis>file system</emphasis> and get a further prompt
asking where to mount it.  We enter <emphasis>/</emphasis>, and come back to the display,
which now shows:
</para>
<programlisting>
Part    Mount             Size Newfs   Part    Mount             Size Newfs
----    -----             ---- -----   ----    -----             ---- -----
wd0s1   &lt;none&gt;            82MB DOS
wd0s2a  /                 20MB UFS Y
</programlisting>

<para>Next we define the swap space.  This time we specify 32 MB, and that it should
be swap space.  Now the display looks like:
</para>
<programlisting>
Part    Mount             Size Newfs   Part    Mount             Size Newfs
----    -----             ---- -----   ----    -----             ---- -----
wd0s1   &lt;none&gt;            82MB DOS
wd0s2a  /                 20MB UFS Y
wd0s2b  &lt;none&gt;            32MB SWAP
</programlisting>

<para><indexterm><primary>/usr</primary></indexterm>
Finally, we create the <emphasis>/usr</emphasis> file system.  This time we accept the offer
of everything available, and end up with:
</para>
<programlisting>
Part    Mount             Size Newfs   Part    Mount             Size Newfs
----    -----             ---- -----   ----    -----             ---- -----
wd0s1   &lt;none&gt;            82MB DOS
wd0s2a  /                 20MB UFS Y
wd0s2b  &lt;none&gt;            32MB SWAP
wd0s2e  /usr              68MB UFS Y
</programlisting>

<para>After this point, we can continue at Section <emphasis>Selecting distributions</emphasis> on
page
The rest of the installation is the same as for a dedicated disk.

</para>
</sect1>
</chapter>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: draft 4th edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchinstall"><title>Installing FreeBSD</title>

<para><anchor id="CFBSD-install-start"/>
So now you're ready to install FreeBSD on your system.  In this chapter, we'll
look at how to install FreeBSD.  If you run into trouble, I'll refer you back to
the page of Chapter <xref linkend="CFBSD-nchconcepts"/> which discusses this topic.  If you want to
install FreeBSD on the same disk as Microsoft or another operating system, you
should have already read <xref linkend="CFBSD-chshareinstall"/>.
</para>

<para>The following discussion relates primarily to installation on the i386
architecture.  Support for the AXP (``Alpha'') processor is very new, and it
will change.  The current support is described on page <xref linkend="CFBSD-alpha-install"/>.
</para>
<sect1>
<title>Installing FreeBSD on the Intel i386 architecture</title>

<para><anchor id="CFBSD-sw-prepare"/>
To install FreeBSD you need the software in a form which the installation
software understands.  You may also need a boot diskette.  The choices you have
are, in order of decreasing attractiveness:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>El</primary><secondary>Torito</secondary></indexterm>
CD-ROM.  This is by far the easiest way to install FreeBSD.  If your system BIOS
supports the <emphasis>El Torito</emphasis>
<footnote>

<para>El Torito is a chain of Tex-Mex restaurants in California and other US states.
The story goes that the original concept was hacked out on the back of a
serviette one evening after a meal at El Torito.  All modern BIOSes support the
El Torito standard.
</para>
</footnote>
CD-ROM boot standard, or you have a running Microsoft system on the machine on which
you want to install FreeBSD, you may not even need a boot diskette.
</para>
</listitem>
<listitem>

<para>Over the network.  You have the choice of <emphasis>ftp</emphasis> or NFS connection.
</para>
</listitem>
<listitem>

<para>From a locally mounted disk partition, either FreeBSD (if you have already
installed it) or Microsoft.
</para>
</listitem>
<listitem>

<para>From tape in <emphasis>tar</emphasis> format.  This was once considered an installation
option, but I don't know of any tape installations done in the last few years,
and it's possible that it no longer works.
</para>
</listitem>
<listitem>

<para>From floppy disk.  This is only for masochists or people who really have almost
no hardware: depending on the extent of the installation, you will need up to
200 disks, and at least one of them is bound to have an I/O error.  And don't
forget that a CD-ROM drive costs a lot less than 200 floppies.
</para>
</listitem>
</itemizedlist>

<para></para>
<sect2>
<title>Booting from CD-ROM</title>

<para>Finally floppy disks are becoming obsolete, and with modern hardware you can
perform a FreeBSD installation without even having a floppy drive on your
computer: all you need is a CD-ROM drive and a BIOS which understands the <emphasis>El
Torito</emphasis> standard.  If you do, you don't need to do any preparation at all
beyond putting the CD-ROM in the drive and setting your BIOS to boot from it.
Continue reading on page <xref linkend="CFBSD-boot-install-kernel"/>
</para>
</sect2>
<sect2>
<title>Preparing a boot floppy</title>

<para><anchor id="CFBSD-make-floppy"/>
<indexterm><primary>boot</primary><secondary>floppy</secondary></indexterm>
<indexterm><primary>floppies/boot.flp</primary></indexterm>
<indexterm><primary>boot</primary><secondary>disk</secondary></indexterm>
If you can't boot from CD-ROM, you will need to boot from floppy disk.  If you
are using 1.44 MB floppies, you will need two of them, the <emphasis>Kernel Disk</emphasis>
and the <emphasis>MFS Root Disk</emphasis> to boot the installation programs.  If you are
using 2.88 MB floppies or a LS-120 disk, you can copy the single <emphasis>Boot
Disk</emphasis>, which is 2.88 MB long.  The images of these floppies are on the CD-ROM
distribution in the files <emphasis>floppies/kern.flp</emphasis>, <emphasis>floppies/mfsroot.flp</emphasis>
and <emphasis>floppies/boot.flp</emphasis> respectively.  If you have your CD-ROM mounted on
a Microsoft system, they will be called <emphasis>FLOPPIES\eKERN.FLP</emphasis>,
<emphasis>FLOPPIES\eMFSROOT.FLP</emphasis> and <emphasis>FLOPPIES\eBOOT.FLP</emphasis> respectively.  The
bootstrap does not recover bad blocks, so the floppy must be 100% readable.
</para>

<para>The way you get the boot disk image onto a real floppy depends on the operating
system you use.  If you are using any flavour of UNIX, just perform something
like
</para>
<programlisting>
# <command>dd if=/cdrom/floppies/kern.flp of=/dev/fd0c bs=36b</command>
<emphasis>change the floppy</emphasis>
# <command>dd if=/cdrom/floppies/mfsroot.flp of=/dev/fd0c bs=36b</command>
</programlisting>

<para><indexterm><primary>rfd0c</primary><secondary>device</secondary></indexterm>
<indexterm><primary>device</primary><secondary>rfd0c</secondary></indexterm>
This assumes that your software is on CD-ROM, and that it is mounted on the
directory <emphasis>/cdrom</emphasis>.  It also assumes that your floppy drive is called
<emphasis>/dev/fd0c</emphasis> (this is the FreeBSD name, which is also used by other BSD
systems&mdash;see page
for an overview).  If you're using Linux, the device name would be
<emphasis>/dev/fd0</emphasis> or <emphasis>/dev/fd1</emphasis>.
</para>

<para>Some versions of UNIX, particularly older System V variants, may complain about
the option <emphasis>bs=36b</emphasis>.  If this happens, just leave it out.  It might take
up to 10 minutes to write the floppy, but it will work, and it will make you
appreciate FreeBSD all the more.
</para>

<para><indexterm><primary>VIEW.EXE</primary><secondary>MS-DOS command</secondary></indexterm>
<indexterm><primary>MS-DOS</primary><secondary>command</secondary></indexterm>
<anchor id="CFBSD-VIEW"/>
<indexterm><primary>MAKEFLP.BAT</primary><secondary>MS-DOS command</secondary></indexterm>
<indexterm><primary>MS-DOS</primary><secondary>command</secondary></indexterm>
<indexterm><primary>floppies/boot.flp</primary></indexterm>
If you have to create the boot floppy from Microsoft, use the program
<emphasis>Makeflp.bat</emphasis> which is on the home directory of the first CD-ROM.  Simply
select the icon.  In this directory you will also find the program can use
<emphasis>View.exe</emphasis>, a self-documenting menu-driven utility which is located in the
root directory of the CD-ROM, to perform all preparation necessary from
Microsoft.  Again, simply select the icon <emphasis>View.exe</emphasis> and follow the
instructions.
</para>
</sect2>
<sect2>
<title>Creating floppies for a floppy installation</title>

<para><anchor id="CFBSD-create-floppies"/>
Installation from floppy disk is definitely the worst choice you have.  You will
need 14 floppies for the minimum installation, and up to 200 for the complete
installation.  The chance of one of them being bad is high.  Most problems on a
floppy install can be traced to bad media, or differences in alignment between
the media and the drive in which they are used, so:
</para>
<note>

<para>Before starting, format all floppies in the drive you intend to use, even if
they are preformatted.
</para>
</note>

<para></para>

<para><indexterm><primary>floppies/boot.flp</primary></indexterm>
<indexterm><primary>RAWRITE.EXE</primary><secondary>MS-DOS command</secondary></indexterm>
<indexterm><primary>dd</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>dd</secondary></indexterm>
The first two floppies you'll need are the Kernel floppy and the MFS Root
floppy, which were described in the previous section.
</para>

<para>In addition, you will need at minimum as many floppies as it takes to hold all
files in the <emphasis>bin</emphasis> directory, which contains the binary distribution.
Read the file <emphasis>LAYOUT.TXT</emphasis> paying special attention to the ``Distribution
format'' section which describes which files you need.
</para>

<para>If you're creating the floppies on a FreeBSD machine, you can put  <emphasis>ufs</emphasis>
file systems on the floppies instead:
</para>
<programlisting>
# <command>fdformat -f 1440 fd0.1440</command>
# <command>disklabel -w -r fd0.1440 floppy3</command>
# <command>newfs -t 2 -u 18 -l 1 -i 65536 /dev/fd0</command>
</programlisting>

<para>Next, copy the files to the floppies.  The distribution files are split into
chunks conveniently sized so that 5 of them will fit on a conventional 1.44MB
floppy.  Go through all your floppies, packing as many files as will fit on each
one, until you've got all the distributions you want packed up in this fashion.
Each distribution should go into its own subdirectory on the floppy, for example
<emphasis>A:\BIN\BIN.INF</emphasis>, <emphasis>A:\BIN\BIN.AA</emphasis>, <emphasis>A:\BIN\BIN.AB</emphasis> etc.
</para>

<para>Make very sure to put the file <emphasis>bin.inf</emphasis> on the first floppy, since it is
needed to find out how many floppies to read.
</para>
</sect2>
<sect2>
<title>Installing via FTP</title>

<para><indexterm><primary>installing</primary><secondary>from Internet</secondary></indexterm>
<anchor id="CFBSD-ftp-install"/>
The fun way to install FreeBSD is via the Internet, but it's not always the best
choice.  There's a lot of data to transfer, and unless you have a really
high-speed, non-overloaded connection to the server, it could take forever.  On
the other hand, of course, if you have your own private server (like another
UNIX machine with the sources on it), and the system on which you want to
install FreeBSD doesn't have a CD-ROM drive, these conditions are fulfilled, and
this could be for you.  Before you decide, though, read about the alternative of
NFS installation below: if you don't have an FTP server with the files already
installed, it's a lot easier to set up an NFS installation.
</para>

<para>There are two FTP installation modes you can use:
</para>
<itemizedlist>
<listitem>

<para>Regular <emphasis>FTP</emphasis> mode does not work through most firewalls but will often work
best with older <emphasis>ftp</emphasis> servers that do not support passive mode.  Use this
mode if your connection hangs with passive mode.
</para>
</listitem>
<listitem>

<para><indexterm><primary>FTP</primary><secondary>passive</secondary></indexterm>
If you need to pass through firewalls that do not allow incoming connections,
try <emphasis>passive FTP</emphasis>.
</para>
</listitem>
</itemizedlist>

<para>Whichever mode of installation and whichever remote machine you choose, you need
to have access to the remote machine.  The easiest and most common way to ensure
access is to use anonymous FTP.  If you're installing from another FreeBSD
machine, read how to install anonymous FTP on page <xref linkend="CFBSD-anonymous-ftp"/>.  This
information is also generally correct for other UNIX systems.
</para>
<sect3>
<title>Setting up the ftp server</title>

<para><indexterm><primary>\*[Fver]-RELEASE</primary></indexterm>
<indexterm><primary>/usr/ftp</primary></indexterm>
To set up the ftp server, the system from which you load the software, you must
load the software into the public FTP directory.  On BSD systems, this will be
the home directory of user <emphasis>ftp</emphasis>, which in FreeBSD defaults to
<emphasis>/usr/ftp</emphasis>.  The name of the directory is the name of the release, which in
this example we'll assume to be <emphasis><xref linkend="CFBSD-Fver"/>-RELEASE</emphasis>.
<!--  .ad l -->
<!--  .nh -->
You can put this directory in a subdirectory of <emphasis>/usr/ftp</emphasis>, for example
<emphasis>/usr/ftp/FreeBSD/<xref linkend="CFBSD-Fver"/>-RELEASE</emphasis>,
<!--  .hy -->
<!--  .ad -->
but the only optional part in this example is the parent directory
<emphasis>FreeBSD</emphasis>.
</para>

<para>This directory has a slightly different structure from the CD-ROM distribution.
To set it up, assuming you have your distribution CD-ROM mounted on
<emphasis>/cdrom</emphasis>, and that you are installing in the directory
<emphasis>/usr/ftp/FreeBSD/<xref linkend="CFBSD-Fver"/>-RELEASE</emphasis>, perform the following steps:
</para>
<programlisting>
# <command>cd /usr/ftp/FreeBSD/<xref linkend="CFBSD-Fver"/>-RELEASE</command>
# <command>mkdir floppies</command>
# <command>cd floppies</command>
# <command>cp /cdrom/floppies/* .</emphasis>			<emphasis>don't omit the </emphasis></command><command>.<emphasis> at the end<emphasis>
# </emphasis></command><command>cd /cdrom					<emphasis>the distribution directory on CD-ROM<emphasis>
# </emphasis></emphasis></command><command>tar cf - [b-d]* g* man* po* pr* [s-z]* | (cd /usr/ftp/FreeBSD/<xref linkend="CFBSD-Fver"/>-RELEASE; tar xvf -)</command>
</programlisting>

<para>This copies all the directories of <emphasis>/cdrom</emphasis> into
<emphasis>/usr/ftp/FreeBSD/<xref linkend="CFBSD-Fver"/>-RELEASE</emphasis> except for <emphasis>packages</emphasis>, a total of about
180 MB.  If you have enough space for the <emphasis>packages</emphasis> file as well (about
500 MB more), you can simplify the last line to:
</para>
<programlisting>
# <command>tar cf - . | (cd /usr/ftp/FreeBSD/<xref linkend="CFBSD-Fver"/>-RELEASE; tar xvf -)</command>
</programlisting>

<para>For a minimal installation, you need only the directory <emphasis>bin</emphasis>, about 16
MB.  To just install <emphasis>bin</emphasis> rather than all of the distribution, change the
last line of the example above to
</para>
<programlisting>
# <command>mkdir bin</command>
# <command>cp /cdrom/bin/* bin</command>
</programlisting>

<para></para>
</sect3>
</sect2>
<sect2>
<title>Installing via NFS</title>

<para><anchor id="CFBSD-nfs-install-setup"/>
If you're installing from a CD-ROM drive on another system in the local network,
you will probably find an installation via FTP too complicated for your liking.
Installation is a lot easier if the other system supports NFS.  Before you
start, make sure you have the CD-ROM mounted on the remote machine, and that the
remote machine is exporting the file system (in System V terminology, exporting
is called <emphasis>sharing</emphasis>).  When prompted for the name of the directory,
specify the name of the directory on which the CD-ROM is mounted.  For example,
if the CD-ROM is mounted on directory <emphasis>/cdrom</emphasis> on the system
<emphasis>presto.example.org</emphasis>, enter <command>presto.example.org:/cdrom</command>.  That's all
there is to it!
</para>
<note>

<para>Older versions of FreeBSD stored the distribution on a subdirectory <emphasis>dists</emphasis>.
Newer versions store it in the root directory of the CD-ROM.
</para>
</note>

<para></para>
</sect2>
<sect2>
<title>Installing from a Microsoft partition</title>

<para>On the Intel architecture it's also possible to install from a primary Microsoft
partition on the first disk.  At the moment, it's not possible to install from
extended partitions.  To prepare for installation from an Microsoft partition,
copy the files from the distribution into a directory called <emphasis>\eFREEBSD</emphasis>.
For example, to do a minimal installation of FreeBSD from Microsoft using files
copied from a CD-ROM mounted on <emphasis>E:</emphasis>, you might do something like this:
</para>
<programlisting>
C&gt; <command>MKDIR C:\eFREEBSD</command>
C&gt; <command>XCOPY /S E:\eBIN C:\eFREEBSD\eBIN</command>
C&gt; <command>XCOPY /S E:\eFLOPPIES C:\eFREEBSD\eFLOPPIES</command>
</programlisting>

<para><indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>boot.flp</primary></indexterm>
You need the directory <emphasis>FLOPPIES</emphasis> because that's where <emphasis>sysinstall</emphasis>
looks for the <emphasis>boot.flp</emphasis>, the first image in every installation.
</para>

<para><indexterm><primary>The</primary><secondary><emphasis>bin</emphasis> directory</secondary></indexterm>
The only required directory is <emphasis>bin</emphasis>.  You can include as many other
directories as you want, but be sure to maintain the directory structure.  In
other words, if you also wanted to install <emphasis>XF86312</emphasis> and <emphasis>manpages</emphasis>,
you would copy them to <emphasis>C:\eFREEBSD\eXF86312</emphasis> and
<emphasis>C:\eFREEBSD\eMANPAGES</emphasis>.
</para>
</sect2>
<sect2>
<title>Installing from tape</title>

<para><indexterm><primary>installing</primary><secondary>from tape</secondary></indexterm>
<anchor id="CFBSD-tape-install"/>
It's theoretically possible to install FreeBSD from tape, but it probably hasn't
been done in the last few years, and it's quite possible that you'll run into
trouble.  If you're installing from tape, you need a tape written in <emphasis>tar</emphasis>
format with a block size of 5120 bytes (10 sectors).  Don't use <emphasis>tar</emphasis>'s
default value of 10240 bytes or 20 sectors.  Since the install program reads the
entire tape onto disk, you will need a <keycap>big</keycap> disk.  As a further
restriction, you can install only from the first tape unit in the system.
</para>
</sect2>
<sect2>
<title>Installing from a FreeBSD partition</title>

<para><indexterm><primary>installing</primary><secondary>from disk partition</secondary></indexterm>
<anchor id="CFBSD-unix-partition-install"/>
If you already have a copy of the FreeBSD distribution on the disk on which you
are installing, you can use this option.  Unfortunately, it doesn't work if the
partition is on another disk.  We're still working on this one&mdash;consider it an
experimental option.
</para>
</sect2>
</sect1>
<sect1>
<title>Booting the install kernel</title>

<para><anchor id="CFBSD-boot-install-kernel"/>
No matter which installation medium you choose, the first step in installing
FreeBSD is to start a minimal version of the operating system.  The simplest way
is to boot directly from the installation CD-ROM, if your system BIOS supports
it.  If your system doesn't support this kind of boot, you have the choice of
booting directly from CD-ROM floppy or from a running Microsoft system.
</para>

<para>In the following sections, we'll look at a real-life installation on a real
machine.  When you install FreeBSD on your machine, a number of things will be
different, depending on the hardware you're running and the way you're
installing the software.  Nevertheless, you should be able to recognize what is
going on.
</para>
<sect2>
<title>Booting from CD-ROM</title>

<para>Booting from CD-ROM is mainly a matter of setting up your system BIOS and
possibly your SCSI BIOS.  Typically, you perform one of the following
procedures:
</para>
<itemizedlist>
<listitem>

<para>If you're booting from an IDE CD-ROM, you enter your system BIOS setup routines
and set the <emphasis>Boot sequence</emphasis> parameter to select CD-ROM booting ahead of
hard disk booting, and possibly also ahead of floppy disk booting.  A typical
sequence might be <emphasis>CDROM,C,A</emphasis>.
</para>
</listitem>
<listitem>

<para>On most machines, if you're booting from a SCSI CD-ROM, you also need a host
adapter which supports CD-ROM boot.  Set up the system BIOS to boot in the
sequence, say, <emphasis>SCSI,A,C</emphasis>.  On typical host adapters (such as the Adaptec
2940 series), you set the adapter to enable CD-ROM booting, and set the ID of
the boot device to the ID of the CD-ROM drive.
</para>
</listitem>
</itemizedlist>

<para>These settings are probably not what you want to use for normal operation.  If
you leave the settings like this, and there is a bootable CD-ROM in your CD-ROM
drive, it always boots from that CD-ROM rather than from the hard disk.  After
installation, change the parameters back again to boot from hard disk before
CD-ROM.  See your system documentation for further details.
</para>
</sect2>
<sect2>
<title>Booting from floppy</title>

<para><indexterm><primary>booting</primary><secondary>from floppy</secondary></indexterm>
<anchor id="CFBSD-floppy-boot"/>
If you are installing from tape or CD-ROM, <emphasis>put the medium in the drive</emphasis>
before booting.  The installation may fail if you boot before inserting the
medium.
</para>

<para><indexterm><primary>/dev/fd0</primary></indexterm>
<indexterm><primary>A:</primary><secondary>drive</secondary></indexterm>
Boot the system in the normal manner: insert the kernel diskette in
<emphasis>/dev/fd0</emphasis>, the first floppy drive (which Microsoft calls <emphasis>A:</emphasis>), and
reset the computer or turn power on.  After the PC has gone through its hardware
tests, it will boot the FreeBSD install kernel from the floppy.
</para>
</sect2>
<sect2>
<title>Installing from a running Microsoft system</title>

<para>If the disk on which you plan to install FreeBSD contains Microsoft, and you're
installing from CD-ROM, you can usually boot directly from MS-DOS.  This will
work whether you plan to overwrite the Microsoft partition, or whether you plan
to install to another slice or another disk on the same system.  To boot this
way, reboot your system in MS-DOS mode, change to the CD-ROM volume (<emphasis>E:</emphasis>
in this example) and start <emphasis>INSTALL</emphasis> or <emphasis>VIEW</emphasis>:
</para>
<programlisting>
C&gt; </emphasis><command>E:</command>			<emphasis>change to CD-ROM
E&gt; <command>cd \e</emphasis>		<emphasis>make sure you're in the root directory</command>
E&gt; </emphasis><command>install</command>		<emphasis>and start the INSTALL program
</programlisting>

<para>Don't try this from Microsoft Windows&mdash;the installation will fail with the
message <emphasis>not enough memory</emphasis>.  The boot will progress in the same way as if
you had booted from floppy.  The advantage of starting <emphasis>VIEW</emphasis> is that you
get more documentation: ultimately <emphasis>VIEW</emphasis> will start <emphasis>INSTALL</emphasis> to
boot the system.
</para>

<para><emphasis>INSTALL</emphasis> doesn't always work.  It depends on what drivers or TSRs are in
your system.  There's no reason to try changing your Microsoft configuration to
get it to work: it's a lot easier just to boot from floppy, which we looked at
on page <xref linkend="CFBSD-make-floppy"/>.
</para>
</sect2>
<sect2>
<title>The boot process</title>

<para>The boot process itself is very similar to the normal boot process described on
page <xref linkend="CFBSD-bootup"/>.  There are a couple of differences:
</para>
<itemizedlist>
<listitem>

<para>At the beginning, you will see the message:
</para>
<programlisting>
Copyright (c) 1992-2000 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD 4.1-RELEASE #1: Mon Aug 21 16:51:39 GMT 2000
    grog@daemon.lemis.com:/usr/src/sys/compile/BOOTMFS
Timecounter "i8254"  frequency 1193182 Hz
Timecounter "TSC"  frequency 467729955 Hz
CPU: Pentium II/Pentium II Xeon/Celeron (467.73-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x665  Stepping = 5
  Features=0x183fbff&lt;FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR&gt;
real memory  = 134217728 (131072K bytes)
</programlisting>

<para>If the system stops at this point, it probably means that you have memory
problems (either not enough memory or defective memory).
</para>
</listitem>
<listitem>

<para>If you're booting from a two-floppy set, the loader will issue the following
prompt after loading the kernel:
</para>
<programlisting>
Please insert MFS root floppy and press enter:
</programlisting>

<para>When you do that, it continues with the probes.
</para>
</listitem>
<listitem>

<para>After the probes (page <xref linkend="CFBSD-device-probe"/>) you always go into the UserConfig menu:
</para>
<programlisting>
<command>B                       Kernel Configuration Menu


         Skip kernel configuration and continue with installation </command>
         Start kernel configuration in full-screen visual mode
         Start kernel configuration in CLI mode


Here you have the chance to go into kernel configuration mode, making
any changes which may be necessary to properly adjust the kernel to
match your hardware configuration.

If you are installing FreeBSD for the first time, select Visual Mode
(press Down-Arrow then ENTER).

If you need to do more specialized kernel configuration and are an
experienced FreeBSD user, select CLI mode.

If you are <command>certain</command> that you do not need to configure your kernel
then simply press ENTER or Q now.
</programlisting>

<para>In order to be able to install the machine, the system must recognize your
hardware.  If you have modern PCI hardware, this shouldn't be a problem, but IDE
hardware frequently needs to be jumpered to individual IRQ and I/O address
settings.  What happens if you want to install via the network and your IDE
Ethernet board is set up differently from the way the kernel expects?  The
driver doesn't notice it, and it won't be until quite some time later that you
will find that the installation can't work.  That's what <emphasis>UserConfig</emphasis> (the
kernel configuration editor) is for, and why you get the chance to run it at
this point in the installation.  See page <xref linkend="CFBSD-modify-boot-config"/> for an example
of how to tell the kernel about your hardware configuration.
</para>

<para>If your hardware configuration matches what the generic kernel expects (see page
<xref linkend="CFBSD-supported-hardware"/>), or if your hardware is all PCI, just press <keycap>ENTER</keycap>.
The kernel will continue with the <emphasis>device probes</emphasis> (see page
<xref linkend="CFBSD-device-probe"/>).  In case of doubt, assume that everything will be OK.  It
might be easier to restart the installation than work your way through the
menus.
</para>

<para>Shortly after you leave UserConfig, the screen will be cleared and you will see
the main <emphasis>sysinstall</emphasis> menu (in colour, if your system supports it).
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
</sect1>
<sect1>
<title>Using sysinstall</title>

<para><anchor id="CFBSD-sysinstall-main"/>
<indexterm><primary>sysinstall</primary><secondary>using</secondary></indexterm>
<indexterm><primary>FAQ/Text</primary></indexterm>
</para>

<para><figure><title>Main installation menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
<!--  XXX .pageref \*[main-installation-menu] "on page \*[main-installation-menu]" -->
Figure <xref linkend="CFBSD-main-installation-menu"/> shows the main <emphasis>sysinstall</emphasis> menu.
<emphasis>sysinstall</emphasis> includes on-line help at all stages.  Simply press <keycap>F1</keycap>
and you will get appropriate help.  Also, if you haven't been here before, the
<emphasis>Doc</emphasis> menu gives you a large part of the appropriate information from the
handbook.
</para>
<sect2>
<title>Kinds of installation</title>

<para><indexterm><primary>standard</primary><secondary>installation</secondary></indexterm>
<indexterm><primary>express</primary><secondary>installation</secondary></indexterm>
<indexterm><primary>custom</primary><secondary>installation</secondary></indexterm>
<indexterm><primary>installation</primary><secondary>standard</secondary></indexterm>
<indexterm><primary>installation</primary><secondary>express</secondary></indexterm>
<indexterm><primary>installation</primary><secondary>custom</secondary></indexterm>
To get started, you select one of <emphasis>Standard</emphasis>, <emphasis>Express</emphasis> or
<emphasis>Custom</emphasis>.  The names imply that the <emphasis>Standard</emphasis> installation is the
best way to go, the <emphasis>Express</emphasis> installation is for people in a hurry, and
<emphasis>Custom</emphasis> installation is for you if you want to specify exactly what is to
be done.
</para>

<para>In fact, the names are somewhat misleading.  There isn't really that much
difference between the three forms of installation.  They all perform the same
steps:
</para>
<itemizedlist>
<listitem>

<para>Possibly set up options.
</para>
</listitem>
<listitem>

<para>Set up disk partitions, which we'll discuss in the next section.
</para>
</listitem>
<listitem>

<para>Set up file systems and swap space within a FreeBSD slice, which we start on
page
</para>
</listitem>
<listitem>

<para>Choose what you want to install, which we discuss on page
</para>
</listitem>
<listitem>

<para>Choose where you want to install it from.  We'll look at this on page
</para>
</listitem>
<listitem>

<para>Actually install the software.  We'll treat this on page
</para>
</listitem>
</itemizedlist>

<para>We looked at disk partitions and file systems on page <xref linkend="CFBSD-partitions"/>.  We'll
look at the other points when we get to them.
</para>

<para>So what's the difference?
</para>
<itemizedlist>
<listitem>

<para>The Standard installation takes you through these steps in sequence.  Between
each step, you get a pop-up window which tells you what is going to happen next.
</para>
</listitem>
<listitem>

<para>The Express installation also takes you through these steps in sequence.  The
main difference is that you don't get the pop-up window telling you what is
going to happen next.  This can save a little time.  If you do want the
information, similar information is available with the F1 key.
</para>
</listitem>
<listitem>

<para>The Custom installation returns you to its main menu after each step.  It's up
to you to select the next step.  You can also select another step, or go back to
a previous one.  Like the Express installation, you don't get the pop-up
information window, but you can get more information with the F1 key.
</para>
</listitem>
</itemizedlist>

<para>The big problem with Standard and Express installations is that they don't let
you back up: if you pass a specific step and discover you want to change
something, you have to abort the installation and start again.  With the Custom
installation, you can simply go back and change it.  As a result, I recommend
the Custom installation.  In the following discussion, you won't see too much
difference: the menus are the same for all three installation forms.
</para>

<para><figure><title>Custom Installation options</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>
</sect2>
</sect1>
<sect1>
<title>Setting installation options</title>

<para>The first item on the menu is to set installation options.  You only have this
option if you're using the Custom installation, and in fact there's probably not
too much you'll want to change.
</para>

<para><figure><title>Custom Installation options</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
About the only thing of interest might be the editor <emphasis>ec</emphasis>, which is a
compromise between a simple editor for beginners and more complicated editors
like <emphasis>vi</emphasis>.  If you're planning to edit anything during the installation, for
example the file <emphasis>/etc/exports</emphasis>, which we'll look at on page
<xref linkend="CFBSD-etc-exports"/>, you may prefer to set an editor with which you are familiar.
Select the fields by moving the cursor to the line and pressing the space bar.
</para>
</sect1>
<sect1>
<title>Creating space on disk</title>

<para><indexterm><primary>partition</primary><secondary>table</secondary></indexterm>
<indexterm><primary>disks</primary><secondary>creating file systems</secondary></indexterm>
<indexterm><primary>disks</primary><secondary>creating space</secondary></indexterm>
<anchor id="CFBSD-building-partition-table"/>
The first installation step is to set up space for FreeBSD on the disk.  We
looked at the technical background in <xref linkend="CFBSD-chconcepts"/>, page
In this section, we'll use the term <emphasis>partition</emphasis> to refer to a slice or
Microsoft partition, since that's the usual terminology, even if it's a little
confusing.
</para>

<para><indexterm><primary>partition</primary></indexterm>
Even if your disk is correctly partitioned, select <emphasis>Partition</emphasis>: the
installation routines need to enter this screen in order to read the partition
information from the disk.  If you like what you see, you can leave again
immediately with <emphasis>q</emphasis> (quit), but you must first enter this menu.  If you
have more than one disk connected to your machine, you will next be asked to
choose the drives that you want to use for FreeBSD:
</para>

<para><figure><title>Disk selection menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
<indexterm><primary>ad0</primary></indexterm>
This screen shows entries for each drive that <emphasis>sysinstall</emphasis> has detected;
in this example, the system has one ATA (IDE) drive, <emphasis>ad0</emphasis>, and one SCSI
drive, <emphasis>da0</emphasis>.  You only get this screen if you have at least two drives
connected to your machine; otherwise <emphasis>sysinstall</emphasis> automatically goes to
the next screen.
</para>

<para>If you intend to use more than one disk for FreeBSD, you have the choice of
setting up all disks now, or setting the others up after the system is up and
running.  We'll look at the latter option in <xref linkend="CFBSD-chdisks"/>, on page
As you'll see there, it's <emphasis>much</emphasis> easier to do it now.
</para>

<para>To select the disk on which you want to install FreeBSD, move the cursor to the
appropriate line and press the space bar.  The screen you get will probably have
contents like this:
</para>

<para><figure><title>Partition editor menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
Table
explains the meanings of the columns in this display.  This display shows the
current partition table on our Western Digital Caviar 2200 disk drive, one of
the smallest disks that you could use to install FreeBSD on.  The first
partition contains the Master Boot Record, which is exactly one sector long, and
the bootstrap, which can be up to 15 sectors long.  The partitioning tools use
the complete first track: note that the geometry information from BIOS says that
it has 35 sectors per track.
<table frame='all'><title>fdisk information</title>
box,center,tab(#) ;
| lfCWp9w8 | lw66 | .
\s10Column#description
=

<tgroup cols='1' align='left' colsep='1' rowsep='1'><tbody>
<row><entry>
</entry></row>
<indexterm><primary>fat</primary></indexterm>
<row><entry>
</entry></row>
<indexterm><primary>file</primary><secondary>allocation table</secondary></indexterm>
<row><entry> Offset</entry><entry> the number of the first sector in the partition
</entry></row>
<row><entry> Size</entry><entry> the length of the partition in sectors
</entry></row>
<row><entry> End</entry><entry> the number of the last sector in the partition
</entry></row>
<row><entry> Name</entry><entry> where present, this is the name by which FreeBSD knows the partition.  In this example, only the second entry has a name.
</entry></row>
<row><entry> Ptype</entry><entry> the partition type.  Partition type 6 is the Master Boot Record, which is exactly one track long (note that the header says that this drive has 63 sectors per track).  Type 2 is a regular partition.
</entry></row>
<row><entry>
</entry></row>
<indexterm><primary>fat</primary></indexterm>
<row><entry>
</entry></row>
<indexterm><primary>File</primary><secondary>Allocation Table</secondary></indexterm>
<row><entry>  Subtype Desc </entry><entry> These describe the type of partition numerically and in text.  <emphasis>fat</emphasis> stands for <emphasis>File Allocation Table</emphasis>, which is a central part of the Microsoft disk space allocation strategy.  In more general terms, we can say that the first partition is a Microsoft file system.
</entry></row>
<row><entry> Flags</entry><entry>can be one or more of the following characters:
</entry></row>
<row><entry>
</entry></row>
<row><entry> </entry><entry><emphasis>=</emphasis>  The partition is correctly aligned
</entry></row>
<row><entry> </entry><entry> <emphasis>&gt;</emphasis>  The partition finishes after cylinder 1024, which can cause problems for Microsoft.  </entry><entry><emphasis>A</emphasis>  This is the active (bootable) partition.
</entry></row>
<row><entry> </entry><entry><emphasis>B</emphasis>  The partition employs BAD144 bad-spot handling.
</entry></row>
<row><entry> </entry><entry><emphasis>C</emphasis>  This is a FreeBSD compatibility partition.
</entry></row>
<row><entry> </entry><entry><emphasis>R</emphasis>  This partition contains a root file system.
</entry></row>
<row><entry>
</entry></row>
</tbody></tgroup></table>
</para>

<para><anchor id="CFBSD-death-to-Microsoft"/>
In our case, the Microsoft file system uses up the whole disk except for the
last track, 630 sectors (315 kB) at the end of the disk.  Clearly there's not
much left to share.  We could shorten the Microsoft partition with
<emphasis>FIPS</emphasis>&mdash;see <xref linkend="CFBSD-chshareinstall"/>, page
if that's what you want to do&mdash;but in this example we choose to remove it.
</para>
<note>

<para>Don't forget that if you remove a partition, you lose all the data in it.  If
the partition contains anything you want to keep, make sure you have a legible
backup.
</para>
</note>

<para>We remove the partition with the <emphasis>d</emphasis> command.  After this, our display
looks like:
</para>
<programlisting>
0   40088160   40088159        -      6     unused        0
</programlisting>

<para>The next step is to allocate a FreeBSD partition with the <emphasis>C</emphasis> command.
There are two ways to do this: if we want to have more than one partition on the
drive (for example, if we
share the disk with another operating system), we will use the <emphasis>c</emphasis>
(create) command.  We'll look at that in <xref linkend="CFBSD-chshareinstall"/>, page
<xref linkend="CFBSD-createpartition"/>.  In our case, though, we want to use the entire disk for
FreeBSD, so we choose the <emphasis>a</emphasis> option:
</para>

<para><figure><title>Partition editor menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
If you answer <emphasis>Yes</emphasis> to this question, you will get a display effectively
the same as in Figure <xref linkend="CFBSD-partition-editor-menu"/>: the only difference will be
that the <emphasis>Desc</emphasis> field will now show <emphasis>freebsd</emphasis> instead of <emphasis>fat</emphasis>.
If you select <emphasis>No</emphasis>, you will get the following display:
</para>

<para><figure><title>Partition editor menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
This layout gives you slightly more space: it omits the partition table and the
630 sectors of waste space at the end.
</para>

<para>So why should you ever want to do it the other way?  There's a lot of discussion
in the FreeBSD community about this issue.  The problem is that the partition
table doesn't only contain partition information, it also describes the geometry
of the disk to the BIOS.  Some BIOSes have great difficulty with disks which
don't contain a partition table.  As a result, you may not be able to boot from
a disk which is partitioned in this way.  Some people use the somewhat
emotionally charged term <emphasis>dangerously dedicated</emphasis> to refer to a drive
partitioned in this way.
</para>

<para>How often is this a problem?  I have never experienced problems with this kind
of partition; others report problems, and it's likely that there are particular
problems in this area with laptops.  But it only affects the boot disk: FreeBSD
doesn't have any problems with dedicated disks, so you can always use this
method for drives other than the boot disk.
</para>

<para><indexterm><primary>command</primary><secondary>fdisk</secondary></indexterm>
<indexterm><primary>fdisk</primary><secondary>command</secondary></indexterm>
<indexterm><primary>boot</primary><secondary>selector</secondary></indexterm>
<indexterm><primary>MBR</primary></indexterm>
<indexterm><primary>master</primary><secondary>boot record</secondary></indexterm>
<anchor id="CFBSD-bootmgr"/>
That's all we need to do here: we leave <emphasis>fdisk</emphasis> with the <emphasis>q</emphasis>
command.
</para>
<note>

<para>Don't use the <emphasis>W</emphasis> (Write Changes) command here.  It's intended for use
only once the system is up and running.
</para>
</note>

<para>If we have selected a partition table, the next screen asks what kind of <emphasis>boot
selector</emphasis> (in other words, <emphasis>MBR</emphasis>) we want:
</para>

<para><figure><title>Partition editor menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
<indexterm><primary>BootMgr</primary></indexterm>
You don't get this screen if you dedicate the entire disk to FreeBSD, by
answering <emphasis>No</emphasis> to the question about a true partition entry.  Since we
plan to have only one operating system on this disk, we select <emphasis>Standard</emphasis>.
If we were sharing with, say, Microsoft, we could choose <emphasis>BootMgr</emphasis>
instead.
<anchor id="CFBSD-select-mbr"/>
<table frame='all'><title>MBR choices</title>
box,center,tab(#) ;
lfCWp9 | lw66 .
\s10Choice#Description
=

<tgroup cols='1' align='left' colsep='1' rowsep='1'><tbody>
<row><entry>
</entry></row>
<indexterm><primary>booteasy</primary></indexterm>
<row><entry> BootMgr</entry><entry> Install the FreeBSD boot manager in the MBR.  This will enable you choose which partition to boot every time you start the system.
</entry></row>
<row><entry> Standard</entry><entry> Use a standard MBR.  You will only be able to boot from the active partition.
</entry></row>
<row><entry> None</entry><entry> Don't change the MBR.  This is useful if you already have another boot manager installed.
</entry></row>
</tbody></tgroup></table>
</para>
<sect2>
<sect3>
<title>Where we are now</title>

<para>At this point in the installation, we have told <emphasis>sysinstall</emphasis> the overall
layout of the disk or disks you intend to use for FreeBSD, and whether or how
you intend to share them with other operating systems.  The next step is to
specify how you want to use the FreeBSD partitions.
</para>
</sect3>
</sect2>
<sect2>
<title>Specifying disk labels</title>

<para><indexterm><primary>disk</primary><secondary>label</secondary></indexterm>
<anchor id="CFBSD-disklabel-editor"/>
<indexterm><primary>/usr</primary></indexterm>
In the next step we tell the installation program what to put in our FreeBSD
partition.  By default, <emphasis>sysinstall</emphasis> gives you three file systems: the
root file system <emphasis>/</emphasis>, <emphasis>/usr</emphasis> and <emphasis>/var</emphasis>.  See <xref linkend="CFBSD-chdisks"/>, page
for the reasoning behind the file system layout.  When we select <emphasis>Label</emphasis>, we
get the following screen:
</para>

<para><figure><title>Label editor menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>
<sect3>
<title>What size partitions?</title>

<para>In our example, we have 20 GB of space to divide up.  How should we do it?  You
don't have to worry about this issue, since <emphasis>sysinstall</emphasis> will do it for
you if you ask it, but we'll see below why this might not be the best choice.
In this section we'll consider how UNIX file systems have changed over the
years, and we'll look at the issues in file system layout nowadays.
</para>

<para>When UNIX was young, disks were tiny.  By the time of the Third Edition of UNIX,
in 1972, the system disk was a Digital RF-11, a fixed head disk with 512 kB.  It
was no longer possible to keep the entire system on this disk, so a second file
system became essential.  It was mounted on a Digital RK03 with 2 MB of
storage.  To quote from a paper published in the <emphasis>Communications of the
ACM</emphasis> in July 1974:
</para>
<note>

<para>In our installation, for example, the root directory resides on the fixed-head
disk, and the large disk drive, which contains user's files, is mounted by the
system initialization program...
</para>
</note>

<para></para>

<para>As time went on, UNIX got bigger, but so did the disks.  By the early 80s, disks
were large enough to put <emphasis>/</emphasis> and <emphasis>/usr</emphasis> on the same disk, and it
would have been possible to merge <emphasis>/</emphasis> and <emphasis>/usr</emphasis>, but they didn't.
Since that time, an additional file system, <emphasis>/var</emphasis>, has come into common use
for frequently changed data.  This is what <emphasis>sysinstall</emphasis> does by default:
</para>

<para><figure><title>Default disk partition sizes</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
It's relatively simple to estimate the size of the root file system, and
<emphasis>sysinstall</emphasis>'s value of 50 MB is fine.  But what about <emphasis>/var</emphasis>?  20 MB
isn't worth the trouble any more.  In fact, both file systems put together would
be lost in the 19 GB of <emphasis>/usr</emphasis> file system.  Why do we still do things
this way?  Let's look at the advantages and disadvantages:
</para>
<itemizedlist>
<listitem>

<para>If you write to a file system, a system crash can have serious consequences for
the data integrity of that file system.
</para>
</listitem>
<listitem>

<para>If you have a crash and lose the root file system, recovery can be difficult.
</para>
</listitem>
<listitem>

<para>If a file system fills up, it can cause lots of trouble.  Most messages about
file systems on the <emphasis>FreeBSD-questions</emphasis> mailing list are complaining about
file systems filling up.  If you have a large number of small file systems, the
chances are higher that one will fill up while space remains on another.
</para>
</listitem>
<listitem>

<para>In single-user mode, only the root file system is mounted.  With the classical
layout, this means that the only programs you can run are those in <emphasis>/bin</emphasis>
and <emphasis>/sbin</emphasis>.  In order to run any other programs, you must first mount the
file system on which they are located.
</para>
</listitem>
<listitem>

<para>It's nice to keep your personal files separate from the system files.  That way
you can upgrade a system much more easily.
</para>
</listitem>
<listitem>

<para>It's very difficult to calculate the sizes of some file systems.  For example,
on some systems <emphasis>/var</emphasis> can be very small, maybe only 2 or 3 MB.  It's
hardly worth making a separate file system for that much data.  On the other
hand, other systems, such as ftp or web servers, may have a <emphasis>/var</emphasis> system
of 50 or 100 GB.  How do you choose the correct size for your system?
</para>
</listitem>
<listitem>

<para>When doing backups, it's a good idea to be able to get a file system on a single
tape.
</para>
</listitem>
</itemizedlist>

<para>In the early days of UNIX, system crashes were relatively common, and the damage
they did to the file systems was relatively serious.  Times have changed, and
nowadays file system damage is relatively seldom, particularly on file systems
that have little activity.  On the other hand, disk drives have grown beyond
most peoples' wildest expectations.  The first edition of this book, only five
years ago, showed how to install on a 200 MB drive.  The smallest disk drives in
current production are 10 GB in size, more than will fit on many tapes.
</para>

<para>As a result of these considerations, I have changed my recommendations.  In
earlier editions of this book, I recommended to put a small root file system and
a <emphasis>/usr</emphasis> file system on the first (or only) disk on the system.
<emphasis>/var</emphasis> was to be a symbolic link to <emphasis>/usr/var</emphasis>.
</para>

<para>This is still a valid layout, but it has a couple of problems:
</para>
<itemizedlist>
<listitem>

<para>In the example we're looking at, <emphasis>/usr</emphasis> is about 19 GB in size.  Not many
people have backup devices which can write this much data on a single medium.
</para>
</listitem>
<listitem>

<para>Many people had difficulty with the symbolic link to <emphasis>/usr/var</emphasis>.
</para>
</listitem>
</itemizedlist>

<para>As a result, I now recommend:
</para>
<itemizedlist>
<listitem>

<para>Make a single root file system of between 2 and 4 GB.
</para>
</listitem>
<listitem>

<para>Do not have separate <emphasis>/usr</emphasis> or <emphasis>/var</emphasis> file systems.
</para>
</listitem>
<listitem>

<para>Use the rest of the space on disk for a <emphasis>/home</emphasis> file system, as long as
it's possible to back it up on a single tape.  Otherwise make multiple file
systems.  <emphasis>/home</emphasis> is the normal directory for user files.
</para>
</listitem>
</itemizedlist>

<para>This layout allows for easy backup of the file systems, and it also allows for
easy upgrading to a new system version: you just need to replace the root file
system.  It's not perfect, though: on a web server you probably wouldn't want to
put <emphasis>/var</emphasis> on the root file system.
XXX

It
seems that the issue here was reliability: the system was laid out in such a way
that the system could still come up in single user mode if <emphasis>/</emphasis> was
undamaged, so it made sense to have a small root file system, on which little
data was written, and a larger <emphasis>/usr</emphasis> file system which included file
systems which changed more frequently.
</para>

<para>In fact, this never quite happened.  UNIX has a directory <emphasis>/tmp</emphasis> for small
quantities of temporary data, and a very large number of systems put this
directory on the root file system.

1.  If you have a crash, the fsck time can be considerable.  I don't
    know if it's any worse than fsck'ing several smaller file systems
    with the same total size, however.

2.  Backing up and restoring can be a challenge.  I've tended to say
    "don't make your file systems larger than your tapes", but there
    are exceptions, especially if you can back up at the subdirectory
    level.  For the same reason, multi-reel backups can be
    counterproductive.  If for some reason you accidentally delete a
    file and need to restore it from tape, you may find it takes 8
    hours or longer, reading through tapes you don't need to look at.

        1) if you fill up 1 partition, you still have space elsewhere
        2) if a partition for some reason gets scrogged, the others
        will still work.
        On many systems, /usr can be read-only for all practical purposes,
        with /usr/tmp on a writable system.



In the examples above, we've made severe compromises to get the system on the
tiny disk.  We've assumed that we can get the root file system in 20 MB, and
that 32 MB of swap space is a good value.  In fact, most modern disks are an
order of magnitude larger than this disk.  What do we use?
</para>

<para>We've already seen how big to make <emphasis>/usr</emphasis>: it's the rest of the disk.  The
root file system is kept separate mainly for reasons of superstition: in the old
days, when systems were less reliable, it was a good idea to keep the root file
system separate in order to recover a crashed file system. Since it's uncommon
to write to the root file system, it's also relatively unlikely that it will be
damaged during a crash.  Nowadays crashes are very rare, and FreeBSD provides
other methods of crash recovery (see page <xref linkend="CFBSD-recovery"/>), so the separate root
file system is not really necessary.  In this case it might be a better idea to
have only one file system and swap.
</para>

<para>If you do have a separate root file system, it doesn't need to be very big, but
the size is increasing.  A better size would be 30 MB.  If you're doing kernel
development, you'll probably want to put in a couple of debug kernels at 10 MB
apiece, so you could easily justify an 80 MB root file system in such cases.
</para>
</sect3>
<sect3>
<title>How much swap space?</title>

<para><indexterm><primary>swap</primary><secondary>space</secondary></indexterm>
<anchor id="CFBSD-how-much-swap"/>
Apart from files, you should also have at least one swap partition on your disk.
It's very difficult to predict how much swap space you need.  The
<emphasis>automatic</emphasis> option gave us 522 MB, slightly more than twice the size of
physical memory.  Maybe you can get by with 64 MB.  Maybe you'll need 2 GB.  How
do you decide?
</para>

<para>It's almost impossible to know in advance what your system will require.  Here
are some considerations:
</para>
<itemizedlist>
<listitem>

<para>Swap space is needed for all pages of virtual memory which contain data that is
not locked in memory and which can't be recreated automatically.  This is the
majority of virtual memory in the system.
</para>
</listitem>
<listitem>

<para>Some people use rules of thumb like ``2.5 times the size of physical memory, or
64 MB, whichever is bigger''.  These rules work only by making assumptions about
your workload.  If you're using more than 2.5 times as much swap space as
physical memory, performance will suffer.
</para>
</listitem>
<listitem>

<para>Known memory hogs are X11 and integrated graphical programs such as NetScape and
StarOffice.  If you use these, you will probably need more swap space.  Older
UNIX-based hogs such as Emacs and the GNU C compiler (<emphasis>gcc</emphasis>) are not in
the same league.
</para>
</listitem>
<listitem>

<para>You can add additional swap partitions on other disks.  This has the additional
advantage of balancing the disk load if your machine swaps a lot.
</para>
</listitem>
<listitem>

<para>About the only ways to change the size of a swap partition are to add another
partition or to reinstall the system, so if you're not sure, a little bit more
won't do any harm, but too little can really be a problem.
</para>
</listitem>
<listitem>

<para>If your system panics, and memory dumping is enabled, it will write the contents
of memory to the swap partition.  This will obviously not work if your swap
partition is smaller than main memory.  Under these circumstances, the system
refuses to dump, but it's not impossible that a bug might cause the dump to
write beyond the bounds of the swap partition, probably causing irreperable
damage to your <emphasis>/usr</emphasis> partition.
</para>
</listitem>
<listitem>

<para>Even with light memory loads, the virtual memory system slowly pages out data in
preparation for a possible sudden demand for memory.  This means that it can be
more responsive to such requests.  As a result, you should have at least as much
swap as memory.
</para>
</listitem>
</itemizedlist>

<para>A couple of examples might make this clearer:
</para>
<itemizedlist>
<listitem>

<para>I used to run <emphasis>X</emphasis>, <emphasis>StarOffice</emphasis>, <emphasis>Netscape</emphasis> and a whole lot of
other memory-hungry applications on an old 486 with 16 MB.  Sure, it's really
slow, especially when changing from one application to another, but it works.
Since there's not much memory, it uses a lot of swap.
</para>

<para><indexterm><primary>command</primary><secondary>pstat</secondary></indexterm>
<indexterm><primary>pstat</primary><secondary>command</secondary></indexterm>
To view the current swap usage, use <emphasis>pstat</emphasis>.  Here's a typical view of this
machine's swap space:
</para>
<programlisting>
$ <command>pstat -s</command>
Device          1024-blocks     Used    Avail Capacity  Type
/dev/da0s1b          122880    65148    57668    53%    Interleaved
</programlisting>

<para></para>
</listitem>
<listitem>

<para>I now run much more stuff on an AMD Athlon with 256 MB of memory.  I've got lots
of swap space, but what I see is:
</para>
<programlisting>
$ <keycap> pstat -s</keycap>
Device          1024-blocks     Used    Avail Capacity  Type
/dev/ad0s1b          524020    22328   501692     4%    Interleaved
</programlisting>

<para></para>
</listitem>
</itemizedlist>

<para>It's not so important that the Athlon is using less swap: it's using 9% of its
memory in swap, whereas the 486 is using 4 times its memory.  In a previous
edition of this book, I had the example of a Pentium with 96 MB of memory, which
used 43 MB of swap.  Look at it from a different point, and it makes more sense:
swap makes up for the lack of real memory, so the 486 is using a total of 80 MB
of memory, the Pentium is using 140 MB, and the Athlon is using 280 MB.  In
other words, there is a tendency to be able to say ``the more main memory you
have, the less swap you need''.
</para>

<para>If, however, you look at it from the point of view of acceptable performance,
you will hear things like ``you need at least one-third of your virtual memory
in real memory''.  That makes sense from a performance point of view, assuming
all processes are relatively active.  And, of course, it's another way of saying
``take twice as much swap as real memory''.
</para>

<para>In summary: be generous in allocating swap space.  In this example, we have a
tiny disk, so we're forced to use a small swap partition.  If you have the
choice, use more.  If you really can't make up your mind, take 512 MB of swap
space.
</para>

<para><indexterm><primary>UNIX</primary><secondary>File System</secondary></indexterm>
<indexterm><primary>Mount</primary></indexterm>
<indexterm><primary>Newfs</primary></indexterm>
<indexterm><primary>UFS</primary></indexterm>
For the file systems, the column <emphasis>Mount</emphasis> now shows the mount points, and
<emphasis>Newfs</emphasis> contains the letters <emphasis>UFS</emphasis> for <emphasis>UNIX File System</emphasis>,
and the letter <emphasis>Y</emphasis>, indicating that we need to create a new file system
before we can use it.
At this point, we have two choices: decide for ourselves what we want, or let
the disk label editor do it for us.  Let's look at both ways:
</para>
</sect3>
<sect3>
<title>Creating the file systems</title>

<para>With these considerations in mind, we'll divide up the disk in the following
manner:
</para>
<itemizedlist>
<listitem>

<para>4 GB for the root file system, which includes <emphasis>/usr</emphasis> and <emphasis>/var</emphasis>.
</para>
</listitem>
<listitem>

<para>512 MB swap space.
</para>
</listitem>
<listitem>

<para>The rest of the disk for the <emphasis>/home</emphasis> file system.
</para>
</listitem>
</itemizedlist>

<para>To create a file system, we press <emphasis>c</emphasis>.  We get a prompt window asking for
the size of the file system, and offering the entire space.  We enter the size
of the root file system:
</para>

<para>When we press ENTER, we see another prompt asking for the kind of partition.  We
select <emphasis>A File System</emphasis>:
</para>

<para>When we press ENTER, we see another prompt asking for the mount point for the
file system.  We enter <emphasis>/</emphasis> for the root file system, after which the
display looks like:
</para>

<para>After we press ENTER again, the display shows:
</para>

<para>Next, we repeat the operation for the swap partition and the <emphasis>/home</emphasis> file
system, entering the appropriate values each time.  We don't change the value
offered for the length of <emphasis>/home</emphasis>: we just use all the remaining space.
At the end we have:
</para>

<para></para>
</sect3>
<sect3>
<title>Second time through</title>

<para>If you have already started an installation and aborted it for some reason after
creating the file systems, things will look a little different when you get
here.  The label editor will find the partitions, but it won't know the name of
the mount points, so the text under <emphasis>Mount</emphasis> will be <emphasis>&lt;none&gt;</emphasis>.  Under
<emphasis>Newfs</emphasis>, you will find an asterisk (<emphasis>*</emphasis>) instead of the text
<emphasis>UFS Y</emphasis>.  The label editor has found the partitions, but it doesn't know
where to mount the file systems.  Before you can use them, you <emphasis>must</emphasis> tell
the label editor the types and mount points of the UFS partitions.  To do this:
</para>
<itemizedlist>
<listitem>

<para>Position the cursor on each of the partitions in turn.
</para>
</listitem>
<listitem>

<para><indexterm><primary>/home
</primary></indexterm>
<indexterm><primary>Mount</primary></indexterm>
<indexterm><primary>Newfs</primary></indexterm>
Press <emphasis>m</emphasis> (Mount).  A prompt window will pop up asking you to specify the
mount point.  Enter the name of the mount point, in this example, first
<emphasis>/</emphasis>, then press return.  The label editor will enter the name of the mount
point under <emphasis>Mount</emphasis>, and under <emphasis>Newfs</emphasis> it will enter <emphasis>UFS
N</emphasis>&mdash;it knows that this is a UFS file system, so it will just check its
consistency, not overwrite it.  Repeat this procedure for <emphasis>/home</emphasis>, and
you're done.
<anchor id="CFBSD-dos-mount-point"/>
If you are sharing your disk with another system, you can also use this method
to specify mount points for your Microsoft file systems.  Simply select the Microsoft
partition and specify the name of a mount point.
</para>
</listitem>
<listitem>

<para><indexterm><primary>command</primary><secondary>fsck</secondary></indexterm>
<indexterm><primary>fsck</primary><secondary>command</secondary></indexterm>
Unless you are very sure that the file system is valid, and you really want to
keep the data in the partitions, press <emphasis>t</emphasis> to specify that the file system
should be created.  The <emphasis>UFS N</emphasis> will change to <emphasis>UFS Y</emphasis>.  If you
leave the <emphasis>N</emphasis> there, the commit phase will check the integrity of the file
system with <emphasis>fsck</emphasis> rather than creating a new one.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect3>
<sect3>
<title>Where we are now</title>

<para>When you get to this point in the installation, you have told <emphasis>sysinstall</emphasis>
everything it needs to know about the layout of the disk or disks you intend to
use for FreeBSD.  Next, you tell it what you want to put on the disks.
</para>
</sect3>
</sect2>
<sect2>
<title>Selecting distributions</title>

<para><indexterm><primary>distributions</primary><secondary>selecting</secondary></indexterm>
<anchor id="CFBSD-select-distribution"/>
The next step is to decide what to install.  Figure <xref linkend="CFBSD-select-distribution-menu"/>
<!--  XXX fix refs .pageref \*[select-distribution-menu-page]  "on page \*[select-distribution-menu-page] " -->
shows us the menu we get when we enter <emphasis>Distributions</emphasis>.  A complete
installation of FreeBSD will use about 1 GB of space, so there's little reason
to choose anything else.  We position the cursor on the line <emphasis>All</emphasis>, as
shown, and press the space bar.
</para>

<para><figure><title>Distribution selection menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>
<note>

<para>Why press the space bar when so far we have been pressing ENTER?  Because in
this particular menu, ENTER will return you to the upper level menu or simply
continue to the media selection menu, depending on the type of installation
you're doing.  It's one of the strangenesses of <emphasis>sysinstall</emphasis>.
</para>
</note>

<para>The next menu is
XXXX  See what's up with crypto.
</para>

<para>Next, you see the message:
</para>

<para>We'll look at the Ports Collection in <xref linkend="CFBSD-chports"/>.  You don't have to install
them now, and it takes much more time than you would expect from the amount of
space that it takes: the Ports Collection consists of about 140,000 very small
files, and copying them to disk can take as long as the rest of the installation
put together.
</para>

<para>Whatever you answer to this question, you are returned to the distribution menu
of figure <xref linkend="CFBSD-select-distribution-menu"/>.  Press ENTER again, and you're done
selecting your distributions.
</para>
<note>

<para>Earlier versions of <emphasis>sysinstall</emphasis> asked you questions about XFree86 at this
point.  Nowadays we do that after completing the installation.
</para>
</note>

<para></para>

<para><figure><title>Installation medium menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>
<sect3>
<title>Where we are now</title>

<para>Now <emphasis>sysinstall</emphasis> knows the layout of the disk or disks you intend to use
for FreeBSD, and what to put on them.  Next, you specify where to get the data
from.
</para>
</sect3>
</sect2>
</sect1>
<sect1>
<title>Selecting the installation medium</title>

<para><indexterm><primary>installation</primary><secondary>medium</secondary></indexterm>
<anchor id="CFBSD-select-medium"/>
<indexterm><primary>menu</primary><secondary>media</secondary></indexterm>
The next thing we need to specify is where we will get the data from.  Where you
go now depends on your installation medium.  Figure <xref linkend="CFBSD-medium-menu"/> shows the
<emphasis>Media</emphasis> menu.  If you're installing from anything except an FTP server or
NFS, you just need to select your medium and then commit the installation, which
we look at on page
</para>
<sect2>
<title>Installing via FTP</title>

<para>Figure <xref linkend="CFBSD-ftp-server-menu"/>
<!-- XXX .pageref \*[ftp-server-menu-page] "on page \*[ftp-server-menu-page]" -->
shows the menu you get when you select <emphasis>FTP</emphasis> or <emphasis>FTP Passive</emphasis>.
</para>

<para><figure><title>Selecting FTP server</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
<indexterm><primary>/usr/ftp</primary></indexterm>
<indexterm><primary>/pub/FreeBSD/\*[Fver]-RELEASE</primary></indexterm>
<indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
<anchor id="CFBSD-install-set-hostname"/>
To see the remainder of the sites, use the <keycap>PageDown</keycap> key.  We want to
install from <emphasis>presto</emphasis>, a system on the local network.  <emphasis>presto</emphasis> isn't
on this list, of course, so we select <emphasis>URL</emphasis>.  Another menu appears, asking
for an ftp pathname in the URL form <emphasis>ftp://<emphasis>hostname<emphasis>/<emphasis>pathname</emphasis></emphasis>.
<emphasis>hostname</emphasis> is the name of the system, in this case
<emphasis>presto.example.org</emphasis>, and <emphasis>pathname</emphasis> is the path relative to the
anonymous ftp directory, which on FreeBSD systems is usually <emphasis>/usr/ftp</emphasis>.
The install program knows its version number, and it attaches it to the name you
supply.
</para>
<note>

<para>You can change the version number from the options menu, for example in order to
install a snapshot of a newer release of FreeBSD.
</para>
</note>

<para>In this case, we're installing version <xref linkend="CFBSD-Fver"/> of FreeBSD, and it's in the
directory <emphasis>/pub/FreeBSD/<xref linkend="CFBSD-Fver"/>-RELEASE</emphasis>.  <emphasis>sysinstall</emphasis> knows the
<emphasis><xref linkend="CFBSD-Fver"/>-RELEASE</emphasis>, so we enter only
<emphasis>ftp://presto.example.org/pub/FreeBSD</emphasis>.  The next menu asks us to configure
our network.  This is the same menu which we would normally fill out at the end
of the installation&mdash;see page
for details.
</para>

<para>This information will be used to set up the machine after installation, so it
pays to fill out this information correctly.  You don't have to fill in
everything, though: for example, you won't need a gateway to access
<emphasis>presto</emphasis> from <emphasis>freebie</emphasis>, since they're both on the same local net.
</para>

<para>After entering this information, you continue with <emphasis>Commit</emphasis> (below).
</emphasis></emphasis></para>
</sect2>
<sect2>
<title>Installing via NFS</title>

<para>We considered the prerequisites for NFS installation on page
<xref linkend="CFBSD-nfs-install-setup"/>.  All you need to do at this point is to give this
information to <emphasis>sysinstall</emphasis>, as shown in figure <xref linkend="CFBSD-nfs-install-menu"/>.  After
entering this information, <emphasis>sysinstall</emphasis> will ask you to configure an
interface.  This is the same procedure which you would otherwise do after
installation&mdash;see page <xref linkend="CFBSD-net-setup"/>.  After performing this configuration,
you continue with <emphasis>Commit</emphasis> (below).
</para>

<para><figure><title>Specifying NFS file system</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>
</sect2>
<sect2>
<title>Installing from floppy disk</title>

<para><anchor id="CFBSD-brain-dead-floppy-install"/>
Installation from floppy disk is definitely the worst choice you have.  You will
need lots of floppies, and the chance of one of them being bad is high.  We
looked at how to prepare floppies for installation in <xref linkend="CFBSD-chconcepts"/>, page
<indexterm><primary>floppy</primary></indexterm>
The installation itself is straightforward enough: select <emphasis>Floppy</emphasis> and
follow the prompts.
</para>
<sect3>
<title>Where we are now</title>

<para>Now <emphasis>sysinstall</emphasis> knows everything it needs to install the software.  It's
just waiting for you to tell it to go ahead.
</para>
</sect3>
</sect2>
</sect1>
<sect1>
<title>Performing the installation</title>

<para><anchor id="CFBSD-commit"/>
So far, everything we have done has had no effect on the disk drives.  If you
change your mind at this point, you can just abort the installation, and the
data on your disks will be unchanged.
</para>

<para>That changes completely in the next step, which we call <emphasis>committing</emphasis> the
installation.  Now is the big moment.  We've set up our partitions, decided what
we want to install and from where.  Now we do it.
</para>

<para>If you are installing with the Custom installation, you need to select
<emphasis>Commit</emphasis> explicitly.  The Standard installation asks you if you want to
proceed:
</para>
<programlisting>
Last Chance!  Are you SURE you want continue the installation?

If you're running this on an existing system, we STRONGLY
encourage you to make proper backups before proceeding.
We take no responsibility for lost disk contents!
</programlisting>

<para><indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
When you answer <emphasis>yes</emphasis>, <emphasis>sysinstall</emphasis> does what we've been preparing
for:
</para>
<itemizedlist>
<listitem>

<para>It creates the partitions and disk partitions.
</para>
</listitem>
<listitem>

<para>It creates the file system structures in the file system partitions, or it
checks them, depending on what you chose in the label editor.
</para>
</listitem>
<listitem>

<para>It mounts the file systems and swap space.
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
<indexterm><primary>/dev/ttyv1</primary></indexterm>
At this point, two other virtual terminals become available.  <emphasis>/dev/ttyv1</emphasis>
shows you what's going on behind the scenes.  You can switch to it with
<keycap>ALT-F2</keycap>.  Right at the beginning you'll see a whole lot of error messages
as <emphasis>sysinstall</emphasis> tries to initialize every device it can think of.  Don't
worry about them, they're normal.  To get back to the install screen, press
<keycap>ALT-F1</keycap>.
</para>

<para><indexterm><primary>/dev/ttyv3</primary></indexterm>
In addition, after <emphasis>sysinstall</emphasis> mounts the root file system, it starts an
interactive shell on <emphasis>/dev/ttyv3</emphasis>.  You can use it if something goes wrong,
or simply to watch what's going on while you're installing.  You switch to it
with <keycap>ALT-F4</keycap>.
</para>

<para>After reading in all the files, <emphasis>sysinstall</emphasis> displays further information
messages:
</para>
<programlisting>
Remaking all devices..  Please wait!

Making slice entries

Fixing permissions..
</programlisting>

<para>And we're done!
<indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
</para>
<sect2>
<sect3>
<title>Where we are now</title>

<para>When we get here, the software has been installed on the disk, but we still need
to customize some information to match our environment.  We'll look at this in
the following sections.
</para>
</sect3>
</sect2>
</sect1>
<sect1>
<title>Network services</title>

<para><indexterm><primary>network</primary><secondary>services</secondary></indexterm>
Figure <xref linkend="CFBSD-network-services"/>
<!--  XXX .pageref \*[network-services-page] "on page \*[network-services-page]" -->
shows the Network Services Menu.  You don't see this menu in the Standard and
Express installations: after setting up your network interfaces,
<emphasis>sysinstall</emphasis> presents you with various items from the Network Services
Menu.  The Custom installation presents you with the menu itself.
</para>

<para><figure><title>Network services menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
The first step should always be to set up the network interfaces, so this is
where you find yourself if you are performing a Standard or Express installation.
</para>
<sect2>
<title>Setting up network interfaces</title>

<para><indexterm><primary>network</primary><secondary>interfaces</secondary></indexterm>
<anchor id="CFBSD-net-setup"/>
<indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
Figure <xref linkend="CFBSD-network-setup-menu"/>
<!--  XXX .pageref \*[network-setup-menu-page] "on page \*[network-setup-menu-page]" -->
shows the network setup menu.  If you installed via FTP or NFS, you will already
have set up your network interfaces, and <emphasis>sysinstall</emphasis> won't ask the
questions again.
</para>

<para><figure><title>Network setup menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
The only real network board on this list is <emphasis>ep0</emphasis>, the Ethernet board.  The
others are standard hardware which can also be used as network interfaces.  In
our case, we choose the Ethernet board.  The next menu asks us to set the
internet parameters.  Figure <xref linkend="CFBSD-network-config-menu"/>
<!--  XXX .pageref \*[network-config-menu-page] "on page \*[network-config-menu-page]" -->
shows the network configuration menu after filling in the values.
</para>

<para><figure><title>Network configuration menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
You need to specify the local host name and the domain name separately.  The
names and addresses correspond to the example network that we will look at in
<xref linkend="CFBSD-chnetintro"/>, on page <xref linkend="CFBSD-reference-net-page"/>.  We have chosen to call this
machine <emphasis>presto</emphasis>, and the domain is <emphasis>example.org</emphasis>.  In other words, the
full name of the machine is <emphasis>presto.example.org</emphasis>.  Its IP address is
<emphasis>223.147.37.2</emphasis>.  In this configuration, all access to the outside world
goes via <emphasis>gw.example.org</emphasis>, which has the IP address <emphasis>223.147.37.5</emphasis>.
The name server is located on the same host, <emphasis>presto.example.org</emphasis>.  Since
the name server isn't running when this information is needed, we specify all
addresses in numeric form.
</para>

<para>What happens if you don't have a domain name?  Well, the simple answer is ``go
out and get one''&mdash;see page <xref linkend="CFBSD-domainreg"/>.  But in the meantime, don't fake
it.  Just leave the fields empty.
</para>

<para><indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>ifconfig</secondary></indexterm>
<indexterm><primary>ifconfig</primary><secondary>command</secondary></indexterm>
As is usual for a class C network, the net mask is <emphasis>255.255.255.0</emphasis>.  You
don't need to fill in this information&mdash;if you leave this field without
filling it in, <emphasis>sysinstall</emphasis> will insert it for you.  Normally, as in this
case, you wouldn't need any additional options to <emphasis>ifconfig.</emphasis>
</para>
</sect2>
<sect2>
<title>Other network options</title>

<para>You don't need to specify  any of the remaining configuration options during
configuration.  See the online handbook for further details.
</para>
</sect2>
</sect1>
<sect1>
<title>Machine configuration</title>

<para><indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
The final part of the installation deals with optional setup items.  You don't
need to do any of this right now, but if this is the first time you have
installed FreeBSD, you will probably want to at least add a user.
<!--   XXX Add user  -->
If you're like me, you'll also have a couple of favourite programs that you want
to install, probably including XFree86.  The Express and Standard installations
walk you through these points, while figure <xref linkend="CFBSD-final-config-menu"/>
<!--  XXX .pageref \*[final-config-menu-page] "on page \*[final-config-menu-page]" -->
shows you the menu that Custom installation presents.
</para>

<para><figure><title>Final configuration menu</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>
</sect1>
<sect1>
<title>Rebooting the new system</title>

<para>Finally, it's done.  You exit the main menu by selecting <emphasis>Quit</emphasis>.  Before
you answer the question asking for confirmation, remember to remove the boot
diskette&mdash;otherwise you'll end up rebooting from the floppy instead.  If you
have booted from CD-ROM, either remove the CD-ROM, or reset the boot
configuration in the BIOS before rebooting.
</para>

<para>After that, the system will reboot.  The results look much the same as before,
but this time, instead of going in to the <emphasis>sysinstall</emphasis> menu, it continues to
start up the machine and give you a login prompt.  We're done!
</para>
<sect2>
<title>Where to put <emphasis>/var</emphasis> and <emphasis>/tmp</emphasis> </title>

<para><anchor id="CFBSD-symlink-var"/>
<indexterm><primary>/var</primary></indexterm>
<indexterm><primary>/usr/var</primary></indexterm>
<indexterm><primary>/var</primary></indexterm>
<indexterm><primary>/usr/var</primary></indexterm>
Now the installation is completed, but you may still have some housekeeping to
do.  Did you include a <emphasis>/var</emphasis> file system on your disk?  In the example,
we didn't. If we don't specify anything else, <emphasis>/var</emphasis> will end up on the
root file system, which isn't enormous.  If we leave things like that, there's a
very good chance that the root file system will fill up.  We solve this problem
by creating a directory <emphasis>/usr/var</emphasis> and a symbolic link <emphasis>/var</emphasis> which
points to <emphasis>/usr/var</emphasis>:
</para>
<programlisting>
# <command>mkdir /usr/var</emphasis>					<emphasis>create a new directory</command>
# <command>cd /var</emphasis>							<emphasis>move to the old /var directory</command>
# <command>tar cf - . | (cd /usr/var; tar xf - )</emphasis>	<emphasis>copy its contents</command>
# <command>cd /</emphasis>							<emphasis>get out of the directory</command>
# <command>rm -rf /var</emphasis>						<emphasis>and remove it</command>
# <command>ln -s /usr/var /var</emphasis>				<emphasis>now link to the new directory</command>
</programlisting>

<para>After performing these steps, you might see messages like:
</para>
<programlisting>
Jan  9 13:15:00 myname syslogd: /var/run/utmp: no such file or directory
</programlisting>

<para><indexterm><primary>syslogd</primary></indexterm>
<indexterm><primary>System</primary><secondary>Log d&aelig;gmon</secondary></indexterm>
<indexterm><primary>d&aelig;gmon</primary><secondary>System Log</secondary></indexterm>
<emphasis>syslogd</emphasis> is the System Log d&aelig;gmon.
<footnote>

<para>See page <xref linkend="CFBSD-daemon"/> for a description of d&aelig;gmons.
</para>
</footnote>
Don't worry about these messages.  If you're intending to restart the system
soon, just wait until then and the messages will go away.  Otherwise you can
restart <emphasis>syslogd</emphasis>:
</para>
<programlisting>
# <command>ps waux | grep syslogd</emphasis>				<emphasis>look for the syslog d&aelig;gmon</command>
root	152 11.0  1.6	 176  476   v0	D+     1:16M   0:00.15 grep syslogd
root	 58  0.0  1.1	 184  332   ??	Ds     1:13    0:00:57 syslogd
# <command>kill -9 58</emphasis>						<emphasis>stop the PID of syslogd</command>
# </emphasis><command>syslogd</command>							<emphasis>and start it again
</programlisting>

<para>The PID of the <emphasis>syslogd</emphasis> is the second field on the line which ends with
just <emphasis>syslogd</emphasis>.  The first line is the process which is looking for the
text <emphasis>syslogd</emphasis>.  See <xref linkend="CFBSD-chunixref"/>, page
for more information on stopping processes.
</para>

<para><indexterm><primary>/tmp</primary></indexterm>
<indexterm><primary>file</primary><secondary>system</secondary></indexterm>
<indexterm><primary>/var/tmp</primary></indexterm>
<indexterm><primary>file</primary><secondary>system</secondary></indexterm>
Programs should not write large files to <emphasis>/tmp</emphasis>; if a program needs to
create a large temporary file, it should create it in <emphasis>/var/tmp</emphasis>.
Unfortunately, the location of the temporary files is not usually in your hands.
It would be tempting to also replace <emphasis>/tmp</emphasis> with a symbolic link to
<emphasis>/var/tmp</emphasis>, but the system handles <emphasis>/tmp</emphasis> and <emphasis>/var/tmp</emphasis>
slightly differently: after a reboot, it removes all files from <emphasis>/tmp</emphasis>, but
it leaves the files in <emphasis>/var/tmp</emphasis>.  You can solve this problem by creating a
directory <emphasis>/usr/tmp</emphasis> and creating a link to it.
</para>

<para>Perform the following steps in single-user mode (see <xref linkend="CFBSD-chunixref"/>, page
for a description of single user mode and how to get into it).
</para>
<programlisting>
# <command>mkdir /usr/tmp</emphasis>					<emphasis>create a new directory</command>
# <command>rm -rf /tmp</emphasis>						<emphasis>and remove the old /tmp</command>
# <command>ln -s /usr/tmp /tmp</emphasis>				<emphasis>now link to the new directory</command>
</programlisting>

<para></para>
</sect2>
</sect1>
<sect1>
<title>Installing FreeBSD on a Compaq AXP (Alpha) system</title>

<para><indexterm><primary>installing</primary><secondary>on Alpha</secondary></indexterm>
<indexterm><primary>Alpha</primary><secondary>installing on</secondary></indexterm>
<anchor id="CFBSD-alpha-install"/>
FreeBSD <xref linkend="CFBSD-Fver"/> includes support for the AXP (Alpha) processor architecture,
but it's not yet of the same standard as for the i386 architecture.  The
following instructions are preliminary: before following them, read the booklet
that came with the CD-ROMs: it's possible that there have been some last-minute
changes.  If all else fails, you can find the latest installable version of
FreeBSD for the alpha at <emphasis>ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/alpha/</emphasis>
or on a mirror site.
</para>

<para>In principle, you perform the same steps to install FreeBSD on the Alpha
architecture that you perform for the Intel architecture.  See page
<xref linkend="CFBSD-alpha-concepts"/> for some differences.
</para>

<para>The easiest type of installation is from CD-ROM.  If you have a supported CD-ROM
drive and a FreeBSD installation CD for Alpha from Walnut Creek CDROM, you can
start the installation by building a set of FreeBSD boot floppy from the files
<emphasis>floppies/kern.flp</emphasis> and <emphasis>floppies/mfsroot.flp</emphasis> as described for the
Intel architecture on page <xref linkend="CFBSD-make-floppy"/>.  Use the CD-ROM marked ``Alpha
installation''.  From the SRM console prompt, insert the <emphasis>kern.flp</emphasis> floppy
and type the following command to start the installation:
</para>
<programlisting>
&gt;&gt;&gt;<command>boot dva0</command>
</programlisting>

<para>Insert the <emphasis>mfsroot.flp</emphasis> floppy when prompted and you will end up at the
first screen of the install program.  You can then continue as for the Intel
architecture on page <xref linkend="CFBSD-boot-install-kernel"/>.
</para>

<para>To install over the net, fetch the floppy images from the FTP site, boot as
above, then proceed as for the Intel architecture.
</para>

<para>Once the install procedure has finished, you will be able to start FreeBSD/alpha
by typing something like this to the SRM prompt:
</para>
<programlisting>
&gt;&gt;&gt;<command>boot dkc0</command>
</programlisting>

<para>This instructs the firmware to boot the specified disk. To find the SRM names of
disks in your machine, use the show device command:
</para>
<programlisting>
&gt;&gt;&gt;<command>show device</command>
dka0.0.0.4.0               DKA0           TOSHIBA CD-ROM XM-57  3476
dkc0.0.0.1009.0            DKC0                       RZ1BB-BS  0658
dkc100.1.0.1009.0          DKC100             SEAGATE ST34501W  0015
dva0.0.0.0.1               DVA0
ewa0.0.0.3.0               EWA0              00-00-F8-75-6D-01
pkc0.7.0.1009.0            PKC0                  SCSI Bus ID 7  5.27
pqa0.0.0.4.0               PQA0                       PCI EIDE
pqb0.0.1.4.0               PQB0                       PCI EIDE
</programlisting>

<para>This example comes from a Digital Personal Workstation 433au and shows three
disks attached to the machine. The first is a CD-ROM called <emphasis>dka0</emphasis> and the
other two are disks and are called <emphasis>dkc0</emphasis> and <emphasis>dkc100</emphasis> respectively.
</para>

<para>You can specify which kernel file to load and what boot options to use
with the <emphasis>-file</emphasis> and <emphasis>-flags</emphasis> options to boot:
</para>
<programlisting>
&gt;&gt;&gt;<command>boot -file kernel.old -flags s</command>
</programlisting>

<para>To make FreeBSD/alpha boot automatically, use these commands:
</para>
<programlisting>
&gt;&gt;&gt;<command>set boot_osflags a</command>
&gt;&gt;&gt;<command>set bootdef_dev dkc0</command>
&gt;&gt;&gt;<command>set auto_action BOOT</command>
</programlisting>

<para></para>
</sect1>
<sect1>
<title>Upgrade installation</title>

<para><anchor id="CFBSD-upgrade-install"/>
As the name implies, upgrade installations are intended to help you upgrade from
an earlier version of FreeBSD.  This kind of installation is still being
developed, and it is possible that all sorts of things can go wrong.  If you
want to use it, make sure you have backed up your old system before you start,
and read carefully the warning messages that appear.  If things do go wrong, you
can always reinstall and then restore your backups.
</para>
</sect1>
<sect1>
<title>Changing configuration</title>

<para><indexterm><primary>configuration</primary><secondary>changing</secondary></indexterm>
<anchor id="CFBSD-reconfig"/>
Once your system is up and running, you're bound to find something that you want
to change.  The online handbook gives more information on this, but it's good to
know that you can start <emphasis>sysinstall</emphasis> after the system is running: it's
called <emphasis>/stand/sysinstall</emphasis>.  For an alternative way to configure additional
disks, see <xref linkend="CFBSD-chdisks"/>, page <xref linkend="CFBSD-second-disk"/>.
</para>
</sect1>
<sect1>
<title>Installing additional software</title>

<para><anchor id="CFBSD-pkg_add"/>
<indexterm><primary>emacs</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>emacs</secondary></indexterm>
<indexterm><primary>bash</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>bash</secondary></indexterm>
<indexterm><primary>less</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>less</secondary></indexterm>
<indexterm><primary>pine</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>pine</secondary></indexterm>
Once your system is up and running, you may find that things you expect are
missing.  Where's <emphasis>Emacs</emphasis>?  Where's <emphasis>bash</emphasis>?  Where's <emphasis>less</emphasis>?
They're all there, and just about everything else is as well.  We'll look at how
to install them in <xref linkend="CFBSD-chports"/>, starting on page <xref linkend="CFBSD-ports-collection"/>.
</para>
</sect1>
<sect1>
<title>How to uninstall FreeBSD</title>

<para><indexterm><primary>uninstall</primary></indexterm>
<indexterm><primary>removing</primary><secondary>FreeBSD from disk</secondary></indexterm>
What, you want to remove FreeBSD?  Why would you want to do that?
</para>

<para>Seriously, if you decide you want to completely remove FreeBSD from the system,
this is no longer a FreeBSD issue, it's an issue of whatever system you use to
replace it.  For example, on page <xref linkend="CFBSD-death-to-Microsoft"/> we saw how to remove a
Microsoft partition and replace it with FreeBSD; no Microsoft software was
needed to remove it.
XXX
    What I do is make /tmp a softlink to /var/tmp, and make /var/tmp its
    own partition.

    I turn softupdates on on all my partitions, including root (you can do
    that now)

    I do NOT use MFS or MD for /tmp, nor do I leave it on /.  I keep it as
    a separate partition and combine it with /var/tmp because both /tmp
    and /var/tmp tend to be used interchangeably anyway, and /tmp
    (or /var/tmp) is the most likely of all your partitions to get filled
    up accidently and you don't want that interfering with other things if
    it happens.  Many things use /tmp, so you can wind up with megabytes in
    it which makes it unsuitable for use with MD and inefficient when used
    with MFS.

    Typically I configure my paritions as follows:

        /               128MB
        swap            (2x main memory, 128MB minimum)
        /var            128MB (minimum, more if using machine for mail/printing)
        /var/tmp        128MB (minimum, more if using machine multiuser)
        /usr            2G
        /home           remainder of disk

        /tmp softlink to /var/tmp
        /compat softlink to /usr/compat

    Even though '/' per say only needs 64MB, having 128MB there is useful.
    I've seen 64MB / partitions 'fill up' with softupdates turned on when
    doing an installworld (because softupdates doesn't delete the files
    being replaced fast enough), and I tend to keep debug kernels sitting
    around in / as well.

    I make /usr big (2G) in order to accomodate ports, since /usr/local
    is part of /usr.

    The ordering of the partitions is also carefully arranged.  The lower
    sector numbers are the 'faster' sectors on a disk, closer to the outer
    rim of the disk where transfer rates are much faster.  So I put swap
    there along with the smaller partitions, and put /usr and /home later
    since those partitions are big enough that you really don't get a
    uniform performance benefit anyway.

                                                -Matt (Dillon)
</para>
</sect1>
</chapter>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchxsetup"><title>Setting up X11</title>

<para><anchor id="CFBSD-xinstall"/>
FreeBSD <xref linkend="CFBSD-Fver"/> comes with XFree86
version <xref linkend="CFBSD-Xver"/>.<xref linkend="CFBSD-Xupdate"/>,
a port of X11R6 that supports several versions of Intel-based UNIX.
This chapter describes how to set up your XFree86 server.  It is based on
material supplied with the FreeBSD release, specifically the files
<emphasis>README.FreeBSD</emphasis> and <emphasis>README.Config</emphasis> in the directory
<emphasis>/usr/X11R6/lib/X11/doc</emphasis>.  If you find any discrepancy, the material in
those files will be more up-to-date than this description.  In addition, the
file <emphasis>/usr/X11R6/lib/X11/doc/RELNOTES</emphasis> contains OS-independent information
about the <xref linkend="CFBSD-Xver"/> release.
</para>

<para>X uses a lot of memory.  In order to run X, your system should have an absolute
minimum of 8 MB of memory, but performance will be painful with so little
memory.  A more practical minimum is 16 MB, and you can improve performance by
adding much more memory.  If you use X intensively, you will continue seeing
performance improvement by increasing to as much as 128 MB of RAM.
</para>
<sect1>
<title>For the impatient</title>

<para>There's lots of useful information in the rest of this chapter, but maybe you're
not interested in information right now.  You just want to get your X server up
and running.  However, be warned:
</para>
<note>

<para>An incorrect installation can burn out your monitor or your video board.
</para>
</note>

<para>Read page
for further details.
</para>

<para>However, if you know you're in spec, and you have a standard Super VGA board and
a good multifrequency monitor, then you can probably get things up and running
without reading this
chapter.  Read the section on X installation in
<xref linkend="CFBSD-chquickinstall"/>, page
If things don't work, come back here and read on.
</para>
</sect1>
<sect1>
<title>Installing XFree86</title>

<para>The easiest way to install XFree86 is with the <emphasis>sysinstall</emphasis> program,
either when you're installing the system, or later by starting the program
<emphasis>/stand/sysinstall</emphasis>.  See <xref linkend="CFBSD-chinstall"/>, page
for details of how to install the software.  In the rest of this chapter, we'll
look at what makes up the distribution, and on page
we'll look at how to configure X once it has been installed.
</para>
</sect1>
<sect1>
<title>The XFree86 distribution</title>

<para><indexterm><primary>XF86333</primary></indexterm>
XFree86 is distributed as a bewildering number of archives in the directory
<emphasis>/cdrom/XF86333</emphasis>.  In the following section, we'll take a look at what you
should install.  Don't worry too much, though: if you can't decide what to pick
and you have 200MB of disk space free, it's safe to unpack everything.
</para>

<para>At a minimum you need to unpack the archives in the following table and at least
one server that matches your VGA board.  You'll need 10Mb for the minimum required
run-time binaries only, and between 1.7 and 3 MB for the server.
<!--  Current contents of /cdrom/1/XF86332 -->
<!--  X3329set.tgz  Japanese setup -->
<!--  X332jdoc.tgz Japanese docs -->
<!--  X332jset.tgz -->
<!--  X332prt.tgz  Sample server? -->
<!--  X332set.tgz XF86setup -->
<!--  X332vfb.tgz  -->
<table frame='all'><title>Required components of XFree86</title>
box, center, tab(#) ;
| lfI |  lw55 | .
Archive#Description
=
X333bin.tgz#T{
All the executable X client applications and shared librariess
T}
X333fnts.tgz#T{
The misc and 75 dpi fonts
T}
X333lib.tgz#T{
Data files and libraries needed at runtime
T}
X3331upd.tgz#T{
Update number <xref linkend="CFBSD-Xupdate"/> to the XFree86 release.
T}
</tbody></tgroup></table>
The file <emphasis>X3331upd.tgz</emphasis> updates XFree86 from the base release (<xref linkend="CFBSD-Xver"/>)
to release <xref linkend="CFBSD-Xver"/>.<xref linkend="CFBSD-Xupdate"/>.  Each incremental update includes the contents
of any previously released updates (in this case there are none).  You must
extract these updates after extracting the base release, since they contain
replacements for files in the other archives.  The archives on the FreeBSD
<xref linkend="CFBSD-Fver"/> CD-ROM include update <xref linkend="CFBSD-Xupdate"/> of XFree86 <xref linkend="CFBSD-Xver"/>.  They are not
the same as the XFree86 <xref linkend="CFBSD-Xver"/> archives on <emphasis>ftp://ftp.XFree86.org/</emphasis>.
</para>
<sect2>
<title>The X Server</title>

<para><indexterm><primary>X</primary></indexterm>
In addition to the archives above, you need at least one server, which will take
up about 3 MB of disk.  The choice depends primarily on what kind of display
board you have.  The default server name is <emphasis>/usr/X11R6/bin/X</emphasis>, and it is a
link to a specific server binary <emphasis>/usr/X11R6/bin/XF86_<emphasis>xxxx</emphasis></emphasis>.  You'll
find the server archives for the standard PC architecture in
<emphasis>/cdrom/XF86333/Servers</emphasis>, and the servers for the Japanese PC98 architecture
in <emphasis>/cdrom/XF86333/PC98-Servers</emphasis>:
<table frame='all'><title>XFree86 servers for standard PC architecture</title>
box, center, tab(#) ;
| lfI |  lw62 | .
Archive#Description
=
X3338514.tgz#T{
8-bit colour for IBM 8514 and true compatibles.
T}
X333AGX.tgz#T{
8 and 16-bit colour for AGX and XGA boards.
T}
X333I128.tgz#T{
8 and 16-bit colour for I128 boards.
T}
X333Ma32.tgz#T{
8 and 16-bit colour for ATI Mach32 boards.
T}
X333Ma64.tgz#T{
8, 16 and 32-bit colour for ATI Mach64 boards.
T}
X333Ma8.tgz#T{
8-bit colour for ATI Mach8 boards.
T}
X333Mono.tgz#T{
1-bit monochrome for VGA, Super-VGA, Hercules, and others.
T}
X333P9K.tgz#T{
8, 16, and 32-bit colour for Weitek P9000 boards (Diamond Viper).
T}
X333S3.tgz#T{
8, 16 and 32-bit colour for S3 boards.
T}
X333S3V.tgz#T{
8 and 16-bit colour for S3 ViRGE boards.
T}
X333SVGA.tgz#T{
&gt;=8-bit colour for Super-VGA cards.
T}
X333VG16.tgz#T{
4-bit colour for VGA and Super-VGA cards
T}
X333W32.tgz#T{
8-bit colour for ET4000/W32, /W32i, /W32p and ET6000 cards.
T}
</tbody></tgroup></table>
<table frame='all'><title>XFree86 servers for Japanese PC98 architecture</title>
box, center, tab(#) ;
| lfI |  lw65 | .
Archive#Description
=
X3339GAN.tgz#T{
8-bit colour for PC98 GA-98NB/WAP boards
T}
X3339GA9.tgz#T{
8, 16 and 32-bit colour for PC98 S3 GA-968 boards
T}
X3339480.tgz#T{
8-bit colour for PC98 PEGC
T}
X3339NKV.tgz#T{
8-bit colour for PC98 NEC-CIRRUS/EPSON NKV/NKV2 boards
T}
X3339WBS.tgz#T{
8-bit colour for PC98 WAB-S boards
T}
X3339WEP.tgz#T{
8-bit colour for PC98 WAB-EP boards
T}
X3339WSN.tgz#T{
8-bit colour for PC98 WSN-A2F boards
T}
X3339EGC.tgz#T{
4-bit colour for PC98 EGC
T}
X3339TGU.tgz#T{
8 and 16-bit colour for PC98 Trident Cyber9320/9680 boards
T}
X3339NS3.tgz#T{
8 and 16-bit colour for PC98 NEC S3 boards
T}
X3339SPW.tgz#T{
8 and 16-bit colour for PC98 S3 PW/PCSKB boards
T}
X3339LPW.tgz#T{
8 and 16-bit colour for PC98 S3 PW/LB boards
T}
</tbody></tgroup></table>
Each of these servers includes a manual page which contains details of supported
chipsets and server-specific configuration options.
</para>

<para>A number of archives are provided for X programmers:
<table frame='all'><title>XFree86 programmer's files</title>
box, center, tab(#) ;
lfI | lw57 .
Archive#Description
=
X333prog.tgz#T{
config, <emphasis>lib*.a</emphasis> and <emphasis>*.h</emphasis> files needed for
compiling clients.
T}
X333ctrb.tgz#T{
Contributed sources.
T}
X333lk98.tgz#T{
The ``link kit'' for building servers, Japanese PC98 version.
T}
<!--  XXX X3333lk98.tgz#T{ -->
<!--  XXX Update archive for the ``link kit'', Japanese PC98 version. -->
<!--  XXX T} -->
X333lkit.tgz#T{
The ``link kit'' for building servers, normal architecture version.
T}
<!--  XXX X3333lkit.tgz#T{ -->
<!--  XXX Update archive for the ``link kit'', normal architecture version. -->
<!--  XXX T} -->
X333src-1.tgz#T{
Part 1 of the complete sources
T}
X333src-2.tgz#T{
Part 2 of the complete sources
T}
X333src-3.tgz#T{
Part 3 of the complete sources
T}
</tbody></tgroup></table>
You'll need <emphasis>X333prog.tgz</emphasis> if you intend to install ports of X software.
</para>

<para>Finally, XFree86 includes a number of optional parts:
<table frame='all'><title>XFree86 documentation</title>
box, center, tab(#) ;
lfI | lw57 .
Archive#Description
=
X333doc.tgz#T{
READMEs
T}
X333jdoc.tgz#T{
READMEs in Japanese
T}
X333ps.tgz#T{
READMEs in PostScript
T}
X333html.tgz#T{
READMEs in HTML
T}
X333man.tgz#T{
man pages
T}
</tbody></tgroup></table>
<table frame='all'><title>XFree86 setup programs</title>
box, center, tab(#) ;
lfI | lw67 .
Archive#Description
=
<indexterm><primary>X333cfg.tgz</primary></indexterm>
X333cfg.tgz#T{
Customizable <emphasis>xinit</emphasis> and <emphasis>xdm</emphasis> runtime configuration files.
T}
X333set.tgz#T{
The <emphasis>XF86Setup</emphasis> utility, a graphical version of the <emphasis>xf86config</emphasis>
utility that we will look at on page <xref linkend="CFBSD-xf86config"/>.
T}
X333jset.tgz#T{
The <emphasis>XF86Setup</emphasis> utility, Japanese version, for the normal PC architecture.
T}
<!--  XXX X3339set.tgz#T{ -->
<!--  XXX The <emphasis>XF98Setup</emphasis> utility, Japanese version.  This corresponds to -->
<!--  XXX <emphasis>XF86Setup</emphasis>, but is intended for the Japanese PC98 architecture. -->
<!--  XXX T} -->
</tbody></tgroup></table>
<emphasis>XF86Setup</emphasis> is a graphical mode setup program for XFree86, and you may
prefer it to the standard setup program <emphasis>xf86config</emphasis>.  You don't need any
special archives for <emphasis>xf86config</emphasis>: it's included in <emphasis>X333bin.tgz</emphasis>.
</para>

<para>The first time you install, you will need <emphasis>X333cfg.tgz</emphasis> to create your
initial configuration files.  Don't use it when upgrading: it overwrites your
configuration files.
<table frame='all'><title>Additional fonts</title>
box, center, tab(#) ;
lfI | lw57 .
Archive#Description
=
X333f100.tgz#T{
100dpi fonts
T}
X333fscl.tgz#T{
Speedo and Type1 fonts
T}
X333fnon.tgz#T{
Japanese, Chinese and other non-english fonts
T}
X333fcyr.tgz#T{
Cyrillic fonts
T}
</tbody></tgroup></table>
Unlike the X servers described above, the archives for the following servers are
all in the main directory <emphasis>/cdrom/disk/XF86333</emphasis>:
<table frame='all'><title>Miscellaneous servers</title>
box, center, tab(#) ;
lfI | lw67 .
Archive#Description
=
X333fsrv.tgz#T{
The font server
T}
X333nest.tgz#T{
A nested server running as a client window on another display.
T}
X333prt.tgz#T{
The X print server.
T}
X333vfb.tgz#T{
The Virtual Framebuffer X server, which renders into memory or an <emphasis>mmap</emphasis>ped
file.
T}
</tbody></tgroup></table>
<indexterm><primary>xdm</primary><secondary>command</secondary></indexterm>
<indexterm><primary>DES</primary></indexterm>
Earlier versions
of FreeBSD
also supplied a separate <emphasis>xdm</emphasis> archive due to export restrictions on the
encryption software included in <emphasis>xdm</emphasis>.  FreeBSD
<xref linkend="CFBSD-Fver"/>
handles encryption in shared libraries now, so that <emphasis>xdm</emphasis> no longer
contains <emphasis>DES</emphasis>, and has been included in the standard archives.
</para>

<para>In addition, earlier versions of XFree86 included the archives
<emphasis>X333pex.tgz</emphasis>, with software for 3D applications, and <emphasis>X333lbx.tgz</emphasis>, the
low bandwidth X proxy server and libraries.  The files in these archives are now
included in the appropriate places in the other archives.  You no longer need to
install them explicitly.
</para>
</sect2>
</sect1>
<sect1>
<title>Installing XFree86 manually</title>

<para>If you don't use <emphasis>sysinstall</emphasis> to install X, you need to perform a number
of steps:
</para>
<itemizedlist>
<listitem>

<para>First, create the directories and unpack the required archives.
</para>
</listitem>
<listitem>

<para>Choose and install an X server.
</para>
</listitem>
<listitem>

<para>Install any updates.
</para>
</listitem>
<listitem>

<para>Set up the environment to be able to access X.
</para>
</listitem>
<listitem>

<para>Find a virtual terminal in which to run X.
</para>
</listitem>
<listitem>

<para>Configure X for your hardware.
</para>
</listitem>
</itemizedlist>

<para>This sounds like a lot of work, but if you approach it methodically, it's not
too bad.  In the rest of the chapter, we'll look at each step in turn.
</para>
<sect2>
<title>Unpacking the archives</title>

<para>You must unpack the archives as <emphasis>root</emphasis>, since a number of the executables
are set-user-id (they run as <emphasis>root</emphasis> even when started by other users).  If
you unpack the server as an ordinary user, it may abort when you try to run it.
You must also use a <emphasis>umask</emphasis> value of <emphasis>022</emphasis> (permissions
<emphasis>rwxr-xr-x</emphasis>), because the X server requires special permissions.  See page
<xref linkend="CFBSD-umask"/> for an explanation of <emphasis>umask</emphasis>.
</para>
<programlisting>
$ <command>su</command>
Password:
# <command>umask 022</command>
</programlisting>

<para>If you don't have enough space in the <emphasis>/usr</emphasis> file system, create a directory
on another partition and symlink it to <emphasis>/usr</emphasis>.  For example, if you have a
file system <emphasis>/home</emphasis> with adequate space, you could do:
</para>
<programlisting>
# <command>cd /home</command>
# <command>mkdir X11R6</command>
# <command>ln -s /home/X11R6 /usr/X11R6</command>
</programlisting>

<para>Next, decide which archives you want to install.
<indexterm><primary>xinitrc</primary></indexterm>
<indexterm><primary>xdm</primary></indexterm>
<indexterm><primary>X333xdcf.tgz</primary></indexterm>
<indexterm><primary>X333fscl.tgz</primary></indexterm>
For a minimal installation, choose <emphasis>/cdrom/XF86333/X333bin.tgz</emphasis>,
<emphasis>/cdrom/XF86333/X333fnts.tgz</emphasis>, <emphasis>/cdrom/XF86333/X333lib.tgz</emphasis>,
<emphasis>/cdrom/XF86333/X333cfg.tgz</emphasis>, and finally any updates, in this case
<emphasis>/cdrom/XF86333/X3331upd.tgz</emphasis>.  If you have already configured X for your
hardware, omit <emphasis>/cdrom/XF86333/X333cfg.tgz</emphasis>.
</para>

<para>If you are using sh, unpack like this:
</para>
<programlisting>
# <command>mkdir -p /usr/X11R6</command>
# <command>cd /usr/X11R6</command>
<!--  XXX -->
# <command>for i in bin fnts lib cfg 1upd; do</command>
# <command>  tar xzf /cdrom/XF86333/X333$i.tgz</command>
# <command>done</command>
</programlisting>

<para>If you are using csh, enter:
</para>
<programlisting>
% <command>mkdir -p /usr/X11R6</command>
% <command>cd /usr/X11R6</command>
<!--  XXX -->
% <command>foreach i (bin fnts lib cfg 1upd)</command>
? <command>  tar xzf /cdrom/XF86333/X333$i.tgz</command>
? <command>end</command>
</programlisting>

<para>If you're installing update archives, it's very important that the last name in
the list is the abbreviation of the name of the update (<emphasis>1upd</emphasis>): this
update archive contains replacements for files in the other archives.  This also
makes it complicated if you want to install everything: you can't just write
<emphasis>/cdrom/XF86333/X333*.tgz</emphasis>, since that would install the update
(<emphasis>1upd</emphasis>) before most of the other archives.  Instead, you need to spell it
out:
</para>
<programlisting>
# <command>mkdir -p /usr/X11R6</command>
# <command>cd /usr/X11R6</command>
# <command>for i in 9set bin cfg contrib doc f100 fcyr fnon fnts fscl fsrv \e
&gt;          html jdoc jset lib lkit man nest prog prt ps set \e
&gt;          src-1 vfb 1upd; do</command>
# <command>  tar xzf /cdrom/XF86333/X333$i.tgz</command>
# <command>done</command>
</programlisting>

<para>If you are using csh, enter:
</para>
<programlisting>
% <command>mkdir -p /usr/X11R6</command>
% <command>cd /usr/X11R6</command>
% <command>foreach i (9set bin cfg contrib doc f100 fcyr fnon fnts fscl fsrv \e
             html jdoc jset lib lkit man nest prog prt ps set \e
             src-1 vfb 1upd; do</command>
? <command>  tar xzf /cdrom/XF86333/X333$i.tgz</command>
? <command>end</command>
</programlisting>

<para>As with the minimal install, make sure that the abbreviation for the update
archive <emphasis>1upd</emphasis> comes last.
</para>

<para>The prompts during the command (<emphasis>#</emphasis> and <emphasis>&gt;</emphasis>, or <emphasis>%</emphasis>, nothing
and <emphasis>?</emphasis>) are typical.  Depending on your shell, you may get other prompts.
</para>
</sect2>
<sect2>
<title>Installing the server</title>

<para>Choose a server archive corresponding to your VGA board.  If table
on page
doesn't give you enough information, check the server man pages,
<emphasis>/usr/X11R6/man/man1/XF86_*</emphasis>, which list the VGA chip sets supported by each
server.  For example, if you have an ET4000 based board you will use the
XF86_SVGA server.  In this case you would enter:
</para>
<programlisting>
# <command>cd /usr/X11R6</command>
# <command>tar xzf /cdrom/XF86333/Server/X333SVGA.tgz</emphasis>	<emphasis>substitute your server name here</command>
</programlisting>

<para>If you are using csh, enter:
</para>
<programlisting>
% <command>cd /usr/X11R6</command>
% <command>tar xzf /cdrom/XF86333/Server/X333SVGA.tgz</emphasis>	<emphasis>substitute your server name here</command>
</programlisting>

<para></para>
</sect2>
<sect2>
<title>Setting up the environment</title>

<para><indexterm><primary>X</primary></indexterm>
<indexterm><primary>XF86_SVGA</primary></indexterm>
Next, you may wish to create a symbolic link <emphasis>/usr/X11/bin/X</emphasis> that points
to the server that matches your video board.  In this example, it's the
<emphasis>XF86_SVGA</emphasis> server:
</para>
<programlisting>
# <command>cd /usr/X11R6/bin</emphasis>						<emphasis>change to bin directory</command>
# <command>rm X</emphasis>								<emphasis>remove the current server</command>
# <command>ln -s XF86_SVGA X</emphasis>						<emphasis>and create a link to the new server</command>
</programlisting>

<para>X needs this symbolic link in order to be able to work correctly, but you have
the option of setting it when you run <emphasis>xf86config</emphasis>&mdash;see below.
<indexterm><primary>profile</primary></indexterm>
<indexterm><primary>csh.login</primary></indexterm>
</para>

<para>Next, check that the directory <emphasis>/usr/X11R6/bin</emphasis> is in the default path for
<emphasis>sh</emphasis> in <emphasis>/etc/profile</emphasis> and for <emphasis>csh</emphasis> in <emphasis>/etc/csh.login</emphasis>,
and add it if it is not.  It's best to do this with an editor, but if you want
to take a short cut, you can enter:
</para>
<programlisting>
# <command>echo 'set path = ($path /usr/X11R6/bin)' &gt;&gt;/etc/csh.login</command>
# <command>echo 'PATH=$PATH:/usr/X11R6/bin' &gt;&gt;/etc/profile</command>
</programlisting>

<para>Alternatively, make sure everybody who uses X puts <emphasis>/usr/X11R6/bin</emphasis> in their
shell's <emphasis>PATH</emphasis> variable.
</para>

<para><indexterm><primary>ldconfig</primary></indexterm>
<indexterm><primary>ld.so</primary></indexterm>
Next, invoke <emphasis>ldconfig</emphasis> to put the shared libraries in <emphasis>ld.so</emphasis>'s
cache:
</para>
<programlisting>
# <command>ldconfig -m /usr/X11R6/lib</command>
</programlisting>

<para>You can omit invoking <emphasis>ldconfig</emphasis> if you plan to reboot before using X.
</para>

<para><indexterm><primary>X333f100.tgz</primary></indexterm>
</para>
<note>

<para><indexterm><primary>mkfontdir</primary></indexterm>
You don't need to uncompress the font files, but if you do, you must run
<emphasis>mkfontdir</emphasis> in the corresponding font directory; otherwise your server will
abort with the message ``could not open default font `fixed'\^''.
</para>
</note>

<para></para>
</sect2>
<sect2>
<title>Assigning a virtual terminal to X</title>

<para><anchor id="CFBSD-getty-setup"/>
<indexterm><primary>getty</primary><secondary>command</secondary></indexterm>
Next, make sure you have a spare virtual console which is running a <emphasis>getty</emphasis>.
First check how many virtual consoles you have:
</para>
<programlisting>
# <command>dmesg | grep virtual</command>
sc0: VGA color &lt;16 virtual consoles, flags=0x0&gt;
</programlisting>

<para><indexterm><primary>/etc/ttys</primary></indexterm>
Then check <emphasis>/etc/ttys</emphasis> to make sure there is at least one virtual terminal
(<emphasis>ttyv<emphasis>xx</emphasis></emphasis> device) which doesn't have a <emphasis>getty</emphasis> enabled.  Look for
the keyword <emphasis>off</emphasis>:
</para>
<programlisting>
# <command>grep ttyv /etc/ttys</command>
ttyv0  "/usr/libexec/getty Pc" cons25  on secure
ttyv1  "/usr/libexec/getty Pc" cons25  on secure
ttyv2  "/usr/libexec/getty Pc" cons25  on secure
ttyv3  "/usr/libexec/getty Pc" cons25  <command>off</command> secure
</programlisting>

<para>In this case, <emphasis>/dev/ttyv3</emphasis> is available, if your kernel has least 4 VTs.
If not, either disable a getty in <emphasis>/etc/ttys</emphasis> by changing <emphasis>on</emphasis> to
<emphasis>off</emphasis>, or build another kernel with more virtual terminals&mdash;see
<xref linkend="CFBSD-chbuild"/>, page
for details of how to set the kernel parameter <emphasis>MAXCONS</emphasis>.
</para>
</sect2>
<sect2>
<title>Configuring X for Your Hardware</title>

<para><indexterm><primary>XF86Config</primary></indexterm>
<anchor id="CFBSD-configuring-X"/>
<anchor id="CFBSD-xf86config"/>
After installing the X software, you will need to customize the file
<emphasis>/usr/X11R6/lib/X11/XF86Config</emphasis>, which tells the X server about your
hardware and how you want to run it.
</para>
<note>

<para><indexterm><primary>XF86Config</primary></indexterm>
<indexterm><primary>reconfig</primary><secondary>command</secondary></indexterm>
<indexterm><primary>XConfig</primary></indexterm>
The format of <emphasis>XF86Config</emphasis> has changed since version 2 of XFree86.  If you
are upgrading from version 2, use the <emphasis>reconfig</emphasis> utility to perform a
partial translation of the old <emphasis>XConfig</emphasis> file to the new format.  You'll
still need to make some changes manually.
</para>
<programlisting>
# <command>reconfig &lt; Xconfig &gt; XF86Config</command>
</programlisting>

<para><indexterm><primary>XF86Config</primary></indexterm>
<indexterm><primary>XF86Config.eg</primary></indexterm>
The man page <emphasis>XF86Config(5)</emphasis> and the file
<emphasis>/usr/X11R6/lib/X11/XF86Config.eg</emphasis> will help you complete the changes.
</para>
</note>

<para><indexterm><primary>XF86Config</primary></indexterm>
In order to set up <emphasis>XF86Config</emphasis>, you'll need the following hardware
information:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>/dev/ttyd0</primary></indexterm>
<indexterm><primary>/dev/ttyd1</primary></indexterm>
<indexterm><primary>/dev/mse0</primary></indexterm>
<indexterm><primary>/dev/psm0</primary></indexterm>
Your mouse type, the bit rate if it's a serial mouse, and the name of the device
to which it is connected.  This will typically be <emphasis>/dev/ttyd0</emphasis> or
<emphasis>/dev/ttyd1</emphasis> for a serial mouse, <emphasis>/dev/psm0</emphasis> for a PS/2 mouse, or
<emphasis>/dev/mse0</emphasis> for a bus mouse.
</para>
</listitem>
<listitem>

<para>The type of the video board and the amount of display memory.  If it's a no-name
board, establish what VGA chip set it uses.
</para>
</listitem>
<listitem>

<para>The parameters of your monitor: vertical and horizontal frequency.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
<sect2>
<title>Identifying the hardware</title>

<para>How do you decide what your hardware is?  The manufacturer <emphasis>should</emphasis> tell
you, but very often the information you get about your display board and monitor
is pitiful: ``Super VGA board with 76 Hz refresh rate and 16,777,216 colors''.
This tells you the maximum pixel depth (24 bits: the number of colours is
2\u\s-3(pixel depth)\s0\d), but it doesn't tell you <emphasis>anything</emphasis> else about
the display board.  As we'll see in <xref linkend="CFBSD-chxtheory"/>, the real parameters you need
to know are the maximum horizontal frequency, the dot clock range, the chip set
and the amount of display memory.
</para>

<para>You could be unlucky trying to get some of this information, but you can get
some with the <emphasis>SuperProbe</emphasis> program.  It should always be able to tell you
the chip set and the amount of memory on board.
</para>
<note>

<para>Occasionally SuperProbe can crash your system.  Make sure you are not doing
anything important when you run it.
</para>
</note>

<para>Running <emphasis>SuperProbe</emphasis> looks like this:
</para>
<programlisting>
# <command>SuperProbe</command>
<emphasis>(warnings and acknowledgements omitted)</emphasis>
First video: Super-VGA
        Chipset: Tseng ET4000 (Port Probed)
        Memory:  1024 Kbytes
        RAMDAC:  Generic 8-bit pseudo-color DAC
                 (with 6-bit wide lookup tables (or in 6-bit mode))
</programlisting>

<para><emphasis>SuperProbe</emphasis> is very finicky about running at all, and you'll often get
messages like:
</para>
<programlisting>
SuperProbe: Cannot be run while an X server is running
SuperProbe: If an X server is not running, unset $DISPLAY and try again
SuperProbe: Cannot open video
</programlisting>

<para>In other words, even if no X server is running, <emphasis>SuperProbe</emphasis> won't work if
you have the environment variable <emphasis>DISPLAY</emphasis> set.  How do you unset it?
With Bourne-style shells, you enter:
</para>
<programlisting>
# <command>unset DISPLAY</command>
</programlisting>

<para>In the C shell, you enter:
</para>
<programlisting>
% <command>unsetenv DISPLAY</command>
</programlisting>

<para></para>
</sect2>
<sect2>
<title>Running xf86config</title>

<para><indexterm><primary>xf86config</primary><secondary>command</secondary></indexterm>
The easy way to create your configuration file is with one of the utilities
<emphasis>xf86config</emphasis> (note the lower case name) or <emphasis>XF86Setup</emphasis>.  Both leads
you through the configuration step by step.  <emphasis>xf86config</emphasis> runs in
character mode, while <emphasis>XF86Setup</emphasis> runs in a graphical mode.
<emphasis>XF86Setup</emphasis> can have problems with unusual hardware, so I personally
prefer <emphasis>xf86config</emphasis>.
</para>

<para>You can also use <emphasis>sysinstall</emphasis>, but this doesn't change much:
<emphasis>sysinstall</emphasis> just starts <emphasis>xf86config</emphasis> for you, and it's easier to
start it directly.  In this section, we'll use an example to illustrate
<emphasis>xf86config</emphasis> configuration: we're installing X for an ancient Diamond
SpeedStar with 1 MB of display memory, a Logitech MouseMan mouse, and an ADI
MicroScan 5AP monitor.  The mouse is connected to the system via the first
serial port, <emphasis>/dev/ttyd0</emphasis>.
</para>

<para>To run <emphasis>xf86config</emphasis>, type in the name.  If <emphasis>/usr/X11R6/bin</emphasis> is
included in your <emphasis>PATH</emphasis> environment variable (see page <xref linkend="CFBSD-PATH"/>), you just
need to type <emphasis>xf86config</emphasis>:
</para>
<programlisting>
# <command>/usr/X11R6/bin/xf86config</command>
This program will create a basic XF86Config file, based on menu selections you
make.

The XF86Config file usually resides in /usr/X11R6/lib/X11 or /etc. A sample
XF86Config file is supplied with XFree86; it is configured for a standard
VGA card and monitor with 640x480 resolution. This program will ask for a
pathname when it is ready to write the file.

You can either take the sample XF86Config as a base and edit it for your
configuration, or let this program produce a base XF86Config file for your
configuration and fine-tune it. Refer to /usr/X11R6/lib/X11/doc/README.Config
for a detailed overview of the configuration process.

For accelerated servers (including accelerated drivers in the SVGA server),
there are many chipset and card-specific options and settings. This program
does not know about these. On some configurations some of these settings must
be specified. Refer to the server man pages and chipset-specific READMEs.

Before continuing with this program, make sure you know the chipset and
amount of video memory on your video card. SuperProbe can help with this.
It is also helpful if you know what server you want to run.

Press enter to continue, or ctrl-c to abort. <keycap>ENTER</keycap>

First specify a mouse protocol type. Choose one from the following list:

 1.  Microsoft compatible (2-button protocol)
 2.  Mouse Systems (3-button protocol)
 3.  Bus Mouse
 4.  PS/2 Mouse
 5.  Logitech Mouse (serial, old type, Logitech protocol)
 6.  Logitech MouseMan (Microsoft compatible)
 7.  MM Series
 8.  MM HitTablet
 9.  Microsoft IntelliMouse

If you have a two-button mouse, it is most likely of type 1, and if you have
a three-button mouse, it can probably support both protocol 1 and 2. There are
two main varieties of the latter type: mice with a switch to select the
protocol, and mice that default to 1 and require a button to be held at
boot-time to select protocol 2. Some mice can be convinced to do 2 by sending
a special sequence to the serial port (see the ClearDTR/ClearRTS options).

Enter a protocol number: </emphasis><command>6</command>			<emphasis>Logitech MouseMan

You have selected a Logitech MouseMan type mouse. You might want to enable
ChordMiddle which could cause the third button to work.

Please answer the following question with either 'y' or 'n'.
Do you want to enable ChordMiddle? <command>n</command>
</programlisting>

<para>You definitely want to enable the third button on your mouse, since many X
clients use it.  With a genuine Logitech mouse, however, you don't need to
enable <emphasis>ChordMiddle</emphasis> in order to use the button.  If you find that the
third button doesn't work when you start X, you can enable <emphasis>ChordMiddle</emphasis>
by editing the configuration file&mdash;it's much easier and less error-prone than
re-running <emphasis>XF86Setup</emphasis>.  See page <xref linkend="CFBSD-XF86Config-Pointer-section"/> for details
of how to edit the configuration file.
</para>

<para>Continuing,
</para>
<programlisting>

If your mouse has only two buttons, it is recommended that you enable
Emulate3Buttons.

Please answer the following question with either 'y' or 'n'.
Do you want to enable Emulate3Buttons? <command>n</command>

Now give the full device name that the mouse is connected to, for example
/dev/tty00. Just pressing enter will use the default, /dev/mouse.

Mouse device: <command>/dev/ttyd1</command>
</programlisting>

<para>Be very careful about this entry: you must specify the correct name for the
device to which the mouse is connected.  <emphasis>xf86config</emphasis> is not specific to
FreeBSD, and the suggested example is just plain wrong for FreeBSD.  Use the
names <emphasis>/dev/ttyd0</emphasis> through <emphasis>/dev/ttyd3</emphasis> for serial mice,
<emphasis>/dev/psm0</emphasis> for PS/2 mice or <emphasis>/dev/mse0</emphasis> for a bus mouse.  See page
<xref linkend="CFBSD-XF86Config-Pointer-section"/> for more details.
</para>

<para>Continuing, we see:
</para>
<programlisting>
Beginning with XFree86 3.1.2D, you can use the new X11R6.1 XKEYBOARD
extension to manage the keyboard layout. If you answer 'n' to the following
question, the server will use the old method, and you have to adjust
your keyboard layout with xmodmap.

Please answer the following question with either 'y' or 'n'.
Do you want to use XKB? <command>y</command>

The following dialogue will allow you to select from a list of already
preconfigured keymaps. If you don't find a suitable keymap in the list,
the program will try to combine a keymap from additional information you
are asked then. Such a keymap is by default untested and may require
manual tuning. Please report success or required changes for such a
keymap to XFREE86@XFREE86.ORG for addition to the list of preconfigured
keymaps in the future.

Press enter to continue, or ctrl-c to abort.

List of preconfigured keymaps:

  1  Standard 101-key, US encoding
  2  Microsoft Natural, US encoding
  3  KeyTronic FlexPro, US encoding
  4  Standard 101-key, US encoding with ISO9995-3 extensions
  5  Standard 101-key, German encoding
  6  Standard 101-key, French encoding
  7  Standard 101-key, Thai encoding
  8  Standard 101-key, Swiss/German encoding
  9  Standard 101-key, Swiss/French encoding
 10  None of the above

Enter a number to choose the keymap.

</emphasis><command>1</command>								<emphasis>Choose the standard US keyboard

Now we want to set the specifications of the monitor. The two critical
parameters are the vertical refresh rate, which is the rate at which the
the whole screen is refreshed, and most importantly the horizontal sync rate,
which is the rate at which scanlines are displayed.

The valid range for horizontal sync and vertical sync should be documented
in the manual of your monitor. If in doubt, check the monitor database
/usr/X11R6/lib/X11/doc/Monitors to see if your monitor is there.

Press enter to continue, or ctrl-c to abort. <keycap>ENTER</keycap>
You must indicate the horizontal sync range of your monitor. You can either
select one of the predefined ranges below that correspond to industry-
standard monitor types, or give a specific range.

It is VERY IMPORTANT that you do not specify a monitor type with a horizontal
sync range that is beyond the capabilities of your monitor. If in doubt,
choose a conservative setting.

    hsync in kHz; monitor type with characteristic modes
 1  31.5; Standard VGA, 640x480 @@ 60 Hz
 2  31.5 - 35.1; Super VGA, 800x600 @@ 56 Hz
 3  31.5, 35.5; 8514 Compatible, 1024x768 @@ 87 Hz interlaced (no 800x600)
 4  31.5, 35.15, 35.5; Super VGA, 1024x768 @@ 87 Hz interlaced, 800x600 @@ 56 Hz
 5  31.5 - 37.9; Extended Super VGA, 800x600 @@ 60 Hz, 640x480 @@ 72 Hz
 6  31.5 - 48.5; Non-Interlaced SVGA, 1024x768 @@ 60 Hz, 800x600 @@ 72 Hz
 7  31.5 - 57.0; High Frequency SVGA, 1024x768 @@ 70 Hz
 8  31.5 - 64.3; Monitor that can do 1280x1024 @@ 60 Hz
 9  31.5 - 79.0; Monitor that can do 1280x1024 @@ 74 Hz
10  31.5 - 82.0; Monitor that can do 1280x1024 @@ 76 Hz
11  Enter your own horizontal sync range

Enter your choice (1-11):
</programlisting>

<para>See <xref linkend="CFBSD-chxtheory"/>, page
for an explanation of the warnings.
</para>

<para>Unfortunately, our monitor isn't mentioned in the file
<emphasis>/usr/X11R6/lib/X11/doc/Monitors</emphasis>, but by chance the manual does specify the
frequency range in the Technical Data section: the horizontal frequency range is
from 30 to 64 kHz, and the vertical frequency range is from 50 to 100 Hz.  The
horizontal frequency range is almost exactly covered by choice 8, but that
setting threatens to go 0.3 kHz higher in frequency than the technical data
state.  Do you want to risk it?  Probably there won't be a problem, since it's
unlikely that the monitor will die at such a small deviation from the specs, and
it's also unlikely that your <emphasis>XF86Config</emphasis> will actually generate a
horizontal frequency between 64.0 and 64.3 kHz.  However, there's no need to
take even this slight risk.  Just specify the real values:
</para>
<programlisting>
Enter your choice (1-11): <command>11</command>

Please enter the horizontal sync range of your monitor, in the format used
in the table of monitor types above. You can either specify one or more
continuous ranges (e.g. 15-25, 30-50), or one or more fixed sync frequencies.

Horizontal sync range: <command>30-64</command>
</programlisting>

<para>Next, we select the vertical frequency range:
</para>
<programlisting>
You must indicate the vertical sync range of your monitor. You can either
select one of the predefined ranges below that correspond to industry-
standard monitor types, or give a specific range. For interlaced modes,
the number that counts is the high one (e.g. 87 Hz rather than 43 Hz).

 1  50-70
 2  50-90
 3  50-100
 4  40-150
 5  Enter your own vertical sync range

Enter your choice: </emphasis><command>3</command>					<emphasis>this time, exactly the range of the monitor
</programlisting>

<para>The next step is to specify identification strings.  You can think out names if
you want, but unless you're juggling a lot of different hardware, you can let
<emphasis>xf86config</emphasis> do it for you:
</para>
<programlisting>
You must now enter a few identification/description strings, namely an
identifier, a vendor name, and a model name. Just pressing enter will fill
in default names.

The strings are free-form, spaces are allowed.
Enter an identifier for your monitor definition: <keycap>ENTER</keycap>
Enter the vendor name of your monitor:  <keycap>ENTER</keycap>
Enter the model name of your monitor:  <keycap>ENTER</keycap>
</programlisting>

<para>Next comes the choice of the video board.  We have an elderly Diamond SpeedStar
Plus with an ET4000 chip, and unknown Ramdac and Clock Chip.  Let's see how we
fare:
</para>
<programlisting>
Now we must configure video card specific settings. At this point you can
choose to make a selection out of a database of video card definitions.
Because there can be variation in Ramdacs and clock generators even
between cards of the same model, it is not sensible to blindly copy
the settings (e.g. a Device section). For this reason, after you make a
selection, you will still be asked about the components of the card, with
the settings from the chosen database entry presented as a strong hint.

The database entries include information about the chipset, what server to
run, the Ramdac and ClockChip, and comments that will be included in the
Device section. However, a lot of definitions only hint about what server
to run (based on the chipset the card uses) and are untested.

If you can't find your card in the database, there's nothing to worry about.
You should only choose a database entry that is exactly the same model as
your card; choosing one that looks similar is just a bad idea (e.g. a
GemStone Snail 64 may be as different from a GemStone Snail 64+ in terms of
hardware as can be).

Do you want to look at the card database? <command>y</command>
  0  2 the Max MAXColor S3 Trio64V+                    S3 Trio64V+
  1  928Movie                                          S3 928
  2  AGX (generic)                                     AGX-014/15/16
  3  ALG-5434(E)                                       CL-GD5434
  4  ASUS 3Dexplorer                                   RIVA128
  5  ASUS PCI-AV264CT                                  ATI-Mach64
  6  ASUS PCI-V264CT                                   ATI-Mach64
  7  ASUS Video Magic PCI V864                         S3 864
  8  ASUS Video Magic PCI VT64                         S3 Trio64
  9  AT25                                              Alliance AT3D
 10  AT3D                                              Alliance AT3D
 11  ATI 3D Pro Turbo                                  ATI-Mach64
 12  ATI 3D Xpression                                  ATI-Mach64
 13  ATI 3D Xpression+ PC2TV                           ATI-Mach64
 14  ATI 8514 Ultra (no VGA)                           ATI-Mach8
 15  ATI All-in-Wonder                                 ATI-Mach64
 16  ATI Graphics Pro Turbo                            ATI-Mach64
 17  ATI Graphics Pro Turbo 1600                       ATI-Mach64

Enter a number to choose the corresponding card definition.
Press enter for the next page, q to continue configuration.
<keycap>ENTER</keycap>
</programlisting>

<para>Dozens of board definitions come in alphabetic order.  Finally we see:
</para>
<programlisting>
108  DSV3325                                           S3 ViRGE
109  DSV3326                                           S3 Trio64V+
110  DataExpert DSV3325                                S3 ViRGE
111  DataExpert DSV3365                                S3 Trio64V+
112  Dell S3 805                                       S3 801/805
113  Dell onboard ET4000                               ET4000
114  Diamond Edge 3D                                   nv1
115  Diamond Multimedia Stealth 3D 2000                S3 ViRGE
116  Diamond Multimedia Stealth 3D 2000 PRO            S3 ViRGE/DX
117  Diamond SpeedStar (Plus)                          ET4000
118  Diamond SpeedStar 24                              ET4000
119  Diamond SpeedStar 24X (not fully supported)       WD90C31
120  Diamond SpeedStar 64                              CL-GD5434
121  Diamond SpeedStar HiColor                         ET4000
122  Diamond SpeedStar Pro (not SE)                    CL-GD5426/28
123  Diamond SpeedStar Pro 1100                        CL-GD5420/2/4/6/8/9
124  Diamond SpeedStar Pro SE (CL-GD5430/5434)         CL-GD5430/5434
125  Diamond SpeedStar64 Graphics 2000/2200            CL-GD5434

Enter a number to choose the corresponding card definition.
Press enter for the next page, q to continue configuration.

<command>117</command>

Your selected card definition:

Identifier: Diamond SpeedStar (Plus)
Chipset:    ET4000
Server:     XF86_SVGA

Press enter to continue, or ctrl-c to abort.<keycap>ENTER</keycap>

Now you must determine which server to run. Refer to the manpages and other
documentation. The following servers are available (they may not all be
installed on your system):

 1  The XF86_Mono server. This a monochrome server that should work on any
    VGA-compatible card, in 640x480 (more on some SVGA chipsets).
 2  The XF86_VGA16 server. This is a 16-color VGA server that should work on
    any VGA-compatible card.
 3  The XF86_SVGA server. This is a 256 color SVGA server that supports
    a number of SVGA chipsets. On some chipsets it is accelerated or
    supports higher color depths.
 4  The accelerated servers. These include XF86_S3, XF86_Mach32, XF86_Mach8,
    XF86_8514, XF86_P9000, XF86_AGX, XF86_W32, XF86_Mach64, XF86_I128 and
    XF86_S3V.

These four server types correspond to the four different "Screen" sections in
XF86Config (vga2, vga16, svga, accel).

 5  Choose the server from the card definition, XF86_SVGA.

Which one of these screen types do you intend to run by default (1-5)?
</programlisting>

<para>The system already chose <emphasis>XF86_SVGA</emphasis> for us.  Do we want to change?  We
would need a good reason.  In this case, we don't have a reason, so we'll keep
the server from the card definition:
</para>
<programlisting>
Which one of these screen types do you intend to run by default (1-5)? <command>5</command>

The server to run is selected by changing the symbolic link 'X'. For example,
'rm /usr/X11R6/bin/X; ln -s /usr/X11R6/bin/XF86_SVGA /usr/X11R6/bin/X' selects
the SVGA server.

Please answer the following question with either 'y' or 'n'.
Do you want me to set the symbolic link? <command>y</command>
</programlisting>

<para>All the programs that start X (<emphasis>xinit</emphasis>, <emphasis>startx</emphasis> and <emphasis>xdm</emphasis>) start
a program <emphasis>/usr/X11R6/bin/X</emphasis>.  This symbolic link makes
<emphasis>/usr/X11R6/bin/X</emphasis> point to your X server.  If you don't have a link, you
won't be able to start X.
</para>
<programlisting>
Now you must give information about your video card. This will be used for
the "Device" section of your video card in XF86Config.

You must indicate how much video memory you have. It is probably a good
idea to use the same approximate amount as that detected by the server you
intend to use. If you encounter problems that are due to the used server
not supporting the amount memory you have (e.g. ATI Mach64 is limited to
1024K with the SVGA server), specify the maximum amount supported by the
server.

How much video memory do you have on your video card:

 1  256K
 2  512K
 3  1024K
 4  2048K
 5  4096K
 6  Other

Enter your choice: <command>3</command>

You must now enter a few identification/description strings, namely an
identifier, a vendor name, and a model name. Just pressing enter will fill
in default names (possibly from a card definition).

Your card definition is Diamond SpeedStar (Plus).

The strings are free-form, spaces are allowed.
Enter an identifier for your video card definition: <keycap>ENTER</keycap>
You can simply press enter here if you have a generic card, or want to
describe your card with one string.
Enter the vendor name of your video card:  <keycap>ENTER</keycap>
Enter the model (board) name of your video card:  <keycap>ENTER</keycap>

Especially for accelerated servers, Ramdac, Dacspeed and ClockChip settings
or special options may be required in the Device section.

The RAMDAC setting only applies to the S3, AGX, W32 servers, and some
drivers in the SVGA servers. Some RAMDAC's are auto-detected by the server.
The detection of a RAMDAC is forced by using a Ramdac "identifier" line in
the Device section. The identifiers are shown at the right of the following
table of RAMDAC types:

  1  AT&amp;T 20C490 (S3 and AGX servers, ARK driver)                att20c490
  2  AT&amp;T 20C498/21C498/22C498 (S3, autodetected)                att20c498
  3  AT&amp;T 20C409/20C499 (S3, autodetected)                       att20c409
  4  AT&amp;T 20C505 (S3)                                            att20c505
  5  BrookTree BT481 (AGX)                                       bt481
  6  BrookTree BT482 (AGX)                                       bt482
  7  BrookTree BT485/9485 (S3)                                   bt485
  8  Sierra SC15025 (S3, AGX)                                    sc15025
  9  S3 GenDAC (86C708) (autodetected)                           s3gendac
 10  S3 SDAC (86C716) (autodetected)                             s3_sdac
 11  STG-1700 (S3, autodetected)                                 stg1700
 12  STG-1703 (S3, autodetected)                                 stg1703


Enter a number to choose the corresponding RAMDAC.
Press enter for the next page, q to quit without selection of a RAMDAC.


</emphasis><command>q</command>							<emphasis>We don't need this

A Clockchip line in the Device section forces the detection of a
programmable clock device. With a clockchip enabled, any required
clock can be programmed without requiring probing of clocks or a
Clocks line. Most cards don't have a programmable clock chip.
Choose from the following list:

 1  Chrontel 8391                                               ch8391
 2  ICD2061A and compatibles (ICS9161A, DCS2824)                icd2061a
 3  ICS2595                                                     ics2595
 4  ICS5342 (similar to SDAC, but not completely compatible)    ics5342
 5  ICS5341                                                     ics5341
 6  S3 GenDAC (86C708) and ICS5300 (autodetected)               s3gendac
 7  S3 SDAC (86C716)                                            s3_sdac
 8  STG 1703 (autodetected)                                     stg1703
 9  Sierra SC11412                                              sc11412
10  TI 3025 (autodetected)                                      ti3025
11  TI 3026 (autodetected)                                      ti3026
12  IBM RGB 51x/52x (autodetected)                              ibm_rgb5xx

Just press enter if you don't want a Clockchip setting.
What Clockchip setting do you want (1-12)? <keycap>ENTER</keycap>

For most configurations, a Clocks line is useful since it prevents the slow
and nasty sounding clock probing at server start-up. Probed clocks are
displayed at server startup, along with other server and hardware
configuration info. You can save this information in a file by running
'X -probeonly 2&gt;output_file'. Be warned that clock probing is inherently
imprecise; some clocks may be slightly too high (varies per run).

At this point I can run X -probeonly, and try to extract the clock information
from the output. It is recommended that you do this yourself and add a clocks
line (note that the list of clocks may be split over multiple Clocks lines) to
your Device section afterwards. Be aware that a clocks line is not
appropriate for drivers that have a fixed set of clocks and don't probe by
default (e.g. Cirrus). Also, for the P9000 server you must simply specify
clocks line that matches the modes you want to use.  For the S3 server with
a programmable clock chip you need a 'ClockChip' line and no Clocks line.

You must be root to be able to run X -probeonly now.

Do you want me to run 'X -probeonly' now?
</programlisting>

<para>This last question is worth thinking about.  You should run <emphasis>X -probeonly</emphasis>
at some point, but it requires some extra work.  We'll take the recommendation
and try it later.
</para>
<programlisting>
Do you want me to run 'X -probeonly' now? <command>n</command>

For each depth, a list of modes (resolutions) is defined. The default
resolution that the server will start-up with will be the first listed
mode that can be supported by the monitor and card.
Currently it is set to:

<anchor id="CFBSD-screen-resolutions"/>
"640x480" "800x600" "1024x768" for 8bpp
"640x480" "800x600" for 16bpp
"640x480" for 24bpp
"640x400" for 32bpp

Note that 16, 24 and 32bpp are only supported on a few configurations.
Modes that cannot be supported due to monitor or clock constraints will
be automatically skipped by the server.

 1  Change the modes for 8pp (256 colors)
 2  Change the modes for 16bpp (32K/64K colors)
 3  Change the modes for 24bpp (24-bit color, packed pixel)
 4  Change the modes for 32bpp (24-bit color)
 5  The modes are OK, continue.

Enter your choice: </emphasis><command>5</command>	<emphasis>accept the defaults

You can have a virtual screen (desktop), which is screen area that is larger
than the physical screen and which is panned by moving the mouse to the edge
of the screen. If you don't want virtual desktop at a certain resolution,
you cannot have modes listed that are larger. Each color depth can have a
differently-sized virtual screen

Please answer the following question with either 'y' or 'n'.
Do you want a virtual screen that is larger than the physical screen? <command>n</command>
</programlisting>

<para>It's difficult to decide whether you want a virtual screen larger than the
physical screen.  I find it extremely disturbing, so I suggest you answer
<command>n</command>.  You might find it useful, especially if your highest resolution is
small.

Now the configuration is complete, and <emphasis>sysinstall</emphasis> just need to write the
configuration file:
</para>
<programlisting>
I am going to write the XF86Config file now. Make sure you don't accidently
overwrite a previously configured one.

Shall I write it to /etc/XF86Config? <command>y</command>

File has been written. Take a look at it before running 'startx'. Note that
the XF86Config file must be in one of the directories searched by the server
(e.g. /usr/X11R6/lib/X11) in order to be used. Within the server press
ctrl, alt and '+' simultaneously to cycle video resolutions. Pressing ctrl,
alt and backspace simultaneously immediately exits the server (use if
the monitor doesn't sync for a particular mode).

For further configuration, refer to /usr/X11R6/lib/X11/doc/README.Config.

</programlisting>

<para>Once you have completed this configuration, you are ready to start X.  We'll
look at how to do that in <xref linkend="CFBSD-chdesktop"/>.  If you run into trouble, or if you're
interested in the background, read <xref linkend="CFBSD-chxtheory"/>.
</para>
</sect2>
</sect1>
</chapter>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchports"><title>The Ports Collection</title>

<para><anchor id="CFBSD-ports-collection"/>
<indexterm><primary>porting</primary></indexterm>
The Internet is full of free software which is normally distributed in source
form.  That's the problem: the way from the source archive that you get free
from the Internet to the finished, installed, running program on your
machine&mdash;normally called <emphasis>porting</emphasis>&mdash;can be a long and frustrating one.
See my book <emphasis>Porting UNIX Software</emphasis> for more details of the porting
process.
</para>

<para>In order to get a software package up and running on your system, you need to go
through most of these steps:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>archive</primary></indexterm>
<indexterm><primary>tar</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>tar</secondary></indexterm>
<indexterm><primary>gzip</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>gzip</secondary></indexterm>
<indexterm><primary>ftp</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>ftp</secondary></indexterm>
Get the source files on your machine.  They are usually contained in an
<emphasis>archive</emphasis>, a file containing a number of other files.  Archives used for the
ports collection are generally <emphasis>gzipped tar</emphasis> files, packed with
<emphasis>tar</emphasis> and compressed with <emphasis>gzip</emphasis>, but other formats are also possible.
Whatever the format, you'll typically use <emphasis>ftp</emphasis> to get them to your
machine.
</para>
</listitem>
<listitem>

<para><indexterm><primary>source</primary><secondary>tree</secondary></indexterm>
Unpack the archive into a <emphasis>source tree</emphasis>, using <emphasis>gunzip</emphasis> and <emphasis>tar</emphasis>.
</para>
</listitem>
<listitem>

<para><emphasis>Configure</emphasis> the package.  Most packages include shell scripts to do this.
Configuration performs a threefold adaptation of the package:
</para>
</listitem>
</itemizedlist>
<orderedlist>
<listitem>

<para>It adapts it to the system hardware.
</para>
</listitem>
<listitem>

<para>It adapts it to the software environment you're running (in this case, FreeBSD).
</para>
</listitem>
<listitem>

<para>It adapts it to your personal preferences.
</para>
</listitem>
</orderedlist>
<itemizedlist>
<listitem>

<para><emphasis>Build</emphasis> the package.  For most packages, this involves compiling the
source files and creating executables.
</para>
</listitem>
<listitem>

<para><emphasis>Installing</emphasis> the package.  This involves mainly copying the executables,
configuration files and documentation created by a <emphasis>build</emphasis> to the correct
place in the directory hierarchy.
</para>
</listitem>
<listitem>

<para><emphasis>Configuring</emphasis> the installed software.  This is similar in concept to
package configuration, except that it occurs in the run-time environment.  The
package configuration may perform all the necessary configuration for you.
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>Ports</primary><secondary>Collection</secondary></indexterm>
These are a lot of steps, and you'll often find they're laid through a
minefield: one false move, and everything blows up.  To make porting and
installing software easier, the FreeBSD team created a framework called the
<emphasis>Ports Collection</emphasis>.  In addition, the CD-ROM edition of FreeBSD includes a
large number of pre-built packages which just need to be installed.
</para>

<para>In this chapter, we'll consider the following points as they relate to the
FreeBSD ports collection:
</para>
<itemizedlist>
<listitem>

<para>How to install a pre-compiled package.  We'll look at this in the next section.
</para>
</listitem>
<listitem>

<para>What the ports tree is, and how to compile and install (``build'') a package.
We'll look at this on page <xref linkend="CFBSD-build-port"/>.
</para>
</listitem>
<listitem>

<para>How to create and submit a new port, on page <xref linkend="CFBSD-new-port"/>
</para>
</listitem>
</itemizedlist>

<para></para>
<sect1>
<title>How to install a package</title>

<para><indexterm><primary>installing</primary><secondary>a package</secondary></indexterm>
<indexterm><primary>package</primary><secondary>installing</secondary></indexterm>
<anchor id="CFBSD-install-package"/>
<indexterm><primary>packages</primary><secondary>directory</secondary></indexterm>
In FreeBSD parlance, a package is simply a special archive which contains the
files (usually executable binary files) which are installed when you build and
install a port.  Compared to the full-blown port, packages are much faster to
install&mdash;most take less than a minute.  On the other hand, they don't give you
the choice of configuration that the complete port does.  The first and third
CD-ROMs of the distribution each contain a directory <emphasis>packages</emphasis> with a total
of nearly 1000 pre-compiled software packages, totalling about 1 GB after
compression.  Alternatively, you can find FreeBSD packages on many servers on
the Internet&mdash;check the online handbook for some places to look.
</para>

<para>To help maintain an overview, both ports and packages are divided into
categories.  They are stored in directories named after the category.  See the
file <emphasis>/usr/ports/INDEX</emphasis> for a list.  For example, <emphasis>emacs</emphasis> under
<emphasis>editors</emphasis> is in the file <emphasis>packages/editors/emacs-20.3.tgz</emphasis>.  To
install it, you simply enter:
</para>
<programlisting>
# <command>pkg_add /cdrom/packages/editors/emacs-20.3.tgz</command>
</programlisting>

<para>Alternatively, you can install packages from the <emphasis>/stand/sysinstall</emphasis> Final
Configuration Menu.  We saw this menu on page in figure <xref linkend="CFBSD-final-config-menu"/> on
page <xref linkend="CFBSD-final-config-menu-page"/>.  When you start <emphasis>sysinstall</emphasis> from the
command line, you get to this menu by selecting <emphasis>Index</emphasis>, and then
selecting <emphasis>Configure</emphasis>.
</para>
</sect1>
<sect1>
<title>Building a port</title>

<para><indexterm><primary>building</primary><secondary>a port</secondary></indexterm>
<indexterm><primary>port</primary><secondary>building</secondary></indexterm>
<anchor id="CFBSD-build-port"/>
<indexterm><primary>port</primary><secondary>FreeBSD definition</secondary></indexterm>
The FreeBSD project uses the term <emphasis>port</emphasis> to describe the additional files
needed to adapt a package to build under FreeBSD.  It does <emphasis>not</emphasis> include
the code itself, though many code archives are on the third and fourth CD-ROMs
in the directory <emphasis>/ports/distfiles</emphasis>.
</para>

<para><indexterm><primary>/usr/ports</primary><secondary>directory</secondary></indexterm>
Before you get started with the ports, you need to install the port information
on your system.  The location is fixed: they must be installed in
<emphasis>/usr/ports</emphasis>.
<indexterm><primary>ports</primary><secondary>tree</secondary></indexterm>
This directory tree is frequently called the <emphasis>Ports Tree</emphasis>.  There are a
number of ways to install them.
</para>
<sect2>
<title>Installing ports during system installation</title>

<para><indexterm><primary>ports</primary><secondary>installing</secondary></indexterm>
The simplest way to install the Ports Collection is when you install the system.
You can install it with the base system if you select the <emphasis>Custom</emphasis>
distribution and include the <emphasis>ports collection</emphasis>.
</para>
</sect2>
<sect2>
<title>Install ports from the first CD-ROM</title>

<para>The file <emphasis>ports/ports.tgz</emphasis> on the first CD-ROM is a <emphasis>tar</emphasis> archive
containing all the ports.  If you didn't install it during system installation,
use the following method to install the complete collection (about 40 MB).  Make
sure your CD-ROM is mounted (in this example on <emphasis>/cdrom</emphasis>), and enter:
</para>
<programlisting>
# <command>cd /usr</command>
# <command>tar xzvf /cdrom/ports/ports.tgz</command>
</programlisting>

<para>If you only want to extract a single package, say <emphasis>inn</emphasis>, which is in the
category <emphasis>news</emphasis>, enter:
</para>
<programlisting>
# <command>cd /usr</command>
# <command>tar xzvf /cdrom/ports/ports.tgz  ports/news/inn</command>
</programlisting>

<para></para>
</sect2>
<sect2>
<title>Installing ports from the ports CD-ROM</title>

<para>Alternatively, you can install the files from the ports CD-ROM.  This is not
much of an advantage for installation, but you may find it convenient to browse
through the source trees in the directory <emphasis>ports</emphasis> on the CD-ROM.  Let's
assume you have found a directory <emphasis>/ports/graphics/hpscan</emphasis> on the CD-ROM,
and it is your current working directory.  You can move the data across with the
following:
</para>
<programlisting>
# <command>cd /cdrom/ports/graphics</command>
# <command>mkdir -p /usr/ports/graphics</command>
# <command>tar cf - . | (cd /usr/ports/graphics; tar xvf -)</command>
</programlisting>

<para></para>
</sect2>
<sect2>
<title>Ports via FTP</title>

<para><indexterm><primary>ports</primary><secondary>via FTP</secondary></indexterm>
Of course, maybe you've just heard about this great new port of
<emphasis>xmbase-grok</emphasis>, and you want to get hold of it as soon as possible.  It's
brand new, so it's obviously not on your CD-ROM.
</para>

<para>All ports are kept in subdirectories of the URL
<emphasis>ftp://ftp.FreeBSD.org/pub/FreeBSD</emphasis>.  The directory
<emphasis>ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/ports</emphasis> contains ports for
FreeBSD-CURRENT (see <xref linkend="CFBSD-chcurrent"/>, page <xref linkend="CFBSD-release-tags"/>).  The other
directories are named after the release.  For example, for FreeBSD-3.2, you
would select <emphasis>ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/ports-3.2</emphasis>.  To get
this one, you might perform the following steps:
</para>
<programlisting>
# <command>ftp ftp.freebsd.org</command>
Connected to wcarchive.cdrom.com.
220 wcarchive.cdrom.com FTP server (Version DG-3.1.27 Wed Dec 2 01:29:08 PST 1998) ready.
331 Guest login ok, send your complete e-mail address as password.
\&amp;<emphasis>...lots of blurb omitted</emphasis>
ftp&gt; <command>cd /pub/FreeBSD/ports/ports-3.2/databases</command>
250 CWD command successful.
ftp&gt; <command>ls -ltr</command>
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 36
drwxrwxr-x  2 2035  ftp-Free  512 Apr  9  1996 pkg
drwxrwxr-x  5 2035  ftp-Free  512 Dec 12  1996 typhoon
drwxrwxr-x  4 2035  ftp-Free  512 Jan 28  1997 gdbm
drwxr-xr-x  4 2035  ftp-Free  512 Jun 13 15:13 db
drwxr-xr-x  4 2035  ftp-Free  512 Jun 24 15:15 p5-DBD-Pg
drwxrwxr-x  5 2035  ftp-Free  512 Jun 24 15:15 p5-Pg
drwxr-xr-x  5 2035  ftp-Free  512 Jun 24 15:15 p5-Mysql
drwxrwxr-x  4 2035  ftp-Free  512 Jun 27 01:48 p5-DBI
drwxr-xr-x  4 2035  ftp-Free  512 Jul  2 15:20 p5-DBD-mysql
drwxrwxr-x  6 2035  ftp-Free  512 Jul 14 15:20 msql
drwxrwxr-x  4 2035  ftp-Free  512 Jul 15 15:27 p5-Msql
drwxrwxr-x  6 2035  ftp-Free  512 Jul 17 15:24 postgresql
drwxr-xr-x  6 2035  ftp-Free  512 Jul 18 03:19 mysql
drwxrwxr-x  6 2035  ftp-Free  512 Aug 27 03:21 gnats
drwxr-xr-x  5 root  ftp-Free  512 Aug 30 15:18 xmbase-grok
-rw-rw-r--  1 2035  ftp-Free  442 Sep  2 15:30 Makefile
drwxr-xr-x  5 root  ftp-Free  512 Sep  2 15:31 xmysql
drwxr-xr-x  4 root  ftp-Free  512 Sep  2 15:31 xmysqladmin
226 Transfer complete.
ftp&gt; <command>get xmbase-grok.tar.gz</command>
local: xmbase-grok.tar.gz remote: xmbase-grok.tar.gz
200 PORT command successful.
150 Opening BINARY mode data connection for /usr/bin/tar.
226 Transfer complete.
2390 bytes received in 1.37 seconds (1.71 KB/s)
</programlisting>

<para>Since <emphasis>xmbase-grok</emphasis> is a directory, you tell <emphasis>ftp</emphasis> to automatically
<emphasis>tar</emphasis> and <emphasis>gzip</emphasis> the directory and return you a file
<emphasis>xmbase-grok.tar.gz</emphasis>.  Not all ftp servers support tarring and gzipping,
since gzipping in particular takes up a lot of CPU time.
</para>

<para>Next, you unpack it in your <emphasis>/usr/ports/databases</emphasis> directory:
</para>
<programlisting>
# <command>cd /usr/ports/databases/</command>
# <command>tar xzvf /home/Book/FreeBSD/xmbase-grok.tar.gz </command>
xmbase-grok/
xmbase-grok/files/
xmbase-grok/files/md5
xmbase-grok/pkg/
xmbase-grok/pkg/COMMENT
xmbase-grok/pkg/DESCR
xmbase-grok/pkg/PLIST
xmbase-grok/Makefile
xmbase-grok/patches/
xmbase-grok/patches/patch-aa
xmbase-grok/patches/patch-ab
xmbase-grok/patches/patch-ac
</programlisting>

<para></para>
</sect2>
<sect2>
<title>What's in that port?</title>

<para><anchor id="CFBSD-ports-contents"/>
One problem with the Ports Collection is the sheer number.  It can be difficult
just to find out what they're supposed to do.  If you build all the ports,
you'll be busy for weeks, and there's no way you could read all the
documentation in one lifetime.  Where can you get an overview?  Here are some
suggestions:
</para>
<itemizedlist>
<listitem>

<para>You can print the index with the following commands:
</para>
<programlisting>
# <command>cd /usr/ports</command>
# <command>make print-index | lpr</command>
</programlisting>

<para></para>
</listitem>
<listitem>

<para>You can search for a specific keyword with the <emphasis>search</emphasis> target.  For
example, to find ports related to <emphasis>Emacs</emphasis>, you might enter:
</para>
<programlisting>
# <command>cd /usr/ports</command>
# <command>make search key=Emacs</command>
</programlisting>

<para></para>
</listitem>
<listitem>

<para>You can build a series of <emphasis>html</emphasis> pages like this:
</para>
<programlisting>
# <command>cd /usr/ports</command>
# <command>make readmes</command>
</programlisting>

<para>You can then browse them at the URL <emphasis>file:/usr/ports/README.html</emphasis>.
</para>
</listitem>
<listitem>

<para>You can find a printable version in the files <emphasis>/cdrom<xref linkend="CFBSD-skelc"/>/docs</emphasis>:
<table frame='all'><title>Ports overview</title>
box,center,tab(#) ;
lI | lw65 .
File#Content
=
packages-by-category.ps#T{
Packages sorted by category, in PostScript
T}
packages-by-category.txt#T{
Packages sorted by category, in ASCII
T}
packages.ps#T{
Packages sorted alphabetically, in PostScript
T}
packages.txt#T{
Packages sorted alphabetically, in ASCII
T}
interested in the background, read <xref linkend="CFBSD-chxtheory"/>.

</tbody></tgroup></table>
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
<sect2>
<title>Ports via CVSup</title>

<para><indexterm><primary>ports</primary><secondary>via CVSup</secondary></indexterm>
If you're using <emphasis>CVSup</emphasis> to keep up to date with the source tree, you have
the option of including the ports tree <emphasis>/usr/ports</emphasis> in the trees you
maintain.  See page <xref linkend="CFBSD-CVSup"/> for more details.
</para>
</sect2>
<sect2>
<title>Getting the source archive</title>

<para>You'll see from the above example that there are not many files in the port.
Most of the files required to build the software are in the original source code
archive, but you don't have it yet!
</para>

<para>Well, that's not a problem.  Part of the function of the ports collection is to
go out on the Net and get them for you.  This is completely automatic: you just
type <emphasis>make</emphasis>, and the build process gets the source archive for you and
builds it.  Of course, you must be connected to the Internet for this to work.
</para>

<para>In any case, are you sure you don't have the sources?  Maybe you do.  As we saw,
most of them are on the third and fourth CD-ROM, in the directory
<emphasis>/\f(CIcdrom<emphasis>/ports/distfiles</emphasis>.  The ports collection Makefiles look for
them in this directory (another good reason to mount your CD-ROM on
<emphasis>/cdrom</emphasis>) and also in <emphasis>/usr/ports/distfiles</emphasis>.
</para>

<para>If you mount your CD-ROM elsewhere (maybe because you have more than one CD-ROM
drive, and so you have to mount the CD-ROM on, say, <emphasis>/cd4</emphasis>), the Makefiles
will not find the distribution files and will try to load the files from the
Internet.  One way to solve this problem is to create a symbolic link from
<emphasis>/cd4/ports/distfiles</emphasis> to <emphasis>/usr/ports/distfiles</emphasis>.  The trouble with
this approach is that you will then no longer be able to load new distribution
files into <emphasis>/usr/ports/distfiles</emphasis>, since it will be on CD-ROM.  Instead, do:
</para>
</emphasis><programlisting>
# <command>cd /cd4/ports/distfiles</command>
# <command>mkdir -p /usr/ports/distfiles</emphasis>			<emphasis>make sure you have a distfiles directory</command>
# <command>for i in *; do</command>
&gt; <command>  ln -s /cd4/ports/distfiles/$i /usr/ports/distfiles/$i</command>
&gt; <command>done</command>
</programlisting>

<para>If you're using <emphasis>csh</emphasis> or <emphasis>tcsh</emphasis>, enter:
</para>
<programlisting>
# <command>cd /cd4/ports/distfiles</command>
# <command>mkdir -p /usr/ports/distfiles</emphasis>			<emphasis>make sure you have a distfiles directory</command>
# <command>foreach i (*)</command>
? <command>  ln -s /cd4/ports/distfiles/$i /usr/ports/distfiles/$i</command>
? <command>end</command>
</programlisting>

<para>This creates a symbolic link to each of the distribution files, but if the file
for a specific port isn't there, the ports collection can fetch it and store it
in the directory.
</para>
</sect2>
<sect2>
<title>Building the port</title>

<para><indexterm><primary>building</primary><secondary>ports</secondary></indexterm>
<indexterm><primary>ports</primary><secondary>building</secondary></indexterm>
<anchor id="CFBSD-new-port"/>
Once you have the skeleton files for the port, the rest is simple.  Just enter:
</para>
<programlisting>
# <command>cd /usr/ports/databases/xmbase-grok</command>
# <command>make</command>
# <command>make install</command>
</programlisting>

<para>It's a good idea to perform the <emphasis>make</emphasis> step first: <emphasis>make install</emphasis>
does not always build the package.
</para>
</sect2>
<sect2>
<title>Port dependencies</title>

<para><indexterm><primary>ports</primary><secondary>dependencies</secondary></indexterm>
Sometimes, it's not enough to build a single port.  Many ports depend on other
ports.  If you have the complete, up-to-date ports tree installed on your
system, the Ports Collection will take care of this for you: it will check if
the other port is installed, and if it isn't, it will install it for you.  For
example, <emphasis>tkdesk</emphasis> depends on <emphasis>tk</emphasis>.  <emphasis>tk</emphasis> depends on <emphasis>tcl</emphasis>.
If you don't have any of them installed, and you try to build <emphasis>tkdesk</emphasis>, it
will recursively install <emphasis>tk</emphasis> and <emphasis>tcl</emphasis> for you.
</para>

<para>Things get a little more complicated if your tree isn't complete, or if you have
updated specific packages.  For example, the latest version of <emphasis>tkdesk</emphasis>
depends on <emphasis>tk</emphasis> version 4.1.  Older versions depended on version 3.6.  If
you update the directory <emphasis>/usr/ports/x11/tkdesk</emphasis>, but not
<emphasis>/usr/ports/x11/tk</emphasis>, the build will probably fail.
</para>

<para>There are two possible solutions to this problem:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>CVSup</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>CVSup</secondary></indexterm>
<indexterm><primary>ctm</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>ctm</secondary></indexterm>
Keep the tree up to date with <emphasis>CVSup</emphasis> or <emphasis>ctm</emphasis> (see <xref linkend="CFBSD-chcurrent"/>).
</para>
</listitem>
<listitem>

<para>Check the dependencies, and update them manually.
</para>
</listitem>
</itemizedlist>

<para>To check the dependencies, look at the <emphasis>Makefile</emphasis>.  For example, the current
version of <emphasis>/usr/ports/x11/tkdesk/Makefile</emphasis> contains:
</para>
<programlisting>
# New ports collection makefile for:	tkdesk
# Version required:     1.0b2
# Date created:         30 Jul 1996
# Whom:                 shanee@rabbit.augusta.de
#
# $I\&amp;d: Makefile,v 1.4 1997/04/20 13:19:59 wosch Exp $
#

DISTNAME=	tkdesk-1.0b3
PKGNAME=	tkdesk-1.0b3
CATEGORIES=	misc x11 tk41
MASTER_SITES=	http://sun1.rrzn-user.uni-hannover.de/~zzhibol/tkdesk/

MAINTAINER=	nox@jelal.hb.north.de

LIB_DEPENDS=	tk41\\.1\\.:${PORTSDIR}/x11/tk41		<emphasis>look at this line</emphasis>

post-patch:
	-rm ${WRKSRC}/tcldesk/*.orig ${WRKSRC}/tcldesk/*/*.orig

\&amp;.include &lt;bsd.port.mk&gt;
</programlisting>

<para>The definition <emphasis>LIB_DEPENDS</emphasis> tells you the dependencies.  In this case, it
will first look for the libraries <emphasis>/usr/lib/libtk41.so.1.0</emphasis> or
<emphasis>/usr/local/lib/libtk41.so.1.0</emphasis>.  If it finds them, it will be satisfied.
Otherwise it will build the port at <emphasis>/usr/ports/x11/tk41</emphasis>.  The <emphasis>make</emphasis>
variable <emphasis>PORTSDIR</emphasis> represents the name of the top-level ports directory,
currently <emphasis>/usr/ports</emphasis>.
</para>
</sect2>
</sect1>
<sect1>
<title>Getting common software</title>

<para><indexterm><primary>Getting</primary><secondary>common software</secondary></indexterm>
<indexterm><primary>netscape</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>netscape</secondary></indexterm>
A lot of software doesn't need to be ported.  For example, if you want
<emphasis>Netscape</emphasis>, you can just download it from <emphasis>ftp.netscape.com</emphasis>.  In fact,
you have a choice of three different versions of <emphasis>Netscape</emphasis>: you can take
the native FreeBSD version, the BSD/OS version or the Linux version.
</para>

<para>That's where the trouble starts.  Which one do you use?  How do you install it?
Netscape's installation procedures are getting better, but they still leave
something to be desired.
</para>

<para>The answer's simple: take the port!  Although Netscape comes only in binary
form, the port handles getting the correct version and installing it for you.
Another advantage to using a port instead of installing the package manually is
that the port installs the software as a FreeBSD package, which makes it much
easier to remove the software later.
</para>

<para><indexterm><primary>StarOffice</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>StarOffice</secondary></indexterm>
This method can be used to install some other software as well, for example
<emphasis>StarOffice</emphasis>.  The moral is simple: always check the ports collection before
getting a software package from the net.
</para>
</sect1>
<sect1>
<title>Maintaining ports</title>

<para><indexterm><primary>maintaining</primary><secondary>ports</secondary></indexterm>
<indexterm><primary>ports</primary><secondary>maintaining</secondary></indexterm>
Once you install a port, you might consider that to be the end of the story.
That's seldom the case.  For example:
</para>
<itemizedlist>
<listitem>

<para>One day, you might find your disk fills up, so you go looking for old stuff you
don't use any more.  How do you know whether it's part of a port or not?
</para>
</listitem>
<listitem>

<para>You might need to replace a port by a newer version.  How do you do it?
</para>
</listitem>
</itemizedlist>

<para></para>
<sect2>
<sect3>
<title>Controlling installed ports</title>

<para><indexterm><primary>controlling</primary><secondary>installed ports</secondary></indexterm>
<indexterm><primary>ports</primary><secondary>controlling</secondary></indexterm>
We've already seen the program <emphasis>pkg_add</emphasis> when installing pre-compiled
packages.  There are a number of other <emphasis>pkg_</emphasis> programs which can help you
maintain installed ports, whether they have been installed by <emphasis>pkg_add</emphasis> or
by <emphasis>make install</emphasis> from the Ports Collection:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>pkg_info</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>pkg_info</secondary></indexterm>
<emphasis>pkg_info</emphasis> will tell you which ports are installed.  For example,
</para>
<programlisting>
$ <emphasis> pkg_info -I -a | sort -f | less</emphasis>
a2ps-A4-4.9.7       Formats an ascii file for printing on a postscript printer.
aalib-1.2           An ascii art library
acroread-3.01       View, distribute and print PDF documents.
afm-1.0             Adobe Font Metrics.
apache-1.2.4        The extremely popular Apache http server.  Very fast, very c
apache-1.2b10       The extremely popular Apache http server.  Very fast, very c
<emphasis>\&amp;... etc</emphasis>
elm-2.4ME+22        ELM Mail User Agent
elm-2.4ME+32        ELM Mail User Agent
<emphasis>\&amp;... etc</emphasis>
</programlisting>

<para><indexterm><primary>pkg_list</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>pkg_list</secondary></indexterm>
The option <emphasis>-a</emphasis> tells <emphasis>pkg_list</emphasis> to list all packages; otherwise you
should specify a package name.  The option <emphasis>-I</emphasis> specifies that the list
should be a one-line ``Index'' description; otherwise you get a multi-line
description of the package.
</para>

<para>By default, <emphasis>pkg_info</emphasis> lists the packages in the order in which they were
installed, which is not normally of great interest.  By piping into the command
<emphasis>sort -f</emphasis>, we get it in alphabetical order.  The <emphasis>-f</emphasis> flags tells
<emphasis>sort</emphasis> to <emphasis>fold</emphasis> upper case into the same sort order as lower case;
otherwise all packages with names starting with a capital letter would come
first.  Finally, <emphasis>less</emphasis> allows us to page through what could be a very
long list.
</para>

<para>Note the advantage of sorting in this example: it seems we have two versions of
<emphasis>apache</emphasis> and two versions of <emphasis>elm</emphasis> installed, probably not what we
intended.  If it had been unsorted, it would be difficult to discover this fact.
</para>
</listitem>
<listitem>

<para><indexterm><primary>pkg_delete</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>pkg_delete</secondary></indexterm>
You can <emphasis>remove</emphasis> a package with <emphasis>pkg_delete</emphasis>.  You need to be
<emphasis>root</emphasis> to do this.  For example, the list above shows two versions of the
<emphasis>elm</emphasis> mail user agent.  To remove the older one, we enter:
</para>
<programlisting>
# <command>pkg_delete elm-2.4ME+22</command>
File `/usr/local/man/man1/answer.1' doesn't really exist.
Unable to completely remove file '/usr/local/man/man1/answer.1'
File `/usr/local/man/man1/checkalias.1' doesn't really exist.
Unable to completely remove file '/usr/local/man/man1/checkalias.1'
<emphasis>\&amp;... etc</emphasis>
Couldn't entirely delete package (perhaps the packing list is
incorrectly specified?)
</programlisting>

<para>In this case, it looks as if somebody has tried to remove the files before, so
<emphasis>pkg_delete</emphasis> couldn't do so.
</para>

<para>Another problem with <emphasis>pkg_delete</emphasis> is that it might delete files of the
same name which have been replaced by newer packages.  After performing this
operation, we try:
</para>
<programlisting>
$ <command>elm</command>
bash: elm: command not found
</programlisting>

<para>Oops!  We tried to delete the old version, but we deleted at least part of the
new version.  Now we need to install it again.
</para>

<para>The moral of this story is that things aren't as simple as they might be.  When
you install a new version of a package, you may want to test it before you
commit to using it all the time.  You can't just go and delete the old version.
One possibility would be to install the new package, and try it out.  When
you've finished testing, delete <emphasis>both</emphasis> packages and re-install the one you
want to keep.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect3>
<sect3>
<title>Keeping track of updates</title>

<para>The best way to find out about updates is to subscribe to the
<emphasis>FreeBSD-ports</emphasis> mailing list.  That way, you will get notification every
time something changes.  If you're tracking the ports tree, you'll also get the
updates to the ports tree automatically.  Otherwise you will have to download
the port.  In either case, to update your installed port, just repeat the build.
</para>
</sect3>
</sect2>
</sect1>
<sect1>
<title>Submitting a new port</title>

<para><indexterm><primary>submitting</primary><secondary>a port</secondary></indexterm>
<indexterm><primary>ports</primary><secondary>submitting</secondary></indexterm>
The ports collection is constantly growing.  Hardly a day goes by without a new
port being added to the list.  Maybe you want to submit the next one?
</para>

<para>It's beyond the scope of this book to give you all the details of how to go
about submitting a port.  Check in the online handbook for the details, which
might change from time to time.  Basically, however, the sequence is:
</para>
<itemizedlist>
<listitem>

<para>Read the instructions <emphasis>before</emphasis> starting the port.  There are many ways to
port a package&mdash;there could even be more than one correct way to port it.  If
you port it in the wrong way, the ports team will be unable to accept it, and
fixing the problem can easily be as difficult as doing the port was in the first
place.
</para>
</listitem>
<listitem>

<para>Write a top-level <emphasis>Makefile</emphasis> for the port, including information on the
master sites from which the package may be downloaded, the name and category of
the package, and the name of the maintainer (you).
</para>
</listitem>
<listitem>

<para>Perform the port.
</para>
</listitem>
<listitem>

<para>Submit it.
</para>
</listitem>
</itemizedlist>

<para><!--  XXXFrom: Doug White &lt;dwhite@gdi.uoregon.edu&gt; -->
<!--  XXXReply-To: Doug White &lt;dwhite@resnet.uoregon.edu&gt; -->
<!--  XXXTo: Greg Pavelcak &lt;gpavelcak@philos.umass.edu&gt; -->
<!--  XXXcc: questions@FreeBSD.ORG -->
<!--  XXXSubject: Re: Optimizing Compile of Ports -->
<!--  XXX -->
<!--  XXXOn Thu, 25 Sep 1997, Greg Pavelcak wrote: -->
<!--  XXX -->
<!--  XXX&gt; I've been installing ports lately instead of packages just for the -->
<!--  XXX&gt; heck of it. Compile optimizations seem to be out of my control with -->
<!--  XXX&gt; ports. Ilooked in /etc/make.conf /usr/share/mk/bsd.port.mk and the -->
<!--  XXX&gt; individual make files associated with ports and I don't see anything -->
<!--  XXX&gt; about compile options. Am I missing something, or is this just the -->
<!--  XXX&gt; way it is? (It's probably a good idea to keep me from messing with -->
<!--  XXX&gt; this stuff anyway.) -->
<!--  XXX -->
<!--  XXXThe ports do assume a standard set of compile-time options.  If you want -->
<!--  XXXto tweak them just before the build starts, you can run ``make -->
<!--  XXXconfigure'', which will fetch, extract, patch, and configure everything -->
<!--  XXXbut stop before the make is started.  See /usr/share/mk/bsd.port.mk line -->
<!--  XXX220-ish for the standard target list. -->
<!--  XXX -->
</para>
</sect1>
</chapter>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchproblems"><title>Installation Problems</title>

<para>In <xref linkend="CFBSD-chinstall"/>, and <xref linkend="CFBSD-chshareinstall"/>, we saw what <emphasis>should</emphasis> happen when
you install FreeBSD.  Unfortunately, things don't always run smoothly.  In this
chapter, we'll look at what could go wrong and what to do if it does.  In the
following section, we'll look at what to do if the installation doesn't work as
expected, and on page
we'll consider how to recover a crashed system.
</para>
<sect1>
<title>If things go wrong</title>

<para>In this section, we'll look at the most common installation problems.  Before
you start, though, a couple of general recommendations:
</para>
<itemizedlist>
<listitem>

<para>If you can't boot, and if this chapter doesn't help, the most important
indication is the point at which the boot failed.  It's worth repeating the boot
with the <emphasis>-v</emphasis> (verbose) flag: enter it at the <emphasis>Boot:</emphasis> prompt:
</para>
<programlisting>
Boot: <command>-v</command>
</programlisting>

<para>It will give you additional information which might help diagnose the problem.
</para>
</listitem>
<listitem>

<para>If you get the system installed to the point where you can start it, but it
doesn't run quite the way you want, <emphasis>don't</emphasis> reinstall.  In most cases,
reinstallation doesn't help.  Instead, try to find the cause of the
problem&mdash;with the aid of the <emphasis>FreeBSD-questions</emphasis> mailing list if
necessary&mdash;and fix the problem.
</para>
</listitem>
</itemizedlist>

<para>Most installation problems relate to hardware incompatibilities, either because
of inherent problems in the hardware, or because the hardware is not configured
in the way the system expects.  You have two choices here:
</para>
<itemizedlist>
<listitem>

<para>Modify the kernel's viewpoint to match the hardware.  See page
<xref linkend="CFBSD-UserConfig-details"/> for an example of how to do this.
</para>
</listitem>
<listitem>

<para>Modify the hardware to match the kernel's viewpoint.  Check your hardware
manuals to do this.
</para>
</listitem>
</itemizedlist>

<para>Beyond these problems, however, specific hardware or combinations of hardware
can cause problems.  Check out the file <emphasis>TROUBLE.TXT</emphasis> on the first CD-ROM
for details of specifics.  In the following sections we'll look at the more
common cases that it mentions.
</para>
<sect2>
<title>Problems with sysinstall</title>

<para><indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
<emphasis>sysinstall</emphasis> is intended to be easy to use, but it is not very tolerant of
errors.  You may well find that you enter something by mistake and can't get
back to where you want to be.  In case of doubt, if you haven't yet committed to
the install, you can always just reboot.
</para>

<para></para>
</sect2>
<sect2>
<title>Problems with CD-ROM installation</title>

<para>If you select to install from CD-ROM, you may get the message:
</para>
<programlisting>
No CD-ROM device found
</programlisting>

<para>This might even happen if you have booted from CD-ROM!  The most common reasons
for this problem are:
</para>
<itemizedlist>
<listitem>

<para>You forgot to put the CD-ROM in the drive before you booted.  Sorry, this is a
current limitation of the boot process.  Restart the installation (press
<keycap>CTRL-ALT-DEL</keycap> or the reset button, or power cycle the computer).
</para>
</listitem>
<listitem>

<para>You are using an ATAPI CD-ROM drive which doesn't quite fit the specification.
In this case you need help from the FreeBSD developers.  Send a message to
<emphasis>FreeBSD-questions@FreeBSD.org</emphasis> and describe your CD-ROM as accurately as
you can.
</para>
</listitem>
<listitem>

<para>You have an old proprietary CD-ROM drive which is not set up the way the generic
kernel expects it.  See page <xref linkend="CFBSD-supported-hardware"/> for details of which
hardware is supported.  If your CD-ROM is set up differently, you have the
choice of setting it to correspond with what the generic kernel expects, or
using the configuration manager included in the generic kernel to change the
parameters&mdash;see page
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
<sect2>
<title>Install tries to install from floppy</title>

<para><indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
Sometimes when an installation medium fails, <emphasis>sysinstall</emphasis> decides to try
to get the root file system from floppy.  For some reason, you can't cancel this
menu.  Instead, just let <emphasis>sysinstall</emphasis> look for the file system on the
floppy.  When it doesn't find it, it'll give up by itself.
</para>
</sect2>
</sect1>
<sect1>
<title>Can't boot</title>

<para>One of the most terrifying things after installing FreeBSD is if you find that
the machine just won't boot.  This is particularly bad if you have important
data on the disk (either another operating system, or data from a previous
installation of FreeBSD).
</para>

<para>At this point, seasoned hackers tend to shrug their shoulders and point out that
you still have the backup you made before you did do the installation.  If you
tell them you didn't do a backup, they tend to shrug again and move on to
something else.
</para>

<para>Still, all is probably not lost.  The two most frequent causes of boot failure
are:
</para>
<itemizedlist>
<listitem>

<para>You installed the wrong boot manager, or you wiped it out altogether.  This one
is harmless.  Boot from the floppy disk, but when the prompt appears, enter:
</para>
<programlisting>
Boot: <command>hd()kernel</command>
</programlisting>

<para>After booting, install the correct bootstrap with <emphasis>disklabel -B</emphasis>, and you
should be able to boot from hard disk again.
</para>
</listitem>
<listitem>

<para>Things might continue a bit further: you elect to install <emphasis>booteasy</emphasis>, and
when you boot you get the Boot Manager prompt, but it just prints <emphasis>F?</emphasis> at
the boot menu and won't accept any input.  In this case, you may have set the
hard disk geometry incorrectly in the Partition editor when you installed
FreeBSD.  Go back into the partition editor and specify the correct geometry for
your hard disk.  Unfortunately, you must reinstall FreeBSD from the beginning if
this happens.
</para>
</listitem>
</itemizedlist>

<para></para>
<sect2>
<title>Can't find correct geometry</title>

<para>If you can't figure out the correct geometry for your machine, and even if you
don't want to run Microsoft on your machine, try installing a small Microsoft
partition at the beginning of the disk and install FreeBSD after that.  The
install program will see the Microsoft partition and try to infer the correct
geometry from it, which usually works.  After the partition editor has accepted
the geometry, you can remove the Microsoft partition again.  If you are sharing
your machine with Microsoft, make sure that the Microsoft partition is before the
FreeBSD partition.  Remember that, in either case, you may need to locate the
FreeBSD root file system completely in the first 1024 cylinders, otherwise you
will not be able to boot.  See page <xref linkend="CFBSD-EIDE"/> for further details.
</para>

<para>Alternatively, if you don't want to share your disk with any other operating
system, select the option to use the entire disk (<emphasis>a</emphasis> in the partition
editor).  This will leave all geometry considerations aside.
</para>
</sect2>
<sect2>
<title>System hangs during boot</title>

<para>A number of problems may lead to the system hanging during the boot process.
Here are a couple:
</para>
<itemizedlist>
<listitem>

<para>After installation, you might find that the system hangs after the message:
</para>
<programlisting>
Changing root to /dev/da0a
</programlisting>

<para><indexterm><primary>Ethernet</primary><secondary>3Com 3C509</secondary></indexterm>
<indexterm><primary>3Com</primary><secondary>3C509</secondary></indexterm>
This may happen if your system has a 3com 3c509 Ethernet adapter.  The
<emphasis>ep</emphasis> device driver is sensitive to probes for other devices that also use
the same address (by default address <emphasis>0x300</emphasis>).  Reboot the system by power
cycling the machine (turning it off and on.  Always wait a few seconds between
powering off and powering on again).  This will probably unwedge the Ethernet
board.  At the <emphasis>Boot:</emphasis> prompt specify the <emphasis>-c</emphasis> option to invoke
<emphasis>UserConfig</emphasis> and use the <emphasis>disable</emphasis> command to disable the device
probes for all devices at address <emphasis>0x300</emphasis> except the <emphasis>ep0</emphasis> driver.
After this, your machine should boot successfully.
</para>
</listitem>
<listitem>

<para>Sometimes the system appears to hang after the message:
</para>
<programlisting>
fd0: 1.44MB 3.5in
fd1: 1.2MB 5.25in
</programlisting>

<para>In fact, this usually isn't a hang, just a very long probe for <emphasis>wdc0</emphasis>.
The probe often takes a long time to complete on certain systems which don't
have a WD controller.  If your system does have a WD controller, this problem
can also happen after the lines:
</para>
<programlisting>
wdc0 at 0x1f0-0x1f7 irq 14 on isa
wdc0: unit 0 (wd0): &lt;WDC AC2200F&gt;
wd0: 202MB (415380 sectors), 989 cyls, 12 heads, 35 S/T, 512 B/S
</programlisting>

<para>In this case, the driver is looking for a second WD disk controller.  Be
patient, your system will boot.  You can eliminate the problem by using
UserConfig to eliminate the device <emphasis>wdc1</emphasis>, or by building a custom kernel.
</para>
</listitem>
<listitem>

<para>When booting from floppy, the system might hang after the message:
</para>
<programlisting>
Uncompressing kernel...
</programlisting>

<para>This is normally an indication that you have a memory problem (not enough
memory, faulty cache, or incorrect chipset parameters).
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
<sect2>
<title>Panic: cannot mount root</title>

<para>If you install FreeBSD on any disk except the first, you might find that the
boot proceeds normally, but then dies with the message:
</para>
<programlisting>
changing root device to wd1s1a
panic: cannot mount root
</programlisting>

<para>This problem comes from the fact that the BIOS uses a different numbering scheme
from FreeBSD, and it's difficult to correlate the disk numbers.
</para>

<para>In the case where the boot disk is not the first disk in the system, FreeBSD may
need help finding it.  There are two common situations where you need to tell
FreeBSD where the root filesystem is:
</para>
<itemizedlist>
<listitem>

<para>You have two IDE disks, each configured as the master on their respective IDE
busses.  You have no disk on the primary slave position (you might have a CD-ROM
drive there).  FreeBSD is on the second disk.  The BIOS sees these as disk 0 and
disk 1, while FreeBSD sees them as <emphasis>wd0</emphasis> and <emphasis>wd2</emphasis>, in other words
disk 2.  To tell the loader how to find it, stop it before booting and enter:
</para>
<programlisting>
disk1s1a:&gt; boot 1:wd(2,a)kernel
</programlisting>

<para>If you have a disk on primary master and on slave, the BIOS numbers agree with
FreeBSD, so you don't need to do this.
</para>
</listitem>
<listitem>

<para>If you're booting from a SCSI disk when you have one or more IDE disks in the
system, the FreeBSD disk number is lower than the BIOS disk number.  If you have
two IDE disks as well as the SCSI disk, the SCSI disk is BIOS disk 2, but it's
FreeBSD disk number 0, so you would say:
</para>
<programlisting>
disk1s1a:&gt; boot 2:da(0,a)kernel
</programlisting>

<para>This tells FreeBSD that you want to boot from BIOS disk 2, which is the first
SCSI disk in the system.  If you only had one IDE disk, you would use <emphasis>1:</emphasis>
instead.
</para>
</listitem>
</itemizedlist>

<para>You don't need to do this every time: once you have determined the correct
values to use, put the command exactly as you would have typed it in the file
<emphasis>/boot.config</emphasis>.  FreeBSD uses the contents of this file as the default
response to the <emphasis>boot:</emphasis>prompt.
</para>
</sect2>
<sect2>
<title>Can't find Intel EtherExpress board</title>

<para>A couple of problems can prevent recognition of an EtherExpress board:
</para>
<itemizedlist>
<listitem>

<para>You don't have a choice of I/O parameters for the EtherExpress 16. You must set
it to be memory mapped at address <emphasis>0xD0000</emphasis>, and set the amount of mapped
memory to 32K using the Intel-supplied program <emphasis>softset.exe</emphasis>.
</para>
</listitem>
<listitem>

<para>The <emphasis>mcd</emphasis> driver can mistakenly recognize Intel EtherExpress boards as
<emphasis>mcd</emphasis> devices.  Check the <emphasis>dmesg</emphasis> output: if it claims to have an
<emphasis>mcd0</emphasis> device, disable the <emphasis>mcd</emphasis> driver in UserConfig.  See page
<xref linkend="CFBSD-UserConfig-details"/> for details of UserConfig.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
<sect2>
<title>Can't see 3Com PCMCIA board</title>

<para>There are a couple of possible problems in this area:
</para>
<itemizedlist>
<listitem>

<para>FreeBSD does not support multi-function boards such as the 3C562 ethernet/modem
board.
</para>
</listitem>
<listitem>

<para>The 3C589 driver must know the IRQ, I/O port address and IOMem address in order
to work.  This information is stored in NVRAM on the board.  Unfortunately, the
only program capable of reading them is the DOS program supplied by 3COM.  This
program is very finicky about its operating environment, so it's best to run it
on a absolutely basic MS-DOS system with no other drivers.  Ignore its
complaints about CARD-Services not being found: it will continue.  If it tells
you the board is defective, use other methods to confirm the claim: it sometimes
does this even if there's nothing wrong with the board.  Note the IRQ, port, and
IOMEM values (the latter is called the CIS tuple by 3COM).  The first two can be
set in the program, the third can only be read.  Set these values in your kernel
configuration.
</para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
<sect2>
<title>No packets are transmitted on PCMCIA network board</title>

<para>Many PCMCIA boards use either 10-Base2 (BNC) or 10-BaseT connectors for
connecting to the network.  The driver can't auto-select the correct connector,
so you must tell it which connector to use with a combination of the
<emphasis>ifconfig</emphasis> flags <emphasis>link0</emphasis>, <emphasis>link1</emphasis> and <emphasis>link2</emphasis>.
Typically, one of the following commands selects the correct connector:
</para>
<programlisting>
# <command>ifconfig zp0 -link0 link1</command>
# <command>ifconfig zp0 link0 -link1</command>
</programlisting>

<para>Check the man page for your board for the details: they vary from one board to
another.  You can set these flags in <emphasis>sysinstall</emphasis> by using the <emphasis>Extra
options to ifconfig:</emphasis> field in the network setup screen.
</para>
</sect2>
<sect2>
<title>Device timeout on <emphasis>ed</emphasis> Ethernet boards</title>

<para>You might find that the system finds your <emphasis>ed</emphasis> board, but after starting up
the system you get device timeout errors.  There are two typical reasons for
this:
</para>
<itemizedlist>
<listitem>

<para>The Ethernet board may not be correctly attached to the network.  If it's not
connected, you at least need a terminator.
</para>
</listitem>
<listitem>

<para>Your board is set up for a different IRQ from what the kernel expects.  By
default, the <emphasis>ed</emphasis> driver does not use the ``soft'' configuration (values
entered using EZSETUP in MS-DOS), but it will use the software configuration if
you specify <emphasis>?</emphasis> in the IRQ field of your kernel config file.
</para>
</listitem>
</itemizedlist>

<para>If the board is incorrectly configured, either move the jumper on the board to a
hard configuration setting (altering the kernel settings if necessary), or
specify the IRQ as <emphasis>-1</emphasis> in UserConfig or <emphasis>?</emphasis> in your kernel config
file.  This will tell the kernel to use the soft configuration.
</para>
</sect2>
<sect2>
<title>Devices at IRQ 9 don't work</title>

<para>You might find that a board set up to generate IRQ 9 (also known as IRQ 2)
doesn't work.  It definitely won't work if you define it to be at IRQ 2, but
even if you define it to be at IRQ 9, you might have problems.  One reason might
be that you have a VGA board which generates IRQ 9: some Microsoft programs used to
use this feature, though it is now obsolete.  Most VGA boards have a jumper to
disable generating IRQ 9.
</para>

<para>Unfortuntately, this may not be enough.  In some cases, you can disable IRQ 9 on
the VGA, and the board still won't work: you may have a brain-dead VGA board
which doesn't generate any interrupts when you remove the jumper, but it holds
the interrupt line anyway and stops any other board from asserting an interrupt.
</para>

<para>XX Should we mention this?
One sure-fire way of making sure that your VGA board doesn't do anything on the
IRQ 9 line is to cut the trace: remove the VGA board from the computer, and
place it on a table with the component side down, the mounting bracket on the
left and the bus connector pointing downwards.  IRQ 9 is the fourth contact from
the left.  You'll probably see a thin trace going away from the contact pad.  I
find that the best way to cut these traces is with a watchmaker's screwdriver.
Don't worry about damaging the board: this trace is never used for anything, and
if you <emphasis>do</emphasis> cut the wrong one by mistake, you can solder it back again
relatively easily.
</para>
</sect2>
<sect2>
<title>Kernel doesn't find Matsushita/Panasonic CD-ROM</title>

<para>If you have a Matsushita/Panasonic CD-ROM, and the kernel doesn't recognize it,
check that the port address for the <emphasis>matcd</emphasis> driver is really correct for
your host interface board.  Some Microsoft drivers for SoundBlaster report a
hardware port address for the CD-ROM interface that is 0x10 lower than it really
is.
</para>

<para>If you can't figure out the settings by examining the board or documentation,
you can restart the system and use UserConfig (see page <xref linkend="CFBSD-UserConfig"/>) to
change the <emphasis></emphasis> address to <emphasis>-1</emphasis>.  This setting causes the driver to
look at a number of I/O ports that various manufacturers use for their
Matsushita/Panasonic/Creative CD-ROM interfaces.  Once the driver locates the
address, you should run UserConfig again and specify the correct address.
Leaving the parameter <emphasis>port</emphasis> set to -1 increases the amount of time that
it takes the system to boot, and this could interfere with other devices.
</para>

<para><indexterm><primary>Matsushita</primary><secondary>CD-562</secondary></indexterm>
<indexterm><primary>Matsushita</primary><secondary>CD-563</secondary></indexterm>
<indexterm><primary>Matsushita</primary><secondary>CD-522</secondary></indexterm>
<indexterm><primary>Matsushita</primary><secondary>CD-523</secondary></indexterm>
<indexterm><primary>Panasonic</primary><secondary>CD-562</secondary></indexterm>
<indexterm><primary>Panasonic</primary><secondary>CD-563</secondary></indexterm>
<indexterm><primary>Panasonic</primary><secondary>CD-522</secondary></indexterm>
<indexterm><primary>Panasonic</primary><secondary>CD-523</secondary></indexterm>
<indexterm><primary>Teac</primary><secondary>CD55a</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Matsushita CD-562</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Matsushita CD-563</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Matsushita CD-522</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Matsushita CD-523</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Panasonic CD-562</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Panasonic CD-563</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Panasonic CD-522</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Panasonic CD-523</secondary></indexterm>
<indexterm><primary>CD-ROM</primary><secondary>Teac CD55a</secondary></indexterm>
FreeBSD <xref linkend="CFBSD-Fver"/> supports only the double-speed Matsushita CR-562 and CR-563.
The Matsushita/Panasonic CR-522, Matsushita/Panasonic CR-523 and TEAC CD55a
drives are currently not supported&mdash;the command sets for these drives are not
compatible with the double-speed CR-562 and CR-563 drives.  You can recognize
the single-speed CR-522 and CR-523 drives by their use of a CD caddy.
</para>
</sect2>
<sect2>
<title>Can't install from tape</title>

<para>If you try to install from tape you might get messages like:
</para>
<programlisting>
sa0(aha0:1:0) NOT READY csi 40,0,0,0
</programlisting>

<para>This is typically what happens if you forget to put the tape in the tape drive
before booting from floppy.  Put the tape in the drive, reboot and try again.
</para>
</sect2>
<sect2>
<title>Can't detect SCSI boards on HP Netserver</title>

<para>There is a known problem detecting the on-board AIC-7xxx host adapter on an EISA
HP Netserver.  The EISA on-board SCSI controller in the HP Netserver machines
occupies EISA slot 11, so all the ``true'' EISA slots are in front of it.
Unfortunately, the address space for EISA slots 10 and higher collides with the
address space assigned to PCI, and FreeBSD's auto-configuration currently cannot
handle this situation very well.
</para>

<para>For the time being, the best you can do is to pretend there is no address range
clash by increasing the value of kernel option EISA_SLOTS to a value of 12.  To
do this, boot with the -c option into UserConfig and type:
</para>
<programlisting>
eisa 12
quit
</programlisting>

<para>Later, you can compile a custom kernel with the option line
</para>
<programlisting>
options	EISA_SLOTS=12
</programlisting>

<para></para>
</sect2>
<sect2>
<title>Can't install on Panasonic AL-N1 or Rios Chandler</title>

<para>For some reason, these machines have problems with newer versions of FreeBSD, so
you could have this problem even if you have been running an older version of
FreeBSD.  Specifically, they don't like the new <emphasis>i586_copyout</emphasis> and
<emphasis>i586_copyin</emphasis> functions.  To disable this, boot the installation boot
floppy and enter UserConfig and type the following at it:
</para>
<programlisting>
flags npx0 1
quit
</programlisting>

<para>Then proceed normally to boot.  This will be saved into your kernel, so you only
need to do it once.
</para>
</sect2>
<sect2>
<title>Problems with the CMD640 IDE controller</title>

<para>This controller is broken: it can't handle commands on both channels
simultaneously.  The driver should recognize this problem and work around it, so
the only situation where you can run into problems is if you're upgrading from
an older version of FreeBSD.  In this case, build a custom kernel with the line
</para>
<programlisting>
options	"CMD640"
</programlisting>

<para></para>
</sect2>
<sect2>
<title>Can't find the floppy on Compaq Aero notebook</title>

<para>Compaq does not store information about the floppy drive in the CMOS RAM of an
Aero notebook, so the FreeBSD floppy driver assumes there is no drive
configured.  To fix this, use UserConfig to set the Flags value of the fdc0
device to 0x1, or build a kernel with this flag set (see page <xref linkend="CFBSD-config-fd0"/> for
details).  This tells the driver of the existence of the first floppy drive (as
a 1.44 MB drive) and doesn't probe the CMOS at all.
</para>
</sect2>
<sect2>
<title>Read errors on Intel AL440LX based systems</title>

<para>The AL44LX is also called <emphasis>Atlanta</emphasis>.  When booting from hard disk the first
time, you may find that it stops with a ``Read Error'' message. There appears to
be a bug in the BIOS on at least some of these boards.  This bug causes the
FreeBSD boot loader to think that it is booting from a floppy disk.  This is
only a problem if you are not using the BootEasy boot manager.  Slice the disk
in ``compatible'' mode and install BootEasy during the FreeBSD installation to
avoid the bug, or upgrade the BIOS (see Intel's website for details).
</para>
</sect2>
<sect2>
<title>Can't recognize Dell DSA on Poweredge XE</title>

<para>By default, FreeBSD does not recognize Dell's proprietary DSA (Dell SCSI Array)
RAID controller on the Dell Poweredge XE.  To fix this, use the EISA
configuration utility to configure the DSA for Adaptec 1540 emulation.  After
that FreeBSD detects the DSA as an Adaptec 1540 SCSI controller, with irq 11 and
port <emphasis>0x340</emphasis>.  In emulation mode the system will use the DSA RAID disks,
but you cannot use DSA specific features such as watching RAID health.
</para>
</sect2>
<sect2>
<title>Can't use the AMD PCnet-FAST Ethernet board</title>

<para>These boards are fitted to machines such as the IBM Netfinity 5xxx or 7xxx
series.  The <emphasis>lnc</emphasis> driver is currently faulty, and will often not work
correctly with the PCnet-FAST and PCnet-FAST+.  At the moment, there is no known
solution: you'll have to install a different board.
</para>
</sect2>
<sect2>
<title>Can't operate IBM EtherJet board</title>

<para>Sometimes the <emphasis>fxp</emphasis> driver correctly detects an IBM EtherJet PCI board,
but the lights on the board don't come on and it doesn't connect to the network.
We don't understand why this happens, and IBM hasn't been able to explain it
either.  The board is a standard Intel EtherExpress Pro/100 with an IBM label on
it, and these boards normally work just fine.  You may see these symptoms only
in some IBM Netfinity servers.  The only current solution is to install a
different Ethernet adapter.
</para>
</sect2>
<sect2>
<title>IBM Netfinity 3500 freezes during network installation</title>

<para>There is an unidentified problem with the onboard Ethernet board in these
machines.  It may be related to the SMP features of the system being
misconfigured.  You will have to install another Ethernet adapter, and avoid
attempting to configure the onboard adapter at any time.
</para>
</sect2>
<sect2>
<title>TEAC CD-220E (rev 1.0D) IDE CD-ROM hangs the system</title>

<para>There are apparently firmware problems with the TEAC CD-220E.  Fixes may be
forthcoming, but at the moment it's best to use a different drive.
</para>
</sect2>
</sect1>
<sect1>
<title>Root file system fills up</title>

<para>You might find that the installation completes successfully, and you get your
system up and running, but almost before you know it, the root file system fills
up.  It could be, of course, that you just haven't made it big enough&mdash;FreeBSD
root file systems have got bigger over the years.  In the first edition of this
book I recommended 32 MB ``to be on the safe side''.  Nowadays 50 MB looks good,
and it wouldn't do any harm to use 80 MB.
</para>

<para>On the other hand, maybe you already have an 80 MB root file system, and it
still fills up.  In this case, you should check where you have put your
<emphasis>/tmp</emphasis> and <emphasis>/var</emphasis> file systems.  See page <xref linkend="CFBSD-symlink-var"/> for
further information.
</para>
</sect1>
<sect1>
<title>Panic</title>

<para><indexterm><primary>panic</primary></indexterm>
<anchor id="CFBSD-panic"/>
Sometimes the system gets into so much trouble that it can't continue.  It
should notice this situation and stop more or less gracefully: you might see a
message like
</para>
<programlisting>
panic: free vnode isn't

Syncing disks 14 13 9 5 5 5 5 5 5 5 giving up

dumping to dev 20001 offset 0
dump 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 succeeded
Automatic reboot in 15 seconds - press a key on the console to abort
Reboooting...
</programlisting>

<para>Just because the system has panicked doesn't mean that you should panic too.
It's a sorry fact of life that software contains bugs.  Many commercial systems
just crash when they hit a bug, and you never know why, or they print a message
like <emphasis>General protection error</emphasis>, which doesn't tell you very much either.
When a UNIX system panics, it tells you why&mdash;in this case here, the reason is
<emphasis>free vnode isn't</emphasis>.  You may not be any the wiser for a message like this
(it tells you that the file system handling has got confused about the current
state of storage on a disk), but other people might.  In particular, if you
<emphasis>do</emphasis> get a panic and you want to ask, say, the FreeBSD hackers, please
don't just say ``My system panicked, what do I do?''  The answer&mdash;if you get
one&mdash;will be ``What was the panic string?''
</para>

<para>After panicking, the system tries to write file system buffers back to disk so
that they don't get lost.  This is not always possible, as we see on the second
line of this example.  It started off with 14 buffers to write, but it only
managed to write 9 of them, possibly because it was confused about the state of
the disk.  This can mean that you will have difficulties after rebooting, but it
might also mean that the system was wrong in its assumptions about the number of
buffers needed to be written.
</para>

<para><indexterm><primary>dumping</primary><secondary>the system</secondary></indexterm>
In addition to telling you the cause of the panic, FreeBSD will optionally copy
the current contents of memory to the swap file for post-mortem analysis.  This
is called <emphasis>dumping</emphasis> the system, and is shown on the next two lines.  In
order to enable dumping, you need to specify where the dump should be written.
In <emphasis>/etc/defaults/rc.conf</emphasis>, you will find:
</para>
<programlisting>
dumpdev="NO"		# Device name to crashdump to (if enabled).
</programlisting>

<para>To enable dumping, put something like this in <emphasis>/etc/rc.conf</emphasis>:
</para>
<programlisting>
dumpdev=/dev/wd0s1b
</programlisting>

<para>If you don't already have a file <emphasis>/etc/rc.conf</emphasis>, just create it.  Make sure
that the name of the <emphasis>dumpdev</emphasis> corresponds to a swap partition with at
least as much space as your total memory.  You can use <emphasis>pstat</emphasis> to check
this:
</para>
<programlisting>
# <command>pstat -s</command>
Device      1024-blocks     Used    Avail Capacity  Type
/dev/wd0s1b       51200    50108     1028    98%    Interleaved
/dev/da0b         66036    51356    14616    78%    Interleaved
/dev/da2b        204800    51220   153516    25%    Interleaved
Total            321844   152684   169160    47%
</programlisting>

<para>As long as this machine doesn't have more than about 192 MB of memory, it will
be possible to take a dump on <emphasis>/dev/da2b</emphasis>.
</para>

<para>In addition, ensure you have a directory <emphasis>/var/crash</emphasis>.  After rebooting, the
system first checks the integrity of the file systems, then it checks for the
presence of a dump.  If it finds one, it copies the dump and the current kernel
to <emphasis>/var/crash</emphasis>.
</para>

<para>It's always worth enabling dumping, assuming your swap space is at least as
large as your memory.  You can analyze the dumps with <emphasis>kgdb</emphasis>&mdash;see the
online handbook for more details.
</para>

<para>To get the best results from a dump analysis, you need a <emphasis>debug kernel</emphasis>.
This kernel is in fact identical to a normal kernel, but it includes a lot of
information that can be used for dump analysis.  See page <xref linkend="CFBSD-run-config"/> for
details of how to build a debug kernel.  Since you never know when you might run
into a problem, it's highly recommended to use a debug kernel at all times.
</para>
</sect1>
<sect1>
<title>Fixing a broken installation</title>

<para><anchor id="CFBSD-recovery"/>
<indexterm><primary>Fixit</primary><secondary>floppy</secondary></indexterm>
A really massive crash may damage your system to such an extent that you need to
reinstall the whole system.  For example, if you overwrite your hard disk from
start to finish, you don't have any other choice.  In many cases, though, the
damage is serious but repairable.  The problem is, you can't start the system to
fix the problems.  In this case, you have two possibilities:
</para>
<itemizedlist>
<listitem>

<para>Boot from the second CD-ROM (<emphasis>Live Filesystem</emphasis>).  It will be mounted as
the root file system.
</para>
</listitem>
<listitem>

<para><indexterm><primary>floppies/fixit.flp</primary></indexterm>
Boot from the <emphasis>Fixit</emphasis> floppy.  The Fixit floppy is in the distribution in
the same directory as the boot diskette, <emphasis>floppies</emphasis>.  Just copy
<emphasis>floppies/fixit.flp</emphasis> to a disk in the same way as described for boot
diskettes in page <xref linkend="CFBSD-make-floppy"/>.  To use the fixit floppy, first boot with the
boot diskette and select ``Fixit floppy'' from the main menu.  The fixit floppy
will be mounted under the root MFS as <emphasis>/mnt2</emphasis>.
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>/mnt2</primary><secondary>mount point</secondary></indexterm>
In either case, the hard disks aren't mounted: you might want to do repair work
on them before any other access.
</para>

<para>Use this option only if you have a good understanding of the system installation
process.  Depending on the damage, you may or may not be successful.  If you
have a recent backup of your system, it might be faster to perform a complete
installation than to try to fix what's left, and after a re-installation you can
be more confident that the system is correctly installed.
</para>
</sect1>
</chapter>
\" This file is in -*- nroff-fill -*- mode
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchxtheory"><title>XFree86 configuration in depth</title>

<para>In most cases, the information in <xref linkend="CFBSD-chxsetup"/>, should be enough to get X up and
running.  If it doesn't work for some reason, or if you're a masochist, or if
you just want to understand the procedure better, this chapter should be able to
help.
</para>

<para>In the next section, we'll look at the technical background, and on page
<xref linkend="CFBSD-doxconfig"/> we'll look at setting up the <emphasis>XF86Config</emphasis> file.
</para>
<sect1>
<title>X configuration: the theory</title>

<para><anchor id="CFBSD-Xtheory"/>
Setting up your <emphasis>XF86Config</emphasis> file normally takes a few minutes, but
sometimes you can run into problems which make grown men cry.  In the rest of
this
chapter,
we'll look at the technical background:
</para>
<itemizedlist>
<listitem>

<para>How display boards and monitors work.
</para>
</listitem>
<listitem>

<para>How to set up XFree86 to work with your hardware.
</para>
</listitem>
<listitem>

<para>How to tune your hardware for maximum display performance.
</para>
</listitem>
<listitem>

<para>How to fry your monitor.
</para>
</listitem>
</itemizedlist>

<para>I mean the last point seriously: conventional wisdom says that you can't damage
hardware with a programming mistake, but in this case, you can, and people do it
from time to time.  When you've read the section on how monitors work, you'll
understand, but <emphasis>please</emphasis> don't start tuning until you understand the dangers
involved.
</para>
<sect2>
<title>How TVs and monitors work</title>

<para>You don't have to be a computer expert to see the similarity between monitors
and TVs: current monitor technology is derived from TV technology, and most
older display boards have modes which can use TVs instead of monitors.  Those of
us who were on the microcomputer scene 15 to 20 years ago will remember the joy
of getting a computer display on a portable TV, a ``glass tty'' connected by a
serial line running at 300 or 1200 bps.
</para>

<para>There are at least two ways to create pictures on a cathode ray tube: one is
derived from oscilloscopes, where each individual character is scanned by the
electron beam, rather like writing in the sand with your finger.  Some early
terminals used this technology, but it has been obsolete for at least 20 years.
</para>

<para>TVs and monitors display the picture by scanning lines across the screen.  Like
in a book, the first line starts at the top left of the screen and goes to the
top right.  Each successive line starts slightly below the previous line.  This
continues until the screen is full.  Like in a book, the lines don't have to be
full: the picture is formed by altering the intensity of the electron beam as it
scans the lines.
</para>

<para><indexterm><primary>deflection</primary><secondary>units</secondary></indexterm>
<indexterm><primary>deflection</primary><secondary>horizontal</secondary></indexterm>
<indexterm><primary>deflection</primary><secondary>vertical</secondary></indexterm>
<indexterm><primary>deflection</primary><secondary>line</secondary></indexterm>
<indexterm><primary>deflection</primary><secondary>frame</secondary></indexterm>
To perform this scan, the TV has two <emphasis>deflection units</emphasis>: one scans from left
to right, and the other scans, much more slowly, from top to bottom.  Not
surprisingly, these units are called the <emphasis>horizontal</emphasis> and <emphasis>vertical</emphasis>
deflection units.  You may also encounter the terms <emphasis>line</emphasis> and <emphasis>frame</emphasis>
deflection.
</para>

<para><indexterm><primary>flyback</primary><secondary>horizontal</secondary></indexterm>
<indexterm><primary>flyback</primary><secondary>vertical</secondary></indexterm>
The tube can only move the electron beam at a finite speed.  When the electron
beam reaches the right hand side of the screen, it needs to be deflected back
again.  This part of the scan is called the <emphasis>horizontal flyback</emphasis>, and it is
not used for displaying picture data.  The actual time that the hardware
requires for the flyback depends on the monitor, but it is in the order of 5% to
10% of the total line scan time.  Similarly, when the vertical deflection
reaches the bottom of the screen, it performs a <emphasis>vertical flyback</emphasis>, which is
also not used for display purposes.
The printed version of this book includes diagrams which are impossible to
reproduce in ASCII.  Sorry about that&mdash;about the only thing I can suggest is
to get hold of the book.
\}
Figure
shows the resultant pattern.
</para>

<para>[
move right 1.3i
TV: box wid 3.2i height 2.4i
A: line from TV.nw+ (.1i,-.1i) to TV.ne + (-.1i,-.1i)
B: line from TV.nw+ (.1i,-.2i) to TV.ne + (-.1i,-.2i)
C: line from TV.nw+ (.1i,-.3i) to TV.ne + (-.1i,-.3i)
"<emphasis>etc</emphasis>" at C.w + (.1i,-.2i)

line dashed .04i from A.e to B.w
Fb2: line dashed .04i from B.e to C.w

"First scan line" at A.e  + (.3i,0i) ljust
"Second scan line" at B.e + (.3i,0i) ljust

FB: "Flyback" at C.c + (0i,-.7i)

arrow dashed from FB.c +(0i,.1i) to Fb2.c
]
</para>

<para><figure><title>Scanning pattern on the monitor</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>

<para>It's not enough to just deflect, of course: somehow you need to ensure that the
scanning is synchronized with the incoming signal, so that the scan is at the
top of the screen when the picture information for the top of the screen
arrives.  You've seen what happens when this doesn't happen: the picture runs up
and down the screen (incorrect vertical synchronization) or tears away from the
left of the screen (incorrect horizontal synchronization).  Synchronization is
achieved by including synchronization pulses in the horizontal and vertical
flyback periods.  They have a voltage level outside the normal picture data
range in order to ensure that they are recognized as synchronization pulses.
</para>

<para><indexterm><primary>video</primary><secondary>blanking</secondary></indexterm>
<indexterm><primary>porch</primary><secondary>front</secondary></indexterm>
<indexterm><primary>porch</primary><secondary>back</secondary></indexterm>
As if that wasn't enough, the video amplifier, the part of the TV which alters
the intensity of the spot as it travels across the screen, needs time to ensure
that the flyback is invisible, so there are brief pauses between the end of the
line and the start of the sync pulse, and again between the end of the sync
pulse and the beginning of the data.  This process is called <emphasis>blanking</emphasis>, and
the delays are called the <emphasis>front porch</emphasis> (before the sync pulse) and the
<emphasis>back porch</emphasis> (after the sync pulse).
In the printed version of this book there's another diagram here.
\}
Figure
depicts a complete scan line.
<anchor id="CFBSD-waveform"/>
</para>

<para><!--  Dimensions -->
p3=.3i
p02=.02i
p1=.1i
p15=.15i
p05=.05i
<!--  For the sake of the article, two 1" variables -->
p100=1i
p100a=1i
p70=.7i
p20=.2i
p60=.6i
p48=.48i
p08=.08i
p025=.025i
p80=.8i
p08=.08i
p50=.5i
p12=.12i
p125=1.25i
p170=1.7i
p07=.07i
move right 1i
line dotted p02 right p1;					# end of previous line
A: line dotted p02 up p100 then right p15;			# start of sync pulse
arc dotted p02 from A.n to A.n+(p05, p05)
line dotted p02 up p15;
Pulse1: line dotted p02 right p1;
B: line dotted p02 down p15;	# pulse
arc dotted p02 from B.s to B.s+(p05,-p05);
Rp: line dotted p02 right p15;				# rear porch
Ps: line down p100 			 	# and picture data
line right p1
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
C: line up p100
line right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
line up p100 then right p1 then down p100 then right p1;
E: line up p100;
Fp: line right p15; 				# start of next sync pulse
arc from Fp.e to Fp.e+(p05, p05)
line up p15;
Pulse2: line right p1;
F: line down p15;				# pulse
arc from F.s to F.s+(p05,-p05);
line right p15;				# front porch
G: line down p100				 	# and picture data of next frame
   line dotted p02 right p1
   line dotted p02 up p70

move to Pulse1.c + (0,p20)
P1text: "Sync pulse" above;
arrow from P1text.c to Pulse1.c

Rpt: "Back porch" at Rp.c + (p60,p48)
arrow from Rpt.w + (-p3,-p08) to Rp.c + (-p07, 0i)
move to Fp

Fpt: "Front porch" at Fp.c + (-p60,p48)

arrow from Fpt.se + (p3,-p08) to Fp.c + (p07, 0i)
move to Fp

move to Pulse2.c + (0,p20)
P2text: "Sync pulse" above;
arrow from P2text.c to Pulse2.c

Cw: arrow from C.n + (0i,p1) to Ps.n + (0i,p1)
Ce: arrow from C.n + (0i,p1) to E.n + (0i,p1)

line dotted p025 from Cw.w to Ps.n
line dotted p025 from Ce.e to E.n

"Picture data" at C.n + (0i,p20)

Rd: "(Reference point)" at Ps.s + (0i,-p50)
     arrow from Rd + (0i,p1) to Ps.s + (0i,-p05)

HDE: "HDE" at E.s + (-p3,-p50)
     arrow from HDE + (0i,p1) to E.s + (0i,-p05)

SHR: "SHR" at Pulse2.w + (-p12,-p170)
     arrow from SHR + (p12,p1) to Pulse2.w + (0i,-p125)
     line dotted p025 from Pulse2.w + (0i,-p125+p100a-p100) to Pulse2.w

EHR: "EHR" at Pulse2.e + (p12,-p170)
     arrow from EHR + (-p12,p1) to Pulse2.e + (0i,-p125)
     line dotted p025 from Pulse2.e + (0i,-p125+p100a-p100) to Pulse2.e

HT: "HT" at G.s + (p3,-p50)
     arrow from HT + (0i,p1) to G.s + (0i,-p05)

"<emphasis>Registers:</emphasis>" at HDE.w - (p80,0i)
</para>

<para></para>

<para><figure><title>Scan line and register values</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>

<para><indexterm><primary>interlacing</primary></indexterm>
The register information at the bottom of the picture refers to the video
controller registers.  We'll look at how to interpret them
on page
</para>

<para>That, in a nutshell, is how horizontal deflection works.  Vertical deflection
works in almost the same way, just slower, with one minor exception.  This basic
display mechanism was developed for TVs in the 1930s, at a time when terms like
high-tech (or even electronics) hadn't even been invented, and even today we're
stuck with the low data rates that they decided upon in those days.  Depending
on the country, TVs display only 25 or 30 frames (pages of display) per second.
This caused an unpleasant flicker in the display.  This flicker was avoided with
a trick called <emphasis>interlacing</emphasis>: instead of displaying the frame in one
vertical scan, the odd and even lines are displayed in two alternating half
frames, which increases the apparent frame frequency to 50 or 60 Hz.
</para>
</sect2>
<sect2>
<title>How monitors differ from TVs</title>

<para>So how do we apply this to computer displays?  Let's look at the US standard
NTSC system&mdash;the international PAL and SECAM systems are almost identical
except for the number of lines and a minor difference in the vertical frequency.
NTSC specifies 525 lines, but that includes the vertical flyback time, and in
fact only about 480 lines are visible.  The aspect ratio of a normal TV is 4:3,
in other words the screen is one-third wider than it is high, so if we want
square pixels,
<footnote>

<para>A square pixel is one with the same height and width.  They don't have to be
that way, but it makes graphics software much simpler.
</para>
</footnote>
we need to have one-third more pixels per line.  This means that we can display
640 pixels per line on 480 lines.
<footnote>

<para>Does this look familiar?  Now you know why.
</para>
</footnote>
This resolution is normally abbreviated to ``640x480''.  PAL and SECAM have
lower vertical frequencies, which allows a nominal 625 lines, of which about 580
are displayed.  Either way, these values have two huge disadvantages: first, the
resolution is barely acceptable for modern graphics displays, and secondly they
are interlaced displays.  Older PC display hardware, such as the CGA and some
EGA modes, was capable of generating these signal frequencies, but VGAs can no
longer do it.  This is a pity, in some ways: I'd like to have an X display on my
TV in the lounge room, but my last EGA died a couple of years ago.
</para>

<para>The first problem is interlace: it works reasonably for TVs, but it's a pain for
computer displays&mdash;there's still more flicker than a real 50 Hz or 60 Hz
display.  Modern display boards can still run in interlace mode, but don't even
think about doing so unless you're forced to&mdash;the resultant picture looks out
of focus and is very tiring to read.
</para>

<para>The second problem is the resolution: nowadays, 1024x768 is a normal enough
resolution, but I'm writing this on a display with 1280x1024, and many modern
boards display 1600x1200.  On the other hand, even 60 Hz refresh rate is barely
adequate: read any marketing literature and you'll discover that 72 Hz is the
point at which flicker suddenly disappears.  To get high-resolution, high
refresh rate displays, you need some very high internal frequencies&mdash;we'll see
how high further down.
</para>
</sect2>
<sect2>
<title>How to fry your monitor</title>

<para><anchor id="CFBSD-fry-monitor"/>
<indexterm><primary>line</primary><secondary>transformer</secondary></indexterm>
Remember that a monitor is just a glorified TV?  Well, one of the design
constraints of real TVs is that they have only a single horizontal frequency and
only a single vertical frequency.  This simplifies the hardware design
considerably: the horizontal deflection uses a tuned circuit to create both the
deflection frequency and the high voltage required to run the tube.  This
circuit is comprised of a transformer (the <emphasis>line transformer</emphasis>) and a
condenser.  Run a line transformer even fractionally off its intended frequency
and it will run much less efficiently and use more current, which gets converted
to heat.  If you run a conventional monitor off spec for any length of time, it
will burn out the line transformer.
</para>

<para>You don't have to roll your own X configuration to burn out the monitor: ten
years ago, the standard display boards were CGAs and HDAs,
<footnote>

<para>Color Graphics Adapter and Hercules Display Adapter.
</para>
</footnote>
and they had different line frequencies and thus required different monitors.
Unfortunately, they both used the same data connector.  If you connected an HDA
(18.43 kHz line frequency) to a CGA monitor (15.75 kHz, the NTSC line
frequency), you could expect smoke signals within a few minutes.
</para>

<para>Modern PC monitors no longer use line transformers, and there are few of them
which can't handle at least a range of line frequencies, but this doesn't mean
you can't damage them&mdash;you'll just burn out something else, frequently the
power supply.  In addition, just because the monitor displays correctly doesn't
mean that it is running in spec.  I have a rather elderly Eizo 9500 (called
Nanao in the US) which has three frequency ranges: (exactly) 31.5 kHz, 48 to 50
kHz, or 64 to 78 kHz.  In fact, it will display at any frequency between 48 and
78 kHz, but if it were run at 57 kHz for any length of time, I would be in for a
hefty repair bill.  The moral of the story:
</para>
<note>

<para>Never run your monitor out of spec.  If your display is screwed up, there's a
good chance that the frequencies are out, so turn off the monitor.
</para>
</note>

<para></para>

<para>Monitors aren't the only thing that you can burn out, of course.  If you try
hard, you can also burn out chips on some display boards by running them at
frequencies which are out of spec.  In practice, though, this doesn't happen
nearly as often.
</para>

<para><indexterm><primary>video</primary><secondary>composite</secondary></indexterm>
<indexterm><primary>composite</primary><secondary>video</secondary></indexterm>
Another difference between TVs and monitors is the kind of signal they take.  A
real TV includes a receiver, of course, so you have an antenna connection, but
modern TVs also have connections for inputs from VCRs, which are usually an
audio signal and a video signal.  The video signal consists of five important
parts: the <emphasis>red</emphasis> signal, the <emphasis>green</emphasis> signal, the <emphasis>blue</emphasis> signal, and
the horizontal and vertical sync pulses.  This kind of signal is called
<emphasis>composite video</emphasis>.  By contrast, most modern monitors separate these signals
onto separate signal lines, and older boards, such as the EGA, even used several
lines per colour.  Unfortunately, there is no complete agreement about how these
signals should work: the polarity of the sync pulses varies from one board to
the next, and some boards cheat and supply the sync pulses on the green signal
line.  This is mainly of historical interest, but occasionally you'll come
across a real bargain 20" monitor which only has 3 signal connections, and you
may not be able to get it to work&mdash;this could be one of the reasons.
</para>
</sect2>
<sect2>
<title>The CRT controller</title>

<para><anchor id="CFBSD-setting-video-regs"/>
The display controller, usually called a CRT (Cathode Ray Tube) controller, is
the part of the display board which creates the signals we've just been talking
about.  Early display controllers were designed to produce signals that were
compatible with TVs: they had to produce a signal with sync pulses, front and
back porches, and picture data in between.  Modern display controllers can do a
lot more, but the principles remain the same.
</para>

<para><indexterm><primary>dot</primary><secondary>clock</secondary></indexterm>
The first part of the display controller creates the framework we're looking
for: the horizontal and vertical sync pulses, blanking and picture information,
which is represented as a series of points or <emphasis>dots</emphasis>.  To count, we need a
pulse source, which also determines the duration of individual dots, so it is
normally called a <emphasis>dot clock</emphasis>.  For reasons lost in history, CRT controllers
start counting at the top left of the display, and not at the vertical sync
pulse, which is the real beginning of the display.  To define a line to the
horizontal deflection, we need to set four CRTC registers to tell
it&mdash;see the
diagram on page
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>register</primary><secondary>Horizontal Display End</secondary></indexterm>
The <emphasis>Horizontal Display End</emphasis> register (HDE) specifies how many dots we want
on each line.  After the CRTC has counted this many pixels, it stops outputting
picture data to the display.
</para>
</listitem>
<listitem>

<para><indexterm><primary>register</primary><secondary>Start Horizontal Retrace</secondary></indexterm>
The <emphasis>Start Horizontal Retrace</emphasis>
register (SHR) specifies how many dot clock
pulses occur before the sync pulse starts.  The difference between the contents
of this register and the contents of the HDE register defines the length of the
front porch.
</para>
</listitem>
<listitem>

<para><indexterm><primary>register</primary><secondary>End Horizontal Retrace</secondary></indexterm>
The <emphasis>End Horizontal Retrace</emphasis>
register (EHR) defines the end of the sync
pulse.  The width of the sync pulse is the difference between the contents of
this register and the SHR register.
</para>
</listitem>
<listitem>

<para><indexterm><primary>register</primary><secondary>Horizontal Total</secondary></indexterm>
The <emphasis>Horizontal Total</emphasis>
register (HT) defines the total number of dot clocks
per line.  The width of the back porch is the difference between the contents of
this register and the EHR register.
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>register</primary><secondary>Start Horizontal Blanking</secondary></indexterm>
<indexterm><primary>register</primary><secondary>End Horizontal Blanking</secondary></indexterm>
In addition, the <emphasis>Start Horizontal Blanking</emphasis> and <emphasis>End Horizontal
Blanking</emphasis> registers (SHB and EHB) define when the video signals are turned off
and on.  The server sets these registers automatically, so we don't need to look
at them in more detail.
</para>

<para><indexterm><primary>register</primary><secondary>Vertical Display End</secondary></indexterm>
<indexterm><primary>register</primary><secondary>Start Vertical Retrace</secondary></indexterm>
<indexterm><primary>register</primary><secondary>End Vertical Retrace</secondary></indexterm>
<indexterm><primary>register</primary><secondary>Vertical Total</secondary></indexterm>
<indexterm><primary>register</primary><secondary>Start Vertical Blanking</secondary></indexterm>
<indexterm><primary>register</primary><secondary>End Vertical Blanking</secondary></indexterm>
The control of the vertical deflection is similar.  In this case, the registers
are <emphasis>Vertical Display End</emphasis> (VDE), <emphasis>Start Vertical Retrace</emphasis> (SVR), <emphasis>End
Vertical Retrace</emphasis> (EVR), <emphasis>Vertical Total</emphasis> (VT), <emphasis>Start Vertical
Blanking</emphasis> (SVB), and <emphasis>End Vertical Blanking</emphasis> (EVB).  The values in these
registers are counted in lines.
</para>

<para>VGA hardware evolved out of older 8 bit character-based display hardware, which
counted lines in characters, not dot clocks.  As a result, all of these
registers are 8 bits wide.  This is adequate for character displays, but it's a
problem when counting dots: the maximum value you can set in any of these
registers is 255.  The designers of the VGA resorted to a number of nasty
kludges to get around this problem: the horizontal registers count in groups of
8 dot clocks, so they can represent up to 2048 dot clocks. The vertical
registers overflow into an overflow register.  Even so, the standard VGA can't
count beyond 1024 lines.  Super VGAs vary in how they handle this problem, but
typically they add additional overflow bits.  To give you an idea of how clean
the VGA design is, consider the way the real Vertical Total (total number of
lines on the display) is defined on a standard VGA.  It's a 10 bit quantity, but
the first 8 bits are in the VT register, the 9th bit is in bit 0 of the overflow
register, and the 10th bit is in bit 5 of the overflow register.
</para>
</sect2>
<sect2>
<title>The XF86Config mode line</title>

<para>One of the steps in setting up XFree86 is to define these register values.
Fortunately, you don't have to worry about which bits to set in the overflow
register: the mode lines count in dots, and it's up to the server to convert the
dot count into something that the display board can understand.  A typical Mode
line looks like:
</para>
<programlisting>
Modeline "640x480a" 28 640 680 728 776 480 480 482 494
</programlisting>

<para>These ten values are required.  In addition, you may specify modifiers at the
end of the line.  The values are:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>XF86Config</primary></indexterm>
A label for the resolution line.  This must be enclosed in quotation marks, and
is used to refer to the line from other parts of the <emphasis>XF86Config</emphasis> file.
Traditionally, the label represents the resolution of the display mode, but it
doesn't have to.  In this example, the resolution really is 640x480, but the
<emphasis>a</emphasis> at the end of the label is a clue that it's an alternative value.
</para>
</listitem>
<listitem>

<para>The clock frequency, 28 MHz in this example.
</para>
</listitem>
<listitem>

<para>The Horizontal Display End, which goes into the HDE register.  This value and
all that follow are specified in dots.  The server mangles them as the display
board requires and puts them in the corresponding CRTC register.
</para>
</listitem>
<listitem>

<para>The Start Horizontal Retrace (SHR) value.
</para>
</listitem>
<listitem>

<para>The End Horizontal Retrace (EHR) value.
</para>
</listitem>
<listitem>

<para>The Horizontal Total (HT) value.
</para>
</listitem>
<listitem>

<para>The Vertical Display End (VDE) value.  This value and the three following are
specified in lines.
</para>
</listitem>
<listitem>

<para>The Start Vertical Retrace (SVR) value.
</para>
</listitem>
<listitem>

<para>The End Vertical Retrace (EVR) value.
</para>
</listitem>
<listitem>

<para>The Vertical Total (VT) value.
</para>
</listitem>
</itemizedlist>

<para>This is pretty dry stuff.  To make it easier to understand, let's look at how we
would set a typical VGA display with 640x480 pixels.  Sure, you can find values
for this setup in any release of XFree86, but that doesn't mean that they're the
optimum for <emphasis>your system</emphasis>.  We want a non-flicker display, which we'll
take to mean a vertical frequency of at least 72 Hz, and of course we don't want
interlace.  Our multiscan monitor can handle any horizontal frequency between 15
and 40 kHz: since we want the least flicker, we'll aim for 40 kHz.
</para>

<para>First, we need to create our lines.  They contain 640 pixels, two porches and a
sync pulse.  The only value we really know for sure is the number of pixels.
How long should the porches and the sync pulses be?  If you have a good monitor
with good documentation, it should tell you, but most monitor manufacturers
don't seem to believe in good documentation.  When they do document the values,
they vary significantly from monitor to monitor, and even from mode to mode:
they're not as critical as they look.  For example, here are some typical values
from my NEC 5D handbook:
</para>

<para>Horizontal sync pulse: 1 to 4 \(*ms, front porch 0.18 to 2.1 \(*ms, back porch
1.25 to 3.56 \(*ms.
</para>

<para>As we'll see, the proof of these timing parameters is in the display.  If the
display looks good, the parameters are OK.  I don't know of any way to damage
the monitor purely by modifying these parameters, but there are other good
reasons to stick to this range.  As a rule of thumb, if you set each of the
three values to 2 \(*ms to start with, you won't go too far wrong.
Alternatively, you could start with the NTSC standard values: the standard
specifies that the horizontal sync pulse lasts for 4.2 to 5.1 \(*ms, the front
porch must be at least 1.27 \(*ms.  NTSC doesn't define the length of the back
porch&mdash;instead it defines the total line blanking, which lasts for 8.06 to 10.3
\(*ms.  For our purposes, we can consider the back porch to be the length of the
total blanking minus the lengths of the front porch and the sync pulse.  If you
take values somewhere in the middle of the ranges, you get a front porch of 1.4
\(*ms, a sync pulse of 4.5 \(*ms, and total blanking 9 \(*ms, which implies a
back porch of 9 - 1.4 - 4.5 = 3.1 \(*ms.
</para>

<para>For our example, let's stick to 2 \(*ms per value.  We have a horizontal
frequency of 40 kHz, or 25 \(*ms per line.  After taking off our 6 \(*ms for
flyback control, we have only 19 \(*ms left for the display data.  In order to
get 640 pixels in this time, we need one pixel every 19 \(di 640 \(*ms, or about 30
ns.  This corresponds to a frequency of 33.6 MHz.  This is our desired dot
clock.
</para>

<para>The next question is: do we have a dot clock of this frequency?  Maybe.  This
should be in your display board documentation, but I'll take a bet that it's
not.  Never mind, the XFree86 server is clever enough to figure this out for
itself.  At the moment, let's assume that you do have a dot clock of 33 MHz.
</para>
<note>

<para>If you don't have a suitable clock, you'll have to take the next lower clock
frequency that you do have: you can't go any higher, since this example assumes
the highest possible horizontal frequency.
</para>
</note>

<para>You now need to calculate four register values to define the horizontal lines:
</para>
<itemizedlist>
<listitem>

<para>The first value is the Horizontal Display End, the number of pixels on a line.
We know this one: it's 640.
</para>
</listitem>
<listitem>

<para>You calculate SHR by adding the number of dot clocks that elapse during the
front porch to the value of HDE.  Recall that we decided on a front porch of 2
\(*ms.  In this time, a 33 MHz clock will count 66 cycles.  So we add 66, right?
Wrong.  Remember that the VGA registers count in increments of 8 pixels, so we
need to round the width of the front porch to a multiple of 8.  In this case, we
round it to 64, so we set SHR to 640 + 64 = 704.
</para>
</listitem>
<listitem>

<para>The next value we need is EHR, which is SHR plus the width of the horizontal
retrace, again 64 dot clocks, so we set that to 704 + 64 = 768.
</para>
</listitem>
<listitem>

<para>The final horizontal value is HT.  Again, we add the front porch&mdash;64 dot
clocks&mdash;to EHR and get 768 + 64 = 832.
</para>
</listitem>
</itemizedlist>

<para>At this point, our vestigial mode line looks like:
</para>
<programlisting>
Modeline "640x480"   28   640 704 768 832
</programlisting>

<para>Next, we need another four values to define the vertical scan.  Again, of the
four values we need, we only know the number of lines.  How many lines do we use
for the porches and the vertical sync?  As we've seen, NTSC uses about 45 lines
for the three combined, but modern monitors can get by with much less.  Again
referring to the Multisync manual, we get a front porch of betwwen 0.014 and 1.2
ms, a sync pulse of between 0.06 and 0.113 ms, and a back porch of between 0.54
and 1.88 ms.  But how many lines is that?
</para>

<para>To figure that out, we need to know our <emphasis>real</emphasis> horizontal frequency.  We
were aiming at 40 kHz, but we made a couple of tradeoffs along the way.  The
real horizontal frequency is the dot clock divided by the horizontal total, in
this case 33 MHz \(di 832, which gives us 39.66 kHz&mdash;not too bad.  At that
frequency, a line lasts 1\(di39660 seconds, or just over 25 \(*ms, so our front
porch can range between \(12 and 48 lines, our sync pulse between 2 and 5 lines,
and the back porch between 10 and 75 lines.  Do these timings make any sense?
No, they don't&mdash;they're just values which the monitor can accept.
</para>

<para>To get the highest refresh rate, we can go for the lowest value in each case.
It's difficult to specify a value of \(12, so we'll take a single line front
porch.  We'll take two lines of sync pulse and 10 lines of back porch. This
gives us:
</para>
<itemizedlist>
<listitem>

<para>VDE is 480.
</para>
</listitem>
<listitem>

<para>SVR is 481.
</para>
</listitem>
<listitem>

<para>EVR is 483.
</para>
</listitem>
<listitem>

<para>VT is 493.
</para>
</listitem>
</itemizedlist>

<para>Now  our mode line is complete:
</para>
<programlisting>
Modeline "640x480" 28  640 704 768 832  480 481 483 493
</programlisting>

<para><indexterm><primary>XF86config</primary></indexterm>
Now we can calculate our vertical frequency, which is the horizontal frequency
divided by the Vertical Total, or 39.66 \(di 493 kHz, which is 80.4 Hz&mdash;that's
not bad either.  By comparison, if you use the standard entry in
<emphasis>XF86config</emphasis>, you will get a horizontal frequency of 31.5 kHz and a vertical
frequency of only 60 Hz.
</para>

<para>If you know the technical details of your monitor and display board, it really
is that simple.  This method doesn't require much thought, and it creates
results which work.
</para>
</sect2>
</sect1>
<sect1>
<title>XF86Config</title>

<para><anchor id="CFBSD-doxconfig"/>
<indexterm><primary>XF86Config</primary></indexterm>
<indexterm><primary>XF86Config</primary></indexterm>
<indexterm><primary>XF86Config.eg</primary></indexterm>
<indexterm><primary>XF86Config</primary></indexterm>
The <emphasis>XF86Config</emphasis> file contains several sections; these procedures will
lead you through filling out each part.  There is a sample <emphasis>XF86Config</emphasis>
file in <emphasis>/usr/X11R6/lib/X11/XF86Config.eg</emphasis>.  You can copy this to
<emphasis>/usr/X11R6/lib/X11/XF86Config</emphasis>, and edit that file to your specific
configuration.  In the following examples, we'll look at the relevant sections
of <emphasis>XF86Config</emphasis> and discuss what might need changing.  Refer to the man
page <emphasis>XF86Config(5)</emphasis> as you fill in your <emphasis>XF86Config</emphasis> file.  Table
overleaf, gives you an overview of the sections in <emphasis>XF86Config</emphasis>.  Note that
the X server treats lines beginning with <emphasis>#</emphasis> as comments.  You'll see many
definitions with a <emphasis>#</emphasis> in front of them in the following examples.  You
activate the definition by removing the <emphasis>#</emphasis>.
</para>

<para>Normally, you'll set up your <emphasis>XF86Config</emphasis> when you run the
<emphasis>xf86config</emphasis> program (note the difference in character case; in UNIX,
<emphasis>XF86Config</emphasis> and  <emphasis>xf86config</emphasis> are two different file names).  We
looked at that in <xref linkend="CFBSD-chxsetup"/>, on page
The following discussion will apply equally well to the <emphasis>XF86Config</emphasis> file
that you generate by this procedure.
<table frame='all'><title>XF86Config sections</title>
center,box,tab(#) ;
| l | lw67 | .
Section#Description
=

<tgroup cols='2' align='left' colsep='1' rowsep='1'><tbody>
<row><entry> Files</entry><entry> Sets the default font and RGB paths&mdash;see page <xref linkend="CFBSD-XF86Config-File-section"/>.
</entry></row>
<row><entry> Server Flags</entry><entry> Sets a few general server options. Refer to the server manual page for more information about them.
</entry></row>
<row><entry> Keyboard</entry><entry> Sets up keyboard devices, and sets a few optional parameters&mdash;see page <xref linkend="CFBSD-XF86Config-Keyboard-section"/>
</entry></row>
<row><entry> Pointer</entry><entry> Sets up the pointer devices, and sets a few optional parameters&mdash;see page <xref linkend="CFBSD-XF86Config-Pointer-section"/>
</entry></row>
<row><entry> Monitor</entry><entry> Describes your monitor to the server&mdash;see page <xref linkend="CFBSD-XF86Config-Monitor-section"/>
</entry></row>
<row><entry> Device</entry><entry> Describes your video hardware to the server&mdash;see page <xref linkend="CFBSD-XF86Config-Device-section"/>
</entry></row>
<row><entry> Screen</entry><entry> Describes how to use the monitor and video hardware&mdash;see page <xref linkend="CFBSD-XF86Config-Screen-section"/>
</entry></row>
</tbody></tgroup></table>
</para>
<sect2>
<title>The Files section</title>

<para><anchor id="CFBSD-XF86Config-File-section"/>
<indexterm><primary>XF86Config</primary><secondary>Files section</secondary></indexterm>
The <emphasis>Files</emphasis> section of the <emphasis>XF86Config</emphasis> file contains the path to
the RGB database file, which should never need to be changed, and the default
font path.  You may want to add more font paths: the <emphasis>FontPath</emphasis> lines in
your <emphasis>XF86Config</emphasis> are concatenated to form a search path.  Ensure that
each directory listed exists and is a valid font directory.
</para>

<para>The standard <emphasis>Files</emphasis> section looks like:
</para>
<programlisting>
Section "Files"

# The location of the RGB database.  Note, this is the name of the
# file minus the extension (like ".txt" or ".db").  There is normally
# no need to change the default.

    RgbPath	"/usr/X11R6/lib/X11/rgb"

# Multiple FontPath entries are allowed (which are concatenated together),
# as well as specifying multiple comma-separated entries in one FontPath
# command (or a combination of both methods)

    FontPath	"/usr/X11R6/lib/X11/fonts/misc/"
#    FontPath	"/usr/X11R6/lib/X11/fonts/Type1/"
#    FontPath	"/usr/X11R6/lib/X11/fonts/Speedo/"
#    FontPath	"/usr/X11R6/lib/X11/fonts/75dpi/"
#    FontPath	"/usr/X11R6/lib/X11/fonts/100dpi/"

EndSection
</programlisting>

<para>Sometimes the server complains about:
</para>
<programlisting>
Can't open default font 'fixed'
</programlisting>

<para><indexterm><primary>mkfontdir</primary><secondary>command</secondary></indexterm>
This is almost certainly the result of an invalid entry in your font path.  Try
running <emphasis>mkfontdir</emphasis> in each directory if you are certain that each one is
correct.  The <emphasis>XF86Config</emphasis> man page describes other parameters that may be
in this section of the file.
</para>
</sect2>
<sect2>
<title>The Keyboard section</title>

<para><anchor id="CFBSD-XF86Config-Keyboard-section"/>
<indexterm><primary>XF86Config</primary><secondary>Keyboard section</secondary></indexterm>
The <emphasis>Keyboard</emphasis> section specifies the keyboard protocol, the repeat rate, and
the default mapping of some of the modifier keys:
</para>
<programlisting>
Section "Keyboard"

    Protocol	"Standard"

# when using XQUEUE, comment out the above line, and uncomment the
# following line

#    Protocol	"Xqueue"

    AutoRepeat	500 5

# Let the server do the NumLock processing.  This should only be required
# when using pre-R6 clients
#    ServerNumLock

# Specifiy which keyboard LEDs can be user-controlled (eg, with xset(1))
#    Xleds      1 2 3

# To set the LeftAlt to Meta, RightAlt key to ModeShift,
# RightCtl key to Compose, and ScrollLock key to ModeLock:

#    LeftAlt     Meta
#    RightAlt    ModeShift
#    RightCtl    Compose
#    ScrollLock  ModeLock

EndSection
</programlisting>

<para>About the only thing you're likely to want to change are the definitions of the
modifier keys for non-English keyboards.  See the <emphasis>XF86Config(5)</emphasis> man page
for details.
</para>
</sect2>
<sect2>
<title>The Pointer section</title>

<para><anchor id="CFBSD-XF86Config-Pointer-section"/>
<indexterm><primary>XF86Config</primary><secondary>Pointer section</secondary></indexterm>
The <emphasis>Pointer</emphasis> section specifies the pointer protocol and device, which is
almost always a mouse.
</para>
<programlisting>
Section "Pointer"

    Protocol	"Microsoft"
    Device	"/dev/com1"

# When using XQUEUE, comment out the above two lines, and uncomment
# the following line.

#    Protocol	"Xqueue"

# Baudrate and SampleRate are only for some Logitech mice

#    BaudRate	9600
#    SampleRate	150

# Emulate3Buttons is an option for 2-button Microsoft mice
# Emulate3Timeout is the timeout in milliseconds (default is 50ms)

#    Emulate3Buttons
#    Emulate3Timeout	50

# ChordMiddle is an option for some 3-button Logitech mice

#    ChordMiddle

EndSection
</programlisting>

<para>These values are defaults, and many are either incorrect for FreeBSD (for
example the device name <emphasis>/dev/com1</emphasis>) or do not apply at all (for example
<emphasis>Xqueue</emphasis>).  If you are configuring manually, select one <emphasis>Protocol</emphasis>
and one <emphasis>Device</emphasis> entry from the following selection.  If you must use a
two-button mouse, uncomment the keyword <emphasis>Emulate3Buttons</emphasis>&mdash;in this mode,
pressing both mouse buttons simultaneously within <emphasis>Emulate3Timeout</emphasis>
milliseconds causes the server to report a middle button press.
</para>
<programlisting>
Section "Pointer"

    Protocol	"Microsoft"	<emphasis>for Microsoft protocol mice</emphasis>
    Protocol    "MouseMan"		<emphasis>for Logitech mice</emphasis>
    Protocol    "PS/2"		<emphasis>for a PS/2 mouse</emphasis>
    Protocol    "Busmouse"		<emphasis>for a bus mouse</emphasis>

    Device	"/dev/ttyd0"		<emphasis>for a mouse on the first serial port</emphasis>
    Device	"/dev/ttyd1"		<emphasis>for a mouse on the second serial port</emphasis>
    Device	"/dev/ttyd2"		<emphasis>for a mouse on the third serial port</emphasis>
    Device	"/dev/ttyd3"		<emphasis>for a mouse on the fourth serial port</emphasis>
    Device	"/dev/psm0"		<emphasis>for a PS/2 mouse</emphasis>
    Device	"/dev/mse0"		<emphasis>for a bus mouse</emphasis>

    Emulate3Buttons			<emphasis>only for a two-button mouse</emphasis>

EndSection
</programlisting>

<para>You'll notice that the protocol name does not always match the manufacturer's
name.  In particular, the <emphasis>Logitech</emphasis> protocol only applies to older
Logitech mice.  The newer ones use either the MouseMan or Microsoft protocols.
Nearly all modern serial mice run one of these two protocols, and most run both.
</para>

<para>If you are using a bus mouse or a PS/2 mouse, make sure that the device driver
is included in the kernel.  The <emphasis>GENERIC</emphasis> kernel contains drivers for both
mice, but the PS/2 driver is disabled.  Use UserConfig (see page <xref linkend="CFBSD-UserConfig"/>)
to enable it.
</para>
</sect2>
<sect2>
<title>The Device section</title>

<para><indexterm><primary>XF86Config</primary><secondary>Device section</secondary></indexterm>
<anchor id="CFBSD-XF86Config-Device-section"/>
The <emphasis>Device</emphasis> section describes the video hardware.  You can specify multiple
device sections, each section describing a single graphics board.  Here are some
typical examples:
</para>
<programlisting>
# Any number of graphics device sections may be present

Section "Device"
    Identifier	"Generic VGA"
    VendorName	"Unknown"
    BoardName	"Unknown"
    Chipset	"generic"
#    VideoRam	256
#    Clocks	25.2 28.3
EndSection

Section "Device"
    # SVGA server auto-detected chipset
    Identifier	"Generic SVGA"
    VendorName	"Unknown"
    BoardName	"Unknown"
EndSection

# Section "Device"
#    Identifier	"Any Trident TVGA 9000"
#    VendorName	"Trident"
#    BoardName	"TVGA 9000"
#    Chipset	"tvga9000"
#    VideoRam	512
#    Clocks	25 28 45 36 57 65 50 40 25 28 0 45 72 77 80 75
# EndSection

# Section "Device"
#    Identifier	"Actix GE32+ 2MB"
#    VendorName	"Actix"
#    BoardName	"GE32+"
#    Ramdac	"ATT20C490"
#    Dacspeed	110
#    Option	"dac_8_bit"
#    Clocks	 25.0  28.0  40.0   0.0  50.0  77.0  36.0  45.0
#    Clocks	130.0 120.0  80.0  31.0 110.0  65.0  75.0  94.0
# EndSection
</programlisting>

<para>Be sure to read the server manual pages and the chipset-specific <emphasis>README</emphasis>
files for any non-generic information that may apply to your setup.
</para>

<para>To create a <emphasis>Device</emphasis> section you need to collect the data for your hardware,
and make some configuration decisions.  The hardware data you need is:
</para>
<itemizedlist>
<listitem>

<para>Chipset
</para>
</listitem>
<listitem>

<para>Amount of video memory
</para>
</listitem>
<listitem>

<para>Dot-clocks available or clock chip used (if programmable)
</para>
</listitem>
<listitem>

<para>Ramdac type (for some servers)
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>XF86Config</primary><secondary>Chipset specification</secondary></indexterm>
The server can usually determine this information on its own, but it is best to
fully specify things in the <emphasis>XF86Config</emphasis> file, so that no mistakes are made.
The <emphasis>Chipset</emphasis> is one of the keyword strings for a configured driver&mdash;you
can display it with
</para>
<programlisting>
$ <command>X -showconfig</command>
XFree86 Version 3.3.3.1 / X Window System
(protocol Version 11, revision 0, vendor release 6300)
Release Date: December 29 1998
        If the server is older than 6-12 months, or if your card is newer
        than the above date, look for a newer version before reporting
        problems.  (see http://www.XFree86.Org/FAQ)
Operating System: FreeBSD 3.0-CURRENT i386 [ELF]
Configured drivers:
  SVGA: server for SVGA graphics adaptors (Patchlevel 0):
      NV1, STG2000, RIVA128, RIVATNT, ET4000, ET4000W32, ET4000W32i,
      ET4000W32i_rev_b, ET4000W32i_rev_c, ET4000W32p, ET4000W32p_rev_a,
      ET4000W32p_rev_b, ET4000W32p_rev_c, ET4000W32p_rev_d, ET6000, ET6100,
      et3000, pvga1, wd90c00, wd90c10, wd90c30, wd90c24, wd90c31, wd90c33,
      gvga, ati, sis86c201, sis86c202, sis86c205, sis86c215, sis86c225,
      sis5597, sis5598, sis6326, tvga8200lx, tvga8800cs, tvga8900b,
      tvga8900c, tvga8900cl, tvga8900d, tvga9000, tvga9000i, tvga9100b,
      tvga9200cxr, tgui9400cxi, tgui9420, tgui9420dgi, tgui9430dgi,
      tgui9440agi, cyber9320, tgui9660, tgui9680, tgui9682, tgui9685,
      cyber9382, cyber9385, cyber9388, cyber9397, cyber9520, 3dimage975,
      3dimage985, clgd5420, clgd5422, clgd5424, clgd5426, clgd5428,
      clgd5429, clgd5430, clgd5434, clgd5436, clgd5446, clgd5480, clgd5462,
      clgd5464, clgd5465, clgd6205, clgd6215, clgd6225, clgd6235, clgd7541,
      clgd7542, clgd7543, clgd7548, clgd7555, clgd7556, ncr77c22, ncr77c22e,
      cpq_avga, mga2064w, mga1064sg, mga2164w, mga2164w AGP, mgag200,
      mgag100, oti067, oti077, oti087, oti037c, al2101, ali2228, ali2301,
      ali2302, ali2308, ali2401, cl6410, cl6412, cl6420, cl6440, video7,
      ark1000vl, ark1000pv, ark2000pv, ark2000mt, mx, realtek, s3_virge,
      AP6422, AT24, AT3D, s3_svga, NM2070, NM2090, NM2093, NM2097, NM2160,
      NM2200, ct65520, ct65525, ct65530, ct65535, ct65540, ct65545, ct65546,
      ct65548, ct65550, ct65554, ct65555, ct68554, ct69000, ct64200,
      ct64300, mediagx, V1000, V2x00, p9100, spc8110, generic
</programlisting>

<para>Note that the operating system is reported as <emphasis>FreeBSD 3.0-CURRENT</emphasis>.  This
is the release of FreeBSD under which the server was built, not necessarily the
release for which it was intended.  In particular, it does not mean that it is
out of date, or that you have accidentally installed the wrong version.
</para>

<para>Only some of the accelerated servers currently have chipset drivers.  The amount
of memory is specified in KBytes, so you specify 1 MB of memory as 1024.
</para>

<para><indexterm><primary>devices</primary><secondary>XF86Config entry</secondary></indexterm>
<indexterm><primary>modeDB.txt</primary></indexterm>
<indexterm><primary>AccelCards</primary></indexterm>
The dot-clocks are the trickiest part of board configuration.  Fortunately a
large database of collected dot-clocks is available.  You can find a list of
Device entries for some graphics boards in the file
<emphasis>/usr/X11R6/lib/X11/doc/Devices</emphasis>.  If you find one for your board, you can
start with that.  Also, the first part of the file
<emphasis>/usr/X11R6/lib/X11/doc/modeDB.txt</emphasis> lists information for a myriad of SVGA
boards.  For accelerated boards, you can also look in the file
<emphasis>/usr/X11R6/lib/X11/doc/AccelCards</emphasis>.  If you find your board, copy the
numbers from the database to the Clocks line in your <emphasis>XF86Config</emphasis> file,
exactly as they appear in the database, without sorting, and leaving any
duplicates.  Note that some of the newer accelerated boards use a programmable
clock generator, in which case a ClockChip line is used in your
<emphasis>XF86Config</emphasis> file to identify the type of clock generator.  For example,
for a #9 GXe board you would specify
</para>
<programlisting>
ClockChip "icd2061a"
</programlisting>

<para></para>

<para>If you can't find a listing for your board, you can attempt to have the server
detect them.  Run the command:
</para>
<programlisting>
$ <command>X -probeonly &gt;/tmp/out 2&gt;&amp;1		<emphasis>for sh, ksh, bash, or zsh</emphasis></command>
% <command>X -probeonly &gt;&amp;/tmp/out			<emphasis>for csh or tcsh</emphasis></command>
</programlisting>

<para>Be sure that the <emphasis>XF86Config</emphasis> file does not contain a Clocks line at this
point.  Running this will cause your monitor to freak out for a couple of
seconds, as the server cycles through the clocks rapidly.  It should not damage
your monitor, but some newer monitors may shut themselves off because things may
go out of spec.  Anyhow, when this gets done, look in the file <emphasis>/tmp/out</emphasis>
for the detected dot-clocks.  Copy these to the Clocks line in your
<emphasis>XF86Config</emphasis> file, exactly as they appear in <emphasis>/tmp/out</emphasis>.  Don't sort
them or rearrange them in any way.
</para>

<para>Your board may have a programmable clock generator.  A symptom of this will be a
printout of only 2 or 3 clock values, with the rest all zeros.  If you run into
this, and your board is not listed in the databases, contact the XFree86 team
for help, or post a message to <emphasis>comp.windows.x.i386unix</emphasis>.
</para>

<para>Some servers (S3 and AGX) require you to identify the type and speed of the
RAMDAC your board uses in order to get the most out of the hardware.  This is
done by adding entries <emphasis>Ramdac</emphasis> and <emphasis>DacSpec</emphasis>.  For details of the
supported RAMDACs, refer to the appropriate server manual page.  Previous
versions of XFree86 specified the RAMDAC type with an Option flag.
</para>

<para>You may need to specify some option flags for your hardware.  The server manual
pages will describe these options, and the chipset-specific <emphasis>README</emphasis> files
will tell you if any are required for your board.
</para>
</sect2>
<sect2>
<title>Configuring the Monitor and its Modes</title>

<para><indexterm><primary>VideoModes.doc</primary></indexterm>
Configuring monitor modes can be a trying experience because of the lack of
standardization in monitor hardware.  The XFree86 project has attempted to
simplify this by collecting databases of specific monitor information, and
assembling a set of generic modes that should get pretty much any monitor up and
functional.  For all the gory details of mode generation and tuning, refer to
the file <emphasis>/usr/X11R6/lib/X11/doc/VideoModes.doc</emphasis>.
</para>
</sect2>
<sect2>
<title>The Monitor section</title>

<para><anchor id="CFBSD-XF86Config-Monitor-section"/>
<indexterm><primary>XF86Config</primary><secondary>Monitor section</secondary></indexterm>
<indexterm><primary>Monitors</primary><secondary>documentation</secondary></indexterm>
The monitor specs and video modes are described in the <emphasis>Monitor</emphasis> sections in
the <emphasis>XF86Config</emphasis> file:
</para>
<programlisting>
# Any number of monitor sections may be present

Section "Monitor"

    Identifier	"Generic Monitor"
    VendorName	"Unknown"
    ModelName	"Unknown"

# HorizSync is in kHz unless units are specified.
# HorizSync may be a comma separated list of discrete values, or a
# comma separated list of ranges of values.
# NOTE: THE VALUES HERE ARE EXAMPLES ONLY.  REFER TO YOUR MONITOR'S
# USER MANUAL FOR THE CORRECT NUMBERS.

    HorizSync   31.5  # typical for a single frequency fixed-sync monitor

#    HorizSync	30-64         # multisync
#    HorizSync	31.5, 35.2    # multiple fixed sync frequencies
#    HorizSync	15-25, 30-50  # multiple ranges of sync frequencies

# VertRefresh is in Hz unless units are specified.
# VertRefresh may be a comma separated list of discrete values, or a
# comma separated list of ranges of values.
# NOTE: THE VALUES HERE ARE EXAMPLES ONLY.  REFER TO YOUR MONITOR'S
# USER MANUAL FOR THE CORRECT NUMBERS.

    VertRefresh 60  # typical for a single frequency fixed-sync monitor

#    VertRefresh	50-100        # multisync
#    VertRefresh	60, 65        # multiple fixed sync frequencies
#    VertRefresh	40-50, 80-100 # multiple ranges of sync frequencies

# Modes can be specified in two formats.  A compact one-line format, or
# a multi-line format.

# A generic VGA 640x480 mode (hsync = 31.5kHz, refresh = 60Hz)
# These two are equivalent

#    ModeLine "640x480" 25.175 640 664 760 800 480 491 493 525

    Mode "640x480"
        DotClock	25.175
        HTimings	640 664 760 800
        VTimings	480 491 493 525
    EndMode

# These two are equivalent

#    ModeLine "1024x768i" 45 1024 1048 1208 1264 768 776 784 817 Interlace

#    Mode "1024x768i"
#        DotClock	45
#        HTimings	1024 1048 1208 1264
#        VTimings	768 776 784 817
#        Flags		"Interlace"
#    EndMode

EndSection
</programlisting>

<para>To create a Monitor section, you need to know your monitor's specifications, in
particular its video bandwidth and what range of horizontal sync and vertical
sync rates it supports.  If you can't find this information in the monitor's
user manual, check the file <emphasis>/usr/X11R6/lib/X11/doc/Monitors</emphasis> to see if it
has an entry for your monitor.  The <emphasis>XF86Config</emphasis> man page describes how to
enter this information into the Monitor section.
</para>

<para>Next, you need to provide a set of video modes that are suitable for the
monitor.  The first step is to check in the <emphasis>Monitors</emphasis> and <emphasis>modeDB.txt</emphasis>
files to see if there is a listing of modes for your specific monitor.  If there
is, copy those modes to the Monitor section of your <emphasis>XF86Config</emphasis> file.
Verify that there is a clock listed on the Clocks line in your <emphasis>XF86Config</emphasis>
that matches the dot clock in the 2nd parameter of each mode line; delete any
mode line that does not have a matching clock on your board.  If you still have
modes left, you are in good shape.
</para>

<para>If you don't find any specific modes, or need more modes for the resolutions you
want to use, refer to the Generic Video Modes listing in the file
<emphasis>/usr/X11R6/lib/X11/doc/README.Config</emphasis>.  Match the mode specification
against your monitor's specifications; pick the highest-refresh mode that is
within specs, and make sure you have a matching dot-clock on your Clocks line.
Try the VESA modes before any corresponding alternate mode setting.  Copy the
mode specification to the Monitor section of your <emphasis>XF86Config</emphasis> file.  Note
that these modes are likely not optimal; they may not be sized perfectly, or may
not be correctly centered.  But they should get you up and running.  If you want
to tune the mode to your monitor, you can read the section <emphasis>Fixing Problems
with the Image</emphasis> in <emphasis>VideoModes.doc</emphasis>.
</para>

<para>A note before you are done.  If the same mode name occurs more than once in the
Monitor section of the <emphasis>XF86Config</emphasis> file, the server will use the first mode
with a matching clock.  It is generally considered a bad idea to have more than
one mode with the same name in your <emphasis>XF86Config</emphasis> file.
</para>
</sect2>
<sect2>
<title>The Screen section</title>

<para><anchor id="CFBSD-XF86Config-Screen-section"/>
<indexterm><primary>XF86Config</primary><secondary>Screen section</secondary></indexterm>
Once you have given a description of your monitor and graphics hardware you need
to specify how they are to be used by the servers.  This is the purpose of the
<emphasis>Screen</emphasis> sections in the <emphasis>XF86Config</emphasis> file:
</para>
<programlisting>
# The colour SVGA server
Section "Screen"
    Driver	"svga"
    Device	"Generic SVGA"
    Monitor	"Generic Monitor"
    Subsection "Display"
        Depth	    8
        Modes	    "640x480"
        ViewPort    0 0
        Virtual     800 600
    EndSubsection
EndSection

# The 16-colour VGA server
Section "Screen"
    Driver	"vga16"
    Device	"Generic VGA"
    Monitor	"Generic Monitor"
    Subsection "Display"
        Modes	    "640x480"
        ViewPort    0 0
        Virtual     800 600
    EndSubsection
EndSection

# The Mono server
Section "Screen"
    Driver	"vga2"
    Device	"Generic VGA"
    Monitor	"Generic Monitor"
    Subsection "Display"
        Modes	    "640x480"
        ViewPort    0 0
        Virtual     800 600
    EndSubsection
EndSection

# The accelerated servers (S3, Mach32, Mach8, 8514, P9000, AGX, W32)
# Section "Screen"
#     Driver	"accel"
#     Device	"Actix GE32+ 2MB"
#     Monitor	"Generic Monitor"
#     Subsection  "Display"
#         Depth	    8
#         Modes	    "640x480"
#         ViewPort    0 0
#         Virtual	    1280 1024
#     EndSubsection
#     SubSection "Display"
#         Depth	    16
#         Weight	    565
#         Modes	    "640x480"
#         ViewPort    0 0
#         Virtual	    1024 768
#     EndSubsection
# EndSection
</programlisting>

<para>Supply a Screen section for each of the server driver types you will be using.
The driver types are <emphasis>SVGA</emphasis> (<emphasis>XF86_SVGA</emphasis>), <emphasis>VGA16</emphasis>
(<emphasis>XF86_VGA16</emphasis>), <emphasis>VGA2</emphasis> (<emphasis>XF86_Mono</emphasis>), <emphasis>MONO</emphasis>
(<emphasis>XF86_Mono</emphasis>, <emphasis>XF86_VGA16</emphasis>), and <emphasis>ACCEL</emphasis> (<emphasis>XF86_S3</emphasis>,
<emphasis>XF86_Mach32</emphasis>, <emphasis>XF86_Mach8</emphasis>, <emphasis>XF86_Mach64</emphasis>, <emphasis>XF86_8514</emphasis>,
<emphasis>XF86_P9000</emphasis>, <emphasis>XF86_AGX</emphasis>, and <emphasis>XF86_W32</emphasis>).  Each Screen section
specifies which Monitor description and Device description are to be used.
</para>

<para>The Screen sections include one or more <emphasis>Display</emphasis> subsections.  One
Display subsection may be provided for each pixel depth (the number of bits per
pixel) that the server supports.  In the Display subsection you can specify the
size of the virtual screen the server will use.  The virtual screen allows you
to have a <emphasis>root window</emphasis> larger than can be displayed on your monitor.  For
example, you can have an 800x600 display, but a 1280x1024 virtual size.  Use the
keyword <emphasis>Virtual</emphasis> to specify this size.  Note that many of the new
accelerated servers use non-displayed memory for caching.  It is not desirable
to use all of your memory for virtual display, as this leaves none for caching,
and this can cost as much as 30-40% of your server performance.
</para>

<para>The last thing you specify in Display subsection are the display modes, the
physical display resolutions that the server will use.  The name is arbitrary,
but must match something in the appropriate <emphasis>Monitor</emphasis> section.  By
convention, these names are the display resolution (for example
<emphasis>1024x768</emphasis>), but this is not a requirement.  You can list as many as
desired; the first is the initial display resolution, and you can cycle through
the list with <keycap>Ctrl-Alt-Keypad+</keycap> or <keycap>Ctrl-Alt-Keypad-</keycap> hotkey sequences.
</para>
</sect2>
</sect1>
</chapter>
<!--  This file is in -*- sgml-fill -*- mode -->
<!--  STATUS: 3rd edition -->
<!--  $Id: sample.sgml,v 1.1.1.1 2001/12/16 00:34:09 root Exp $ -->
<!--  -->
<chapter id="CFBSD-nchunixref"><title>Making friends with FreeBSD</title>

<para>So now you have installed FreeBSD, and it successfully boots from the hard disk.
Your first encounter with FreeBSD can be rather puzzling.  Sure, you didn't
expect to see the same things you know from Microsoft platforms, but you might
not have expected what you see either:
<anchor id="CFBSD-login-prompt"/>
</para>
<programlisting>
   FreeBSD (freebie.example.org) (ttyv0)

login:
</programlisting>

<para>Where do you go from here?  This chapter tells you.
</para>

<para><indexterm><primary>Abrahams</primary><secondary>Paul W.</secondary></indexterm>
<indexterm><primary>Larson</primary><secondary>Bruce R.</secondary></indexterm>
<indexterm><primary>Peek</primary><secondary>Jerry</secondary></indexterm>
<indexterm><primary>O'Reilly</primary><secondary>Tim</secondary></indexterm>
<indexterm><primary>Loukides</primary><secondary>Mike</secondary></indexterm>
<indexterm><primary>Nemeth</primary><secondary>Evi</secondary></indexterm>
<indexterm><primary>Snyder</primary><secondary>Garth</secondary></indexterm>
<indexterm><primary>Seebass</primary><secondary>Scott</secondary></indexterm>
<indexterm><primary>Hein</primary><secondary>Trent R.</secondary></indexterm>
FreeBSD is a very powerful operating system, but power doesn't come without a
certain complexity.  As a result, that some mundane operations can seem more
difficult than they need be.  There isn't space in this book to explain
everything there is about working with FreeBSD, but in the following few
chapters I'd like to make the transition easier for people who have prior
experience with Microsoft platforms or with other flavours of UNIX.  You can
find a lot more information about these topics in <emphasis>UNIX for the
Impatient</emphasis>, by Paul W. Abrahams and Bruce R. Larson, <emphasis>UNIX Power Tools</emphasis>,
by Jerry Peek, Tim O'Reilly, and Mike Loukides, and <emphasis>UNIX System
Administration Handbook</emphasis>, by Evi Nemeth, Garth Snyder, Scott Seebass, and
Trent R. Hein.  See <xref linkend="CFBSD-biblio"/>, for more information.
</para>

<para>If you've come from Microsoft, you will notice a large number of differences
between UNIX and Microsoft, but in fact the two systems have more in common than
meets the eye.  Indeed, back in the mid-80s, one of the stated goals of MS-DOS
2.0 was to make it more UNIX-like.  You be the judge of how successful that
attempt was, but in the following sections you'll notice some similarities.
You'll find a comparison of the more common MS-DOS and UNIX commands in
<xref linkend="CFBSD-appcommands"/>.
</para>

<para>In this chapter, we'll look at FreeBSD from the perspective of a newcomer with
no UNIX background.  If you <emphasis>do</emphasis> have a UNIX background, you may still
find it interesting.  Specifically, we'll consider:
</para>
<itemizedlist>
<listitem>

<para>Your primary interface with FreeBSD is via the <emphasis>shell</emphasis>.  This looks rather
like the command-line interface to Microsoft's MS-DOS, but there are a number of
differences which aren't immediately obvious.  We'll look at them in the next
section.
</para>
</listitem>
<listitem>

<para>UNIX is a multi-user operating system.  This means that you have to tell the
system who you are before you can access it.  On page <xref linkend="CFBSD-users-and-groups"/> we'll
look at how to define users.
</para>
</listitem>
<listitem>

<para>Once you have defined a user, you need to log in to the system and tell it what
to do.  We'll look at that on page
</para>
</listitem>
<listitem>

<para>Not all users are created equal.  In particular, the system administration login
<emphasis>root</emphasis> has power over all other users.  We'll look at this topic on page
</para>
</listitem>
<listitem>

<para>UNIX implements multi-tasking via a mechanism called <emphasis>processes</emphasis>.  We'll
look at them on page <xref linkend="CFBSD-processes"/>.
</para>
</listitem>
<listitem>

<para>Timekeeping is extremely important in a networking system.  If your system has
the wrong time, it can cause all sorts of strange effects.  On page
<xref linkend="CFBSD-timekeeping"/> we'll look at how to ensure that your system is running the
correct time.
</para>
</listitem>
<listitem>

<para>Other aspects of FreeBSD are so extensive that we'll dedicate separate chapters
to them.  We'll look at them in <xref linkend="CFBSD-chstarting"/>, <xref linkend="CFBSD-chfilesys"/>, <xref linkend="CFBSD-chdisks"/>, and
<xref linkend="CFBSD-chtapes"/>.  In particular, on page <xref linkend="CFBSD-vt"/> we'll see how to access multiple
``terminals'' or windows.
</para>
</listitem>
</itemizedlist>

<para></para>
<sect1>
<title>Differences from other environments</title>

<para><indexterm><primary>Differences</primary><secondary>from other environments</secondary></indexterm>
At first sight, UNIX can look really arcane.  People often get really frustrated
when working with the shell: it just doesn't seem to do what you want, and
there's no good reason.
</para>

<para>Well, of course there's always a good reason, but they are often so non-obvious
that even experienced programmers find it hard to believe.  Here are some of the
most popular, seen from a Microsoft perspective:
</para>
<sect2>
<title>Upper and lower case names</title>

<para><indexterm><primary>File</primary><secondary>names</secondary></indexterm>
UNIX file names are <emphasis>case-sensitive</emphasis>: the names <emphasis>FOO</emphasis>, <emphasis>Foo</emphasis> and
<emphasis>foo</emphasis> are three different names.  This may seem silly at first, but any
alternative is going to make things slower (the system must internally upshift
or downshift the names), and it means that the names must be associated with a
specific character set.  How do you upshift the German name <emphasis>Blödsinn</emphasis>?
What if the same characters appear in a Chinese name?  Do they still shift the
same?  In fact, all characters are legal in a UNIX file name, with one
exception: <emphasis>/</emphasis> is a separator which indicates a directory, and you can't
use it in a file name.  Still, there are some characters you should avoid:
spaces are a pain, as we'll see below, and binary 0s (the ASCII <emphasis>NUL</emphasis>
character) can confuse a lot of programs.  It's almost impossible to get a
binary 0 into a file name anyway, since the character is used to represent the
end of a string in the C programming language.
</para>

<para>This isn't the problem it used to be: web browsers have made UNIX file names
more popular with <emphasis>Uniform Resource Locators</emphasis> or <emphasis>URLs</emphasis>.  We'll look
at them on page <xref linkend="CFBSD-URL"/>.
</para>
</sect2>
<sect2>
<title>File names and extensions</title>

<para>The Microsoft naming convention (name, period and extension) is similar to that
of UNIX.  UNIX also uses extensions to represent specific kinds of files.  The
difference is that these extensions (and their lengths) are implemented by
convention, not by the file system.  In Microsoft, the period between the name
and the extension is a typographical feature which only exists at the display
level: it's not part of the name.  In UNIX, the period is part of the name, and
names like <emphasis>foo.bar.bazzot</emphasis> are perfectly valid file names.  The system
doesn't assign any particular meaning to file name extensions; instead, it looks
for <emphasis>magic numbers</emphasis>, specific values in specific places in the file.
</para>
</sect2>
<sect2>
<title>Globbing characters</title>

<para><indexterm><primary>globbing</primary><secondary>characters</secondary></indexterm>
<indexterm><primary>characters</primary><secondary>globbing</secondary></indexterm>
Most systems have a method of representing groups of filenames and other names,
usually by using special characters for representing an abstraction.  The most
common in UNIX are the characters <emphasis>*</emphasis>, <emphasis>?</emphasis> and the square brackets
<emphasis>[]</emphasis>.  UNIX calls these characters <emphasis>globbing characters</emphasis>.  The
Microsoft usage comes from UNIX, but the underlying file name representation
makes for big differences.  Table <xref linkend="CFBSD-globbing-example"/> gives some examples.
box,center,tab(#) ;
lfCWp9 | lw32 | lw32 .
Name#Microsoft meaning#UNIX meaning
=
CONFIG.*#T{
All files with the name <emphasis>CONFIG</emphasis>, no matter what their extension.
T}#T{
All files whose name starts with <emphasis>CONFIG.</emphasis>, no matter what the rest is.
Note that the name includes a period at the end.
T}
CONFIG.BA?#T{
All files with the name <emphasis>CONFIG</emphasis> and an extension which starts with
<emphasis>BA</emphasis>, no matter what the last character.
T}#T{
All files which start with <emphasis>CONFIG.BA</emphasis> and have one more character in their
name.
T}
*#T{
Depending on the Microsoft version, all files without an extension, or all
files.
T}#T{
All files.
T}
*.*#T{
All files with an extension.
T}#T{
All files which have a period after the beginning of their name.
T}
foo[127]#T{
In older versions, invalid.  In newer versions with long file name support, the
file with the name <emphasis>foo[127]</emphasis>.
T}#T{
<emphasis>foo1</emphasis>, <emphasis>foo2</emphasis> and <emphasis>foo7</emphasis>.
T}

</tbody></tgroup></table>
<figure><title>Globbing examples</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
</para>
</sect2>
<sect2>
<title>Shell parameters</title>

<para><indexterm><primary>Shell</primary><secondary>parameters</secondary></indexterm>
<indexterm><primary>parameters</primary><secondary>shell</secondary></indexterm>
<indexterm><primary>parsing</primary></indexterm>
<indexterm><primary>argument</primary><secondary>shell</secondary></indexterm>
<indexterm><primary>white</primary><secondary>space</secondary></indexterm>
<indexterm><primary>space</primary><secondary>white</secondary></indexterm>
When you invoke a program with the shell, it first <emphasis>parses</emphasis> the input line
before passing it to the program: it turns the line into a number of parameters
(called <emphasis>arguments</emphasis> in the C programming language).  Normally the
parameters are separated by <emphasis>white space</emphasis>, either a space or a tab
character.  If you write a program or script <emphasis>foo</emphasis>, and invoke it like this:
</para>
<programlisting>
$ <command>foo and a lot more</command>
</programlisting>

<para>the program will receive five arguments, numbered 0 to 4:
box,center,tab(#) ;
rfCWp9 | lw65 .
\s10Argument#Value
=
0#foo
1#and
2#a
3#lot
4#more

</tbody></tgroup></table>
What happens if you want to pass a name with a space?  For example, you might
want to look for the text ``<emphasis>Mail rejected</emphasis>'' in a log file.  We have a
program for looking for text, called <emphasis>grep</emphasis>.  The syntax is:
</para>
<programlisting>
grep <emphasis>expression</emphasis> <emphasis>files</emphasis>
</programlisting>

<para>Argument 1 is the expression; all additional arguments are the names of files to
search.  We could write
</para>
<programlisting>
$ <command>grep Mail rejected /var/log/maillog</command>
</programlisting>

<para>but that would try to look for the text <emphasis>Mail</emphasis> in the files
<emphasis>rejected</emphasis> (probably causing an error message that the file did not exist)
and <emphasis>/var/log/maillog</emphasis> (where just about every line contains the text
<emphasis>Mail</emphasis>).  That's  not what we want.  Instead, we do pretty much what I
wrote above:
</para>
<programlisting>
$ <command>grep "Mail rejected" /var/log/maillog</command>
</programlisting>

<para>In other words, if we put quote characters <command>""</command> around a group of words,
the shell will interpret them as a single parameter.  The parameter that is
passed to <emphasis>grep</emphasis> is <emphasis>Mail rejected</emphasis>, not <emphasis>"Mail rejected"</emphasis>.
</para>

<para>This behaviour of the shell is a very good reason not to use file names with
spaces in them.  It's perfectly legitimate to embed spaces into UNIX file names,
but it's a pain to use.
</para>

<para>It's even more interesting to see what happens when you pass a globbing
character to a program, for example:
</para>
<programlisting>
$ <command>cc -o foo *.c</command>
</programlisting>

<para>This invocation compiles all C source files (<emphasis>*.c</emphasis>) and creates a program
<emphasis>foo</emphasis>.  If you do this with Microsoft, the C compiler gets four parameters,
and it has to find the C source files itself.  In UNIX, the shell expands the
text <emphasis>*.c</emphasis> and replaces it with the names of the source files.  If there
are thirty source files in the directory, it will pass a total of 33 parameters
to the compiler.
</para>
</sect2>
<sect2>
<title>Fields which can contain spaces</title>

<para>The solution to the ``Mail rejected'' problem isn't ideal, but it works well
enough as long as you don't have to do it all the time.  In many cases, though,
particularly in configuration files, you do have to do it relatively often.  As
a result, a number of system configuration files use a colon (<emphasis>:</emphasis>) as a
delimiter.  This looks very confusing at first, but it turns out not to be as
bad as the alternatives.  We'll see some examples in the password file on page
<xref linkend="CFBSD-master-passwd"/>, in the login class file on page <xref linkend="CFBSD-login-class"/>, and in the
<emphasis>PATH</emphasis> environment variable on page <xref linkend="CFBSD-PATH"/>.
</para>
</sect2>
<sect2>
<title>Slashes: backward and forward</title>

<para><indexterm><primary>root</primary><secondary>directory</secondary></indexterm>
<indexterm><primary>slash</primary><secondary>character</secondary></indexterm>
<indexterm><primary>escape</primary><secondary>character</secondary></indexterm>
<indexterm><primary>character</primary><secondary>slash</secondary></indexterm>
<indexterm><primary>character</primary><secondary>escape</secondary></indexterm>
<anchor id="CFBSD-slash"/>
Some of the most confusing characters in computers are <emphasis>/</emphasis> and <emphasis>\e</emphasis>.
UNIX uses <emphasis>/</emphasis> to delimit directories: for example, <emphasis>/etc/fstab</emphasis>
starts from the <emphasis>root directory</emphasis> (<emphasis>/</emphasis>), and represents the directory
<emphasis>etc</emphasis> inside this directory, and the file <emphasis>fstab</emphasis> within that
directory.  The backslash <emphasis>\e</emphasis> is called an <emphasis>escape character</emphasis> it
has a number of different purposes:
</para>
<itemizedlist>
<listitem>

<para>You can put it in front of another special character to say ``don't interpret
this character in any special way''.  For example, we've seen that the shell
interprets a space character as the end of a parameter.  In the previous example
we changed <emphasis>Mail rejected</emphasis> to <emphasis>"Mail rejected"</emphasis> to stop the shell
from interpreting it.  We could also have written it like this:
<emphasis>Mail\e\ rejected</emphasis>.
</para>

<para><indexterm><primary>quoting</primary></indexterm>
A more common use for this <emphasis>quoting</emphasis> is to tell the shell to ignore the
end of a line.  If a command line in a shell script gets too long, you might
like to split it up into several lines; but the shell sees the end of a line as
a go-ahead to perform the command.  You can stop it from doing so by putting a
backslash <emphasis>immediately</emphasis> before the end of the line:
</para>
<programlisting>
$ <command>grep \e
  "Mail rejected" \e
   /var/log/maillog</command>
</programlisting>

<para>Don't put any spaces between the <emphasis>\e</emphasis> and the end of the line; otherwise
the shell will interpret the first space as a parameter by itself, and then it
will interpret the end of line as the end of the command.
</para>
</listitem>
<listitem>

<para><indexterm><primary>control</primary><secondary>characters</secondary></indexterm>
<indexterm><primary>character</primary><secondary>control</secondary></indexterm>
In the C programming language, the backslash is used to represent several
<emphasis>control characters</emphasis>.  For example, <emphasis>\en</emphasis> means ``new line''.  This
usage appears in many other places as well.
</para>
</listitem>
<listitem>

<para>Using <emphasis>\e</emphasis> as an escape character causes problems: how do we put a
<emphasis>\e</emphasis> character on a line?  The answer: quote it.  Write <emphasis>\e\e</emphasis> when
you mean <emphasis>\e</emphasis>.  This causes particular problems when interfacing with
Microsoft&mdash;see page <xref linkend="CFBSD-multibackslash"/> for an example.
</para>
</listitem>
</itemizedlist>

<para>There are many more such surprises in store; take a look at <emphasis>UNIX Power
Tools</emphasis> for a good overview.
</para>
</sect2>
<sect2>
<title>Tab characters</title>

<para><indexterm><primary>Tab</primary><secondary>characters</secondary></indexterm>
<indexterm><primary>character</primary><secondary>tab</secondary></indexterm>
<indexterm><primary>make</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>make</secondary></indexterm>
<indexterm><primary>sendmail</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>sendmail</secondary></indexterm>
<indexterm><primary>syslogd</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>syslogd</secondary></indexterm>
We've seen that the shell treats white space, either spaces or tab characters,
as the same.  Unfortunately, some other programs do not.  <emphasis>make</emphasis>,
<emphasis>sendmail</emphasis> and <emphasis>syslogd</emphasis> make a distinction between the two kinds of
characters, and they all require tabs (not spaces) in certain places.  This is a
<emphasis>real</emphasis> nuisance, since hardly any editor makes a distinction between them.
</para>
</sect2>
<sect2>
<title>Carriage control characters</title>

<para><indexterm><primary>Carriage</primary><secondary>Return character</secondary></indexterm>
<indexterm><primary>Line</primary><secondary>Feed character</secondary></indexterm>
<indexterm><primary>character</primary><secondary>carriage return</secondary></indexterm>
<indexterm><primary>character</primary><secondary>line feed</secondary></indexterm>
In the olden days, the standard computer terminal was a Teletype, a kind of
computer-controlled electric typewriter.  When it got to the end of a line, it
required two mechanical operations to move to the beginning of the next line: the
<emphasis>Carriage Return</emphasis> control character told it to move the carriage back to
the beginning of the line, and the <emphasis>Line Feed</emphasis> character told it to move
to the next line.
</para>

<para><indexterm><primary>Newline</primary><secondary>character</secondary></indexterm>
<indexterm><primary>character</primary><secondary>newline</secondary></indexterm>
Generations of computer systems emulated this behaviour by putting both
characters at the end of each text line.  This makes it more difficult to
recognize the end of line, it uses up more storage space, and normally it
doesn't buy you much.  The implementors of UNIX decided instead to use a single
character, which it calls the <emphasis>Newline</emphasis> character.  For some reason, they
chose the line feed to represent newline, though the character generated by
<keycap>Enter</keycap> is a carriage return.  As we saw above, the C programming language
represents it as <emphasis>\en</emphasis>.
</para>

<para>This causes problems transferring data between FreeBSD and Microsoft, and also
when printing to printers which still expect both characters.  We'll look at the
file transfer issues on page <xref linkend="CFBSD-Microsoft-staircase"/>, and the printer issues on
page <xref linkend="CFBSD-staircase"/>.
</para>
</sect2>
</sect1>
<sect1>
<title>Users and groups</title>

<para><indexterm><primary>users</primary><secondary>and groups</secondary></indexterm>
<anchor id="CFBSD-users-and-groups"/>
Probably the biggest difference between traditional Microsoft platforms and
FreeBSD also takes the longest to appreciate: FreeBSD is a multi-user,
multi-tasking system.  This means that many people can use the system at once,
and each of them can do several things at the same time.  You may think ``why
would I want to do that?''.  Once you've got used to this idea, though, you'll
never be satisfied with Microsoft again, even if you were in the first place.
If you use the X window system, you'll find that all windows can be active at
the same time&mdash;you don't have to select them.  You can monitor some activity
in the background in another window while writing a letter, testing a program,
or playing a game.
</para>

<para><indexterm><primary>user</primary></indexterm>
In order to access a FreeBSD system, you must be registered as a <emphasis>user</emphasis>.
The registration defines a number of parameters:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>user</primary><secondary>name</secondary></indexterm>
<indexterm><primary>user</primary><secondary>ID</secondary></indexterm>
A <emphasis>user name</emphasis>, also often called <emphasis>user ID</emphasis>.  This is a name which you
use to identify yourself to the system.
</para>
</listitem>
<listitem>

<para><anchor id="CFBSD-password"/>
<indexterm><primary>password</primary></indexterm>
A <emphasis>password</emphasis>, a security device to ensure that other people don't abuse your
user ID.  In order to log in, you need to specify both your user ID and the
correct password.  When you type in the password, nothing appears on the screen,
so that people looking over your shoulder can't read it.
</para>

<para>It may seem strange to go to such security measures on a system which you alone
use, but if you connect to the Internet, even via PPP or SLIP, other people can
at least theoretically access your system while you are connected.  If you don't
connect to the Internet, you can get away without a password, but you can't get
away without a user ID.
</para>
</listitem>
<listitem>

<para><anchor id="CFBSD-shell"/>
<indexterm><primary>shell</primary></indexterm>
<indexterm><primary>COMMAND.COM</primary></indexterm>
<indexterm><primary>sh</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>sh</secondary></indexterm>
<indexterm><primary>csh</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>csh</secondary></indexterm>
<indexterm><primary>bash</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>bash</secondary></indexterm>
<indexterm><primary>tcsh</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>tcsh</secondary></indexterm>
<indexterm><primary>zsh</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>zsh</secondary></indexterm>
<indexterm><primary>COMMAND.COM</primary></indexterm>
A <emphasis>shell</emphasis>, a program which reads in your commands and executes them.  MS-DOS
uses the program <emphasis>COMMAND.COM</emphasis> to perform this function.  UNIX has a large
choice of shells: the traditional UNIX shells are the Bourne shell <emphasis>sh</emphasis>
and the C shell <emphasis>csh</emphasis>, but FreeBSD also supplies <emphasis>bash</emphasis>, <emphasis>tcsh</emphasis>,
<emphasis>zsh</emphasis> and others.  The UNIX shells are orders of magnitude more powerful
than <emphasis>COMMAND.COM</emphasis>&mdash;see <emphasis>UNIX Power Tools</emphasis> for a good discussion.  I
personally use the <emphasis>bash</emphasis> shell.
</para>
</listitem>
<listitem>

<para><anchor id="CFBSD-home-directory"/>
<indexterm><primary>home</primary><secondary>directory</secondary></indexterm>
<indexterm><primary>directory</primary><secondary>home</secondary></indexterm>
A <emphasis>home directory</emphasis>.  Since the system can have multiple users, each one
needs a separate directory in which to store his private files.  Typically,
users have a directory <emphasis>/home/<emphasis>username</emphasis></emphasis>, where <emphasis>username</emphasis> is
the name they use to log in.  When you log in to the system, the shell sets the
current directory to your home directory.  In it, you can do what you want, and
normally it is protected from access by other users.  Many shells, including the
<emphasis>bash</emphasis> used in these examples, use the special notation <emphasis>~</emphasis> (tilde)
to represent the name of the home directory.
</para>
</listitem>
<listitem>

<para><indexterm><primary>group</primary></indexterm>
<anchor id="CFBSD-group"/>
A <emphasis>group</emphasis> number.  UNIX collects users into <emphasis>groups</emphasis> who have
specific access permissions.  When you add a user, you need to make him a member
of a specific group, which is entered in the password information.  Your group
number indirectly helps determine what you are allowed to do in the system.  As
we'll see on page <xref linkend="CFBSD-permissions"/>, your user and group determine what access you
have to the system.  You can belong to more than one group.
</para>

<para><indexterm><primary>/etc/group</primary></indexterm>
Group numbers generally have names associated with them.  The group names and
numbers are stored in the file <emphasis>/etc/group</emphasis>.  In addition, this file may
contain userids of users who belong to another group, but who are allowed to
belong to this group as well.
</para>

<para>If you find the concept of groups confusing, don't worry about them.  You can
get by quite happily without using them at all.  You'll just see references to
them when we come to discuss file permissions.  For further information, look at
the man page for <emphasis>group(5)</emphasis>.
</para>
</listitem>
</itemizedlist>

<para></para>

<para>In addition to ``real'' users, who represent people, the system has a number of
pseudo-users who represent tasks performed by the system.  Don't remove them, or
you could run into problems.
</para>

<para><indexterm><primary>/etc/passwd</primary></indexterm>
<indexterm><primary>/etc/master.passwd</primary></indexterm>
<indexterm><primary>/etc/pwd.db</primary></indexterm>
<indexterm><primary>/etc/spwd.db</primary></indexterm>
<anchor id="CFBSD-master-passwd"/>
The list of users is kept in the file <emphasis>/etc/passwd</emphasis>.  In older UNIX systems,
this was the only file used to store user information, and the passwords were
also stored here in encrypted form.  Nowadays processors are much faster, and
it's too easy to crack a password.  As a result, FreeBSD keeps the real
information in a file called <emphasis>/etc/master.passwd</emphasis>, and for performance
reasons it also makes it available in database form in <emphasis>/etc/pwd.db</emphasis> and
<emphasis>/etc/spwd.db</emphasis>.  <emphasis>/etc/passwd</emphasis> remains for compatibility reasons: some
programs access it directly to get information about the environment in which
they are running.
</para>

<para>By default, there are no real users on a freshly installed system.  Optionally,
<emphasis>sysinstall</emphasis> will do it for you, but there's no particular reason to do it
during system installation.  In the next section, we'll look at two ways to add
and modify users.
</para>
<sect2>
<title>Choosing a user name</title>

<para><indexterm><primary>user</primary><secondary>name</secondary></indexterm>
<indexterm><primary>choosing</primary><secondary>a user name</secondary></indexterm>
<anchor id="CFBSD-logging-in"/>
<indexterm><primary>logging</primary><secondary>in</secondary></indexterm>
So what user name do you choose?  User names are usually related to your real
name and can be up to 8 characters long.  By convention, they are in all lower
case, even when they represent real names.  Typical ways to form a user name
are:
</para>
<itemizedlist>
<listitem>

<para>First name.  In my personal case, this would be <emphasis>greg</emphasis>.
</para>
</listitem>
<listitem>

<para>Last name (<emphasis>lehey</emphasis>).
</para>
</listitem>
<listitem>

<para>First name and initial of last name (<emphasis>gregl</emphasis>).
</para>
</listitem>
<listitem>

<para>Inital of first name, and last name (<emphasis>glehey</emphasis>).
</para>
</listitem>
<listitem>

<para>Initials (<emphasis>gfl</emphasis>).
</para>
</listitem>
<listitem>

<para>Nickname (for example, <emphasis>grog</emphasis>).
</para>
</listitem>
</itemizedlist>

<para>I choose the last possibility, as we will see in the following discussion.
</para>
</sect2>
<sect2>
<title>Adding users</title>

<para><indexterm><primary>adding</primary><secondary>users</secondary></indexterm>
<indexterm><primary>users</primary><secondary>adding</secondary></indexterm>
<anchor id="CFBSD-adding-user"/>
<indexterm><primary>sysinstall</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>sysinstall</secondary></indexterm>
<indexterm><primary>adduser</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>adduser</secondary></indexterm>
<indexterm><primary>Schneider</primary><secondary>Wolfram</secondary></indexterm>
<indexterm><primary>Lehey</primary><secondary>Yana</secondary></indexterm>
There are two ways to add users.  One is the program <emphasis>adduser</emphasis>:
</para>
<programlisting>
# <command>adduser</command>
Use option ``-verbose'' if you want see more warnings &amp; questions
or try to repair bugs.

Enter username [a-z0-9]: <command>yana</command>
Enter full name []: <command>Yana Lehey</command>
Enter shell bash csh date no sh [bash]:	<emphasis>accept the default</emphasis>
Uid [1000]:						<emphasis>accept the default</emphasis>
Enter login class: default []:			<emphasis>accept the default</emphasis>
Login group yana [yana]: <command>home</command>
Login group is ``home''. Invite yana into other groups: <command>no</command>
[no]: </emphasis><command>wheel</command>						<emphasis>in order to use su
Enter password []:					<emphasis>no echo</emphasis>
Enter password again []:				<emphasis>no echo</emphasis>

Name:	  yana
Password: ****
Fullname: Yana Lehey
Uid:	  1000
Gid:	  1001 (home)
Class:
Groups:	  home wheel
HOME:	  /home/yana
Shell:	  /bin/bash
OK? (y/n) [y]:						<emphasis>accept the default</emphasis>
Added user ``yana''
Add another user? (y/n) [y]: <command>n</command>
</programlisting>

<para><indexterm><primary>vipw</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>vipw</secondary></indexterm>
<indexterm><primary>Lehey</primary><secondary>Norman</secondary></indexterm>
<anchor id="CFBSD-vipw"/>
</para>

<para><indexterm><primary>/etc/master.passwd</primary></indexterm>
An alternative way of adding or removing users is with the <emphasis>vipw</emphasis> program.
This is a more typical UNIX-hackish approach: <emphasis>vipw</emphasis> starts your favourite
editor and allows you to edit the contents of the file <emphasis>/etc/master.passwd</emphasis>.
After you have finished, it checks the contents and rebuilds the password
database.  Figure <xref linkend="CFBSD-vipw-screen"/> shows an example.
<indexterm><primary>/etc/master.passwd</primary></indexterm>
</para>

<para><figure><title><emphasis>vipw</emphasis> display</title><graphic format="JPEG" fileref="images/missing.jpg"></graphic></figure>
<anchor id="CFBSD-user-class"/>
<table frame='all'><title><emphasis>/etc/master.passwd</emphasis> format</title>
box,center,tab(#) ;
lfCWp9w15 | lw60  .
\s10Field#Meaning
=
yvonne#T{
User name
T}
(gibberish)#T{
Encrypted password.  When adding a new user, leave this field empty and add it
later with the <emphasis>passwd</emphasis> program.
T}
1005#T{
User number
T}
1000#T{
Group number
T}
<indexterm><primary>/etc/passwd</primary></indexterm>
(empty)#T{
Login class.  We'll look at this below.  This field is not included in
<emphasis>/etc/passwd</emphasis>.
T}
0#T{
Password change time.  If non-0, it is the time in seconds after which the
password must be changed.  This field is not included in <emphasis>/etc/passwd</emphasis>.
T}
0#T{
Account expiration time.  If non-0, it is the time in seconds after which the
user expires.  This field is not included in <emphasis>/etc/passwd</emphasis>.
T}
<indexterm><primary>Lehey</primary><secondary>Yvonne</secondary></indexterm>
<indexterm><primary>gecos</primary></indexterm>
T{
Yvonne Lehey, Echunga, +61-8-8388-8250
T}#T{
The so-called <emphasis>gecos</emphasis>
field, which describes the user.  This field is used
by a number of programs, in particular mail readers, to extract the real name of
the user.
T}
/home/yvonne#T{
The name of the home directory.
T}
/bin/bash#T{
The shell to be started when the user logs in.
T}

</tbody></tgroup></table>
</para>

<para>You're probably wondering why would you ever want to do things this way, and you
might find it funny that most experienced UNIX administrators prefer it.  The
reason is that you get more of an overview than with a peephole approach that
graphical environments give you, but of course you need to understand the format
better.  It's less confusing once you know that each line represents a single
user, that the lines are divided into <emphasis>fields</emphasis> (which may be empty), and
that each field is separated from the next by a colon (<emphasis>:</emphasis>).  Table
<xref linkend="CFBSD-master.passwd-format"/> describes the fields you see on the line on which the
cursor is positioned.  You can read more about the format of
<emphasis>/etc/master.passwd</emphasis> in the man page for <emphasis>passwd</emphasis> for further
details.
</para>

<para>We'll see a valid use of this approach on page <xref linkend="CFBSD-add-SLIP-user"/>: if you want to
make a second user almost the same as the first, it's easier to use an editor
than type in all the parameters again.
<!-- XXX -->
</para>
</sect2>
<sect2>
<title>Adding or changing passwords</title>

<para><indexterm><primary>adding</primary><secondary>passwords</secondary></indexterm>
<indexterm><primary>changing</primary><secondary>passwords</secondary></indexterm>
<indexterm><primary>passwords</primary><secondary>adding</secondary></indexterm>
<indexterm><primary>passwords</primary><secondary>changing</secondary></indexterm>
<indexterm><primary>passwd</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>passwd</secondary></indexterm>
If your system has any connection with the outside world, it's a good idea to
change your password from time to time.  Do this with the <emphasis>passwd</emphasis>
program.  The input doesn't look very interesting:
</para>
<programlisting>
$ <command>passwd</command>
Changing local password for yana.
Old password:				<emphasis>doesn't echo</emphasis>
New password:				<emphasis>doesn't echo</emphasis>
Retype new password:			<emphasis>doesn't echo</emphasis>
passwd: rebuilding the database...
passwd: done
</programlisting>

<para>You have to enter the old password to make sure that some passer-by doesn't
change it for you while you're away from your monitor, and you have to enter the
new password twice to make sure that you don't mistype and lock yourself out of
your account.  If this does happen anyway, you can log in as <emphasis>root</emphasis> and
change the password: <emphasis>root</emphasis> doesn't have to enter the old password, and it
can change anybody's password.  For example:
</para>
<programlisting>
# <command>passwd</command>
Changing local password for yana.
New password:				<emphasis>doesn't echo</emphasis>
Retype new password:			<emphasis>doesn't echo</emphasis>
passwd: rebuilding the database...
passwd: done
</programlisting>

<para>In this case, you specify the name of the user for whom you change the password.
</para>

<para><indexterm><primary>root</primary></indexterm>
<indexterm><primary>su</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>su</secondary></indexterm>
If you are changing the <emphasis>root</emphasis> password, be careful: it's easy enough to
lock yourself out of the system if you mess things up, which could happen if,
for example, you mistyped the password twice in the same way (don't laugh, it
happens).  If you're running X, open another window and use <emphasis>su</emphasis> to become
<emphasis>root</emphasis>.  If you're running in character mode, select another virtual
terminal and log in as <emphasis>root</emphasis> there.  Only when you're sure you can still
access <emphasis>root</emphasis> should you log out.
</para>

<para>If you <emphasis>do</emphasis> manage to lose the <emphasis>root</emphasis> password, all may not be lost.
Reboot the machine to single user mode (see page <xref linkend="CFBSD-single-user"/>), and enter:
</para>
<programlisting>
# <command>mount -u /</emphasis>				<emphasis>mount root file system read/write</command>
# <command>mount /usr /</emphasis>				<emphasis>mount /usr file system (if separate)</command>
# <command>passwd root</emphasis>				<emphasis>change the password for <emphasis>root<emphasis>
Enter new password:
Enter password again:
# </emphasis></emphasis></emphasis></command><command>^D</command>						<emphasis>enter ctrl-D to continue with startup
</programlisting>

<para>If you have a separate <emphasis>/usr</emphasis> file system (the normal case), you need to
mount it as well, since the <emphasis>passwd</emphasis> program is in the directory
<emphasis>/usr/bin</emphasis>.  Note that you should explicitly state the name <emphasis>root</emphasis>: in
single user mode, the system doesn't have the concept of user IDs.
</para>
</sect2>
<sect2>
<title>The super user</title>

<para><indexterm><primary>super</primary><secondary>user</secondary></indexterm>
<anchor id="CFBSD-root"/>
<indexterm><primary>su</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>su</secondary></indexterm>
FreeBSD has a number of privileged users for various administration functions.
Some are just present to be the owners of particular files, while others, such
as <emphasis>daemon</emphasis> and <emphasis>uucp</emphasis>, exist to run particular programs.  One user
stands above all others, however: <emphasis>root</emphasis> may do just about anything.  The
kernel gives <emphasis>root</emphasis> special privileges, and you need to become
<emphasis>root</emphasis> in order to perform a number of functions, including adding other
users.  Make sure <emphasis>root</emphasis> has a password if there is any chance that other
people can access your system (this is a must if you have any kind of dialup
access).  Apart from that, <emphasis>root</emphasis> is a user like any other, but to quote
the man page <emphasis>su(1)</emphasis>,
<quote>
<emphasis>By default (unless the prompt is reset by a startup file) the super-user
prompt is set to <emphasis>#</emphasis> to remind one of its awesome power.
</quote>
</emphasis></para>
<sect3>
<title>Becoming super user</title>

<para><indexterm><primary>becoming</primary><secondary>super user</secondary></indexterm>
<indexterm><primary>super</primary><secondary>user</secondary></indexterm>
Frequently when you're logged in normally, you want to do something which
requires you to be <emphasis>root</emphasis>.  You can log out and log in again as
<emphasis>root</emphasis>, of course, but there's an easier way:
</para>
<programlisting>
$ </emphasis><command>su</command>							<emphasis>become super user
Password:						<emphasis>as usual, it doesn't echo</emphasis>
#							<emphasis>root prompt</emphasis>
</programlisting>

<para><indexterm><primary>/etc/group</primary></indexterm>
In order to be able to use <emphasis>su</emphasis>, you must be a member of the group
<emphasis>wheel</emphasis>.  Normally you do this when you add the user, but otherwise just
put the name of the user at the end of the line in <emphasis>/etc/group</emphasis>:
</para>
<programlisting>
</emphasis>wheel:*:0:root<command>,grog</command>				<emphasis>add the text in bold face
</programlisting>

<para></para>
<note>

<para>BSD treats <emphasis>su</emphasis> somewhat differently from System V.  First, you need to be
a member of the group <emphasis>wheel</emphasis>, and secondly BSD gives you more of the
super-user environment than System V.  See the man page
for further information.
</para>
</note>

<para></para>
</sect3>
</sect2>
<sect2>
<title>Login classes</title>

<para><indexterm><primary>login</primary><secondary>classes</secondary></indexterm>
<anchor id="CFBSD-login-class"/>
<indexterm><primary>/etc/login.conf</primary></indexterm>
In UNIX tradition, <emphasis>root</emphasis> has been the owner of the universe.  In a large
installation, this is rather primitive, and the 4.3BSD Net/2 relase introduced a
new concept, <emphasis>login classes</emphasis>, which determine session accounting, resource
limits and user environment settings.  Various programs in the system use the
database described in <emphasis>/etc/login.conf</emphasis> to set up a user's login
environment and to enforce policy, accounting and administrative restrictions.
The login class database also provides the means by which users are able to be
authenticated to the system and the types of authentication available.
</para>

<para>When creating a user, you may optionally enter a class name, which should match
an entry in <emphasis>/etc/login.conf</emphasis>&mdash;see page <xref linkend="CFBSD-user-class"/> for more details.
If you don't, the system uses the entry <emphasis>default</emphasis> for a non-root user.
For the root user, the system uses the entry <emphasis>root</emphasis> if it is present, and
<emphasis>default</emphasis> otherwise.
</para>

<para>The structure of the login configuration database is relatively extensive.  It
describes a number of parameters, many of which can have two values: a
<emphasis>current</emphasis> value and a <emphasis>maximum</emphasis> value.  On login, the system sets
the values to the <emphasis>-cur</emphasis> (current) value, but the user may, at his option,
increase the value to the <emphasis>-max</emphasis> (maximum) value.  We'll look at the
<emphasis>default</emphasis> entry for an example.
</para>
<programlisting>
# Example defaults
# These settings are used by login(1) by default for classless users
# Note that entries like "cputime" set both "cputime-cur" and "cputime-max"

default:\e
	:cputime=infinity:\e
	:datasize-cur=64M:\e
	:stacksize-cur=64M:\e
	:memorylocked-cur=10M:\e
	:memoryuse-cur=100M:\e
	:filesize=infinity:\e
	:coredumpsize=infinity:\e
	:maxproc-cur=64:\e
	:openfiles-cur=64:\e
	:priority=0:\e
	:requirehome@:\e
	:umask=022:\e
	:tc=auth-defaults:
</programlisting>

<para><indexterm><primary>backslash
</primary></indexterm>
As in the password file, the fields are delimited by colons (<emphasis>:</emphasis>).  In
this example, though, lines are <emphasis>continued</emphasis> by placing a backslash
(<emphasis>\e</emphasis>) at the end of each line except the last.  This usage is common in
UNIX.  Unlike Microsoft usage, a backslash is never used to represent a
directory.
</para>

<para>This entry defines the following parameters:
</para>
<itemizedlist>
<listitem>

<para>Processes may use as much CPU time as they want.  If you change this, you can
stop processes which use more than a specific amount of CPU time.
</para>
</listitem>
<listitem>

<para>The current maximum sizes of the user data segment and the stack are set to 64
MB.  The entry doesn't define maximum values for these parameters.
</para>
</listitem>
<listitem>

<para>The user may lock a maximum of 10 MB of memory per process.
</para>
</listitem>
<listitem>

<para>The total memory use per process may not exceed 100 MB.
</para>
</listitem>
<listitem>

<para>There is no limit on the size of data files or core dump files that the user may
create.
</para>
</listitem>
<listitem>

<para>The user may have up to 64 processes.
</para>
</listitem>
<listitem>

<para>Each process may have up to 64 open files.  For some programs, this could be a
limitation.
</para>
</listitem>
<listitem>

<para>The user <emphasis>need not</emphasis> have a home directory in order to log in.  The
<emphasis>@</emphasis> symbol specifies that the preceding symbol (<emphasis>requirehome</emphasis>)
should be undefined.  As a result, the system does not require the home
directory.
</para>
</listitem>
<listitem>

<para><indexterm><primary>umask</primary></indexterm>
By default, the <emphasis>umask</emphasis> is set to <emphasis>022</emphasis>.  See page <xref linkend="CFBSD-umask"/> for
more details of <emphasis>umask</emphasis>.
</para>
</listitem>
<listitem>

<para>The system uses the default authentication scheme for this user.
</para>
</listitem>
</itemizedlist>

<para>See the man page <emphasis>login.conf(5)</emphasis> for further details.
</para>
</sect2>
<sect2>
<title>Referring to other classes</title>

<para>If you want to create a new class, you don't have to start from scratch.  You
can derive the defaults from a different class.  For example, if you have one
user on the system who uses a lot of memory, you might create a class like this:
</para>
<programlisting>
glutton:\e
	:tc=default:\e
	:memoryuse-cur=infinity:
</programlisting>

<para>The property <emphasis>tc</emphasis> refers to the <emphasis>default</emphasis> class.  A good example of
this is the <emphasis>xuser</emphasis> class, designed for the needs of X11 users:
</para>
<programlisting>
xuser:\e
	:manpath=/usr/share/man /usr/X11R6/man /usr/local/man:\e
	:cputime=4h:\e
	:datasize=12M:\e
	:stacksize=4M:\e
	:filesize=8M:\e
	:memoryuse=16M:\e
	:openfiles=32:\e
	:maxproc=48:\e
	:tc=standard:
</programlisting>

<para>In this example, you'll notice also that the class definition defines a default
for the environment variable <emphasis>MANPATH</emphasis>.
</para>
</sect2>
<sect2>
<title>Using login classes</title>

<para>Login classes are a relatively recent addition to FreeBSD.  There are a couple
of things to note about their use:
</para>
<itemizedlist>
<listitem>

<para>At the time of writing, not all parameters are implemented.
</para>
</listitem>
<listitem>

<para><indexterm><primary>/etc/login.conf</primary></indexterm>
The data is stored in the file database format for faster access.  After
modifying the file <emphasis>/etc/login.conf</emphasis>, be sure to run the following command
to update the database:
</para>
<programlisting>
# <command>cap_mkdb /etc/login.conf</command>
</programlisting>

<para></para>
</listitem>
</itemizedlist>

<para></para>
</sect2>
</sect1>
<sect1>
<title>Using the shell</title>

<para><indexterm><primary>using</primary><secondary>the shell</secondary></indexterm>
<indexterm><primary>shell</primary><secondary>using</secondary></indexterm>
So now we have a user ID, and we can get beyond the prompt on page
\&amp;<xref linkend="CFBSD-login-prompt"/>.  When you log in, you start your <emphasis>shell</emphasis>.  As we saw on
page <xref linkend="CFBSD-shell"/>, the shell takes your input as commands and ensures that they are
executed.  To log in, you type in your user ID, and when asked, your password:
</para>
<programlisting>
login: <command>grog</command>
Password:					<emphasis>password doesn't show on the screen</emphasis>
Last login: Sun Dec 21 18:56:11 on ttyv0
Copyright (c) 1980, 1983, 1986, 1988, 1989, 1991, 1993, 1994
	The Regents of the University of California.  All rights reserved.

FreeBSD 2.2.5 (FREEBIE) #14: Tue Jan  2 06:56:46 MET 1998

Welcome to FreeBSD!

You have mail.
erase ^H, kill ^U, intr ^C, status ^T
Niklaus Wirth has lamented that, whereas Europeans pronounce his name
correctly (Ni-klows Virt), Americans invariably mangle it into
(Nick-les Worth).  Which is to say that Europeans call him by name, but
Americans call him by value.
=== grog@freebie(/dev/ttyv0) ~ 1 -&gt;
</programlisting>

<para>There's a lot of stuff here, and it's worth looking at it in more detail:
</para>
<itemizedlist>
<listitem>

<para><indexterm><primary>getty</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>getty</secondary></indexterm>
<indexterm><primary>login</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>login</secondary></indexterm>
The program that asks you to log in is called <emphasis>getty</emphasis>.  It reads in your
user ID and starts a program called <emphasis>login</emphasis> and passes the user ID to it.
</para>
</listitem>
<listitem>

<para><emphasis>login</emphasis> asks for the password and checks your user ID.
</para>
</listitem>
<listitem>

<para>If the user ID and password are correct, <emphasis>login</emphasis> starts your designated
shell.
</para>
</listitem>
<listitem>

<para>While starting up, the shell looks at a number of files.
See the man page for your particular shell for details of what they are for.
<indexterm><primary>Message</primary><secondary>of the day</secondary></indexterm>
<indexterm><primary>/etc/motd</primary></indexterm>
<anchor id="CFBSD-motd"/>
In this case, though, we can see the results: one file contains the time you
last logged in, another one contains the <emphasis>Message of the day</emphasis>
(<emphasis>/etc/motd</emphasis>), and a third one contains your mail.  The shell prints out
the message of the day unaltered&mdash;in this case, it contains information about
the name of the kernel and a welcome message.  The shell also prints information
on last login time and whether you have mail.
</para>
</listitem>
<listitem>

<para>The line ``<emphasis>erase ^H, kill ^U, intr ^C, status ^T</emphasis>'' looks strange.  It's
telling you the current editing control characters.  We'll look at these on page
<xref linkend="CFBSD-control-chars"/>.
</para>
</listitem>
<listitem>

<para><indexterm><primary>home</primary><secondary>directory</secondary></indexterm>
<indexterm><primary>directory</primary><secondary>home</secondary></indexterm>
It changes the current directory to your <emphasis>home directory</emphasis>.
</para>
</listitem>
<listitem>

<para><indexterm><primary>Wirth</primary><secondary>Niklaus</secondary></indexterm>
<indexterm><primary>fortune</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>fortune</secondary></indexterm>
Then it runs the <emphasis>fortune</emphasis> program, which prints out a random quotation
from a database of ``fortune cookies''.  In this case, we get a message about
Niklaus Wirth, the inventor of the Pascal programming language.
</para>
</listitem>
<listitem>

<para>Finally, the last line is a prompt, the information that tells you that the
shell is ready for input.
</para>
</listitem>
</itemizedlist>

<para><indexterm><primary>sh</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>sh</secondary></indexterm>
<indexterm><primary>csh</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>csh</secondary></indexterm>
It's worth looking at the prompt in more detail, since it illustrates a number
of things about the UNIX environment.  By default, <emphasis>sh</emphasis> and friends prompt
with a <emphasis>$</emphasis>, and <emphasis>csh</emphasis> and friends prompt with a <emphasis>%</emphasis>.  In the
same way that you can change the MS-DOS command prompt away from <emphasis>C:\e&gt; </emphasis>
to, say, show the current directory, you can change it to just about anything
you want with the UNIX shells.  You don't have to like my particular version,
but it's worth understanding what it's trying to say.
</para>

<para><indexterm><primary>xterm</primary><secondary>command</secondary></indexterm>
<anchor id="CFBSD-shell-prompt"/>
The first part, <emphasis>===</emphasis>, is just to make it easier to find in a large list
on an X display.  An <emphasis>xterm</emphasis> window (a terminal emulator which runs under
X11) on a high resolution X display can contain up to 90 lines, and searching
for command prompts can be non-trivial.
</para>

<para>Next, <emphasis>grog@freebie</emphasis> is my user ID and the name of system on which I am
working, in the RFC 822 format used for mail IDs.  Multiple systems and multiple
users can all be present on a single X display.  This way, I can figure out
which user I am and what system I am running on.
</para>

<para><indexterm><primary>/dev/ttyv0</primary></indexterm>
<emphasis>/dev/ttyv0</emphasis> is the name of the current controlling terminal.  This can
sometimes be useful.
</para>

<para><emphasis>~</emphasis> is the name of the home directory.  Most shells, but not all of them,
support this symbolism.
</para>

<para><emphasis>1</emphasis> is the prompt number.  Each time you enter a command, it is associated
with this number, and the prompt number is incremented.  One way to re-execute
the command is to enter <emphasis>!!1</emphasis> (two exclamation marks and the number of the
command).  We'll look at more comfortable ones in the next section.
</para>
<sect2>
<title>Command line editing</title>

<para><indexterm><primary>Command</primary><secondary>line editing</secondary></indexterm>
<anchor id="CFBSD-control-chars"/>
Typing is a pain.  If you're anything like me, you're continually making
mistakes, and you may spend more time correcting typing errors than doing the
typing in the first place.  It's particularly frustrating when you enter
something like:
</para>
<programlisting>
$ <command>groff -rex=7.5 -r$$ -rL -rW -rN2 -mpic tmac.M unixerf.mm<emphasis>
troff: fatal error: can't open `unixerf.mm': No such file or directory
</emphasis></command></programlisting>

<para>This command <emphasis>should</emphasis> create the PostScript version of this chapter, but
unfortunately I messed up the name of the chapter: it should have been
<emphasis>unixref.mm</emphasis>, and I typed <emphasis>unixerf.mm</emphasis>.
</para>
<note>

<para>Yes, I know this looks terrible.  UNIX isn't all like this, but sometimes this
kind of notation has its advantages: it offers a flexibility that you can't get
any other way.  In addition, it's relatively easy to generate this kind of
command line automatically: the command I really use to format this chapter is
<emphasis>make unixref</emphasis>.
</para>
</note>

<para>It would be particularly frustrating if I had to type the whole command in
again.  UNIX offers a number of ways to make life easier.  The most obvious one
is so obvious that you tend to take it for granted: the <keycap>Backspace</keycap> key
erases the last character you entered.  Well, most of the time.  What if you're
running on a machine without a <keycap>Backspace</keycap> key?  You won't have that problem
with a PC, of course, but a lot of workstations have a <keycap>DEL</keycap> key instead of
a <keycap>Backspace</keycap> key.  UNIX lets you specify what key to use to erase the last
character entered.  By default, the erase character really is <keycap>DEL</keycap>, but the
shell startup changes it and prints out a message saying what it has done:
</para>
<programlisting>
 erase ^H, kill ^U, intr ^C, status ^T
</programlisting>

<para>in the example above.  <keycap>^H</keycap> (<keycap>CTRL-H</keycap>) is an alternative representation
for <keycap>Backspace</keycap>.
</para>

<para>The three other functions <emphasis>kill</emphasis>, <emphasis>intr</emphasis>, and <emphasis>status</emphasis> perform
similar editing functions.  <emphasis>kill</emphasis> erases the whole line, and <emphasis>intr</emphasis>
stops a running program.
</para>
<note>

<para><indexterm><primary>signal</primary></indexterm>
More correctly, <emphasis>intr</emphasis> sends a <emphasis>signal</emphasis> called <emphasis>SIGINTR</emphasis> to
the process.  This normally causes a program to stop.
</para>
</note>

<para><indexterm><primary>bash</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>bash</secondary></indexterm>
You'll notice that it is set to <keycap>Ctrl-C</keycap>, so its function is very similar to
that of the MS-DOS <keycap>Break</keycap> key.  <emphasis>status</emphasis> is an oddball function: it
doesn't change the input, it just displays a statistics message.  <emphasis>bash</emphasis>
doesn't in fact use it: it has a better use for <keycap>Ctrl-T</keycap>.
</para>

<para>In fact, these control characters are just a few of a large number of control
characters that you can set.  Table <xref linkend="CFBSD-terminal-control-chars"/> gives an
overview.
<table frame='all'><title>Terminal control characters</title>
box, center,tab(%) ;
 lfCWp9 | lfCWp9 | lf(R)w59  .
\s10Name%Default%Function
=

<tgroup cols='1' align='left' colsep='1' rowsep='1'><tbody>
<row><entry> CR%\er% Go to beginning of line.  Normally, this also terminates input (in other words, it returns the complete line to the program, which then acts on the input).
</entry></row>
<row><entry> NL%\en% End line.  Normally, this also terminates input.
</entry></row>
<row><entry> INTR%CTRL-C% Generate an \s10<emphasis>SIGINT</emphasis>\s0 signal.  This normally causes the process to terminate.
</entry></row>
<row><entry> QUIT%CTRL-|% Generate a \s10<emphasis>SIGQUIT</emphasis>\s0 signal.  This normally causes the process to terminate.
</entry></row>
<row><entry> ERASE%DEL% Erase last character.  FreeBSD sets this to <keycap>Backspace</keycap> on login, but under some unusual circumstances you will find it still set to <keycap>DEL</keycap>.
</entry></row>
<row><entry> KILL%CTRL-U% Erase current input line.
</entry></row>
<row><entry> EOF%CTRL-D% Return end-of-file indication.  Most programs stop when they receive an EOF.
</entry></row>
<row><entry> EOL%% Alternate end-of-line character.  This is not normally used, and by default it is disabled.
</entry></row>
<row><entry> EOL2%% Alternate end-of-line character.  Also seldom used.
</entry></row>
<row><entry> START%CTRL-Q% Resume output after stop.  See the next entry.
</entry></row>
<row><entry> STOP%CTRL-S% Stop output.  Use this to examine text which is scrolling faster than you can read.
</entry></row>
<row><entry>
</entry></row>
<indexterm><primary>fg</primary><secondary>command</secondary></indexterm>
<row><entry>
</entry></row>
<indexterm><primary>command</primary><secondary>fg</secondary></indexterm>
<row><entry> SUSP%CTRL-Z% Suspend process.  This key generates a \s10<emphasis>SIGTSTP</emphasis>\s0 signal when typed. This normally causes a program to be suspended.  To restart, use the <emphasis>fg</emphasis> command.
</entry></row>
<row><entry> DSUSP%CTRL-Y% Delayed suspend. Generate a \s10<emphasis>SIGTSTP</emphasis>\s0 signal when the character is read.  Otherwise, this is the same as <emphasis>SUSP</emphasis>.
</entry></row>
<row><entry> REPRINT%CTRL-R% Redisplay all characters in the input queue (in other words, characters that have been input but not yet read by any process).  The term "print" recalls the days of harcopy terminals.  Many shells disable this function.
</entry></row>
<row><entry> DISCARD%CTRL-O% Discard all terminal output until another \s10<emphasis>DISCARD</emphasis>\s0 character arrives, more input is typed or the program clears the condition.
</entry></row>
<row><entry> WERASE%CTRL-W%Erase the preceding word.
</entry></row>
<row><entry> LNEXT%CTRL-V% Interpret next character literally.  Many shells disable this function.
</entry></row>
<row><entry> STATUS%\\377% Send a <emphasis>SIGINFO</emphasis> signal to the foreground process group.  If <emphasis>NOKERNINFO</emphasis> is not set, the kernel also prints a status message on the terminal.
</entry></row>
</tbody></tgroup></table>
<indexterm><primary>stty</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>stty</secondary></indexterm>
To set these characters, use the <emphasis>stty</emphasis> program.  For example, if you're
used to erasing the complete input line with <keycap>Ctrl-X</keycap>, and specifying an
end-of-file condition with <keycap>Ctrl-Z</keycap>, you could enter:
</para>
<programlisting>
$ <command>stty susp \e377 kill ^X eof ^Z</command>
</programlisting>

<para>You need to set <emphasis>SUSP</emphasis> to something else first, because by default it is
<emphasis>Ctrl-Z</emphasis>, so the system wouldn't know which function to perform if you
press <emphasis>^Z</emphasis>
</para>
<note>

<para>The combination <emphasis>\e377</emphasis> is the character octal 377 (this notation comes
from the C language, and its origin is lost in the mists of time, back in the
days when UNIX ran on PDP-11s).  This character is the ``null'' character which
turns off the corresponding function.  System V uses the character <emphasis>\e0</emphasis>
for the same purpose.
</para>
</note>

<para>In this particular case, <emphasis>^X</emphasis> really does mean the letter <emphasis>^</emphasis>
followed by the letter <emphasis>X</emphasis>, and not <keycap>CTRL-X</keycap>, the single character
created by holding down the <keycap>Control</keycap> character and pressing <keycap>X</keycap> at the
same time.
</para>
</sect2>
<sect2>
<title>Command history and other editing functions</title>

<para><indexterm><primary>Command</primary><secondary>history</secondary></indexterm>
<anchor id="CFBSD-command-history"/>
The editing characters we looked at above are provided by the terminal driver,
which is part of the kernel, so they are available to all processes.  They all
have the limitation that they only work on the line you're currently typing.
Once you've pressed <keycap>Enter</keycap>, there's nothing they can do any more.
</para>

<para>Nowadays, most shells supply a <emphasis>command history</emphasis> function and additional
functionality for editing it.  We'll take a brief look at these features
here&mdash;for more details, see the man pages for your shell.
<!-- XXX -->
<indexterm><primary>emacs</primary><secondary>command</secondary></indexterm>
<indexterm><primary>command</primary><secondary>emacs</secondary></indexterm>
<table frame='all'><title>Command line editing&mdash;<emphasis>Emacs</emphasis> mode</title>
box, center,tab(#) ;
lf(B)w11 | lw67	 .
Key#Function
=

<tgroup cols='26' align='left' colsep='1' rowsep='1'><tbody>
<row><entry>  Ctrl-A </entry><entry> Move to the beginning of the line   LeftArrow </entry><entry> Move to previous character on line   Ctrl-B </entry><entry> Move to previous character on line (alternative)   Ctrl-D </entry><entry> Delete the character under the cursor.  Be careful with this character: it's als