The Complete FreeBSDGregLehey2001Greg LeheyIntroductionFreeBSD is a state of the art operating system derived from AT&T's UNIX
operating system.
FreeBSD no longer contains any AT&T proprietary code, so it may be distributed
freely. See page for more details.
It runs on the following platforms:
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.
The
Compaq/Digital Alpha processor.
In addition, significant development efforts are going towards porting FreeBSD
to other hardware, notably the MIPS R4000 series and the Sun Sparc.
This book only describes the released versions of FreeBSD for Intel and Alpha
processors.
How to use this bookThis book is divided into five parts:
The first part, chapters to , tells you how to install
FreeBSD and what to do if things go wrong.
Chapters to introduce you to life with FreeBSD,
including setting up optional features, building custom kernels and keeping up
to date with FreeBSD.
Chapters to introduce you to FreeBSD's rich
network support.
manpages
Starting on page you'll find selected man pages, 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.
The appendices start on page and include a large amount of
reference material.
In more detail, we'll discuss the following subjects:
In the rest of this chapter, we'll look at what FreeBSD is, what you need to run
it, and what resources are available:
On page we'll look at FreeBSD's features.
Starting on page we'll look at how FreeBSD came to be.
On page we'll compare FreeBSD to other free UNIX-like operating
systems.
On page we'll look at other sources of information about FreeBSD.
On page , we'll look at the world-wide FreeBSD community.
On page we'll consider what kinds of support are available for
FreeBSD.
Finally, on page we'll look at the BSD's emblem, the dæmon on the cover
of this book.
, discusses the installation requirements and theoretical
background of installing FreeBSD. You don't really need to read this
chapter, but it'll make you feel a whole lot more confident if you do.
, describes the changes that have taken place in FreeBSD since the
introduction of version 3.
, presents a quick installation overview. If you're
reasonably experienced, this may be all you need to install FreeBSD. Otherwise,
read on...
In , we'll walk through a typical installation. Read this chapter
if you are installing FreeBSD on a disk by itself.
In , we'll look at the differences you will encounter if you
install FreeBSD on a system which already contains another operating system.
, discusses what to do if you run into problems during or after
installation.
, describes the thousands of free software packages which you can
optionally install on a FreeBSD system.
, tells you how to set up XFree86, the Intel 386 architecture
implementation of the industry standard X11 Windowing System.
In , we'll look at the theory behind getting X11 working.
, presents a number of aspects of FreeBSD which are of interest
to newcomers (particularly from a Microsoft environment), in particular the
concepts of users and processes. We'll also consider the basics
of using the shell, as well as the importance of timekeeping.
, 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.
, contains information about the FreeBSD directory structure and
device names. You'll find the section on device names (starting on page
) interesting even if you're an experienced UNIX hacker.
, describes how to format and integrate hard disks, and how to handle
disk errors.
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 .
, describes the BSD spooling system and how to use it both on
local and networked systems.
, describes the user's viewpoint of FreeBSD. UNIX has come a long
way in the last few years—make yourself comfortable.
, discusses how to build a customized version of FreeBSD.
In , we'll discuss how to ensure that your system is always running
the most appropriate version of FreeBSD.
FreeBSD can run software written for a number of other operating systems. Read
about it in .
Starting at , we'll look at the Internet and the more important
services.
, describes how to set up local networking.
, discusses the issues in selecting an Internet Service Provider (ISP)
and establishing a presence on the Internet.
, discusses serial hardware and the prerequisites for PPP and SLIP
communications.
In , we look at FreeBSD's two PPP implementations and what it takes to
set them up.
In , we look at two older serial communication protocols.
In , we'll consider the use of names on the Internet.
Security is an increasing problem on the Internet. In , we'll
look at some things we can do to improve it. We'll also look at IP
aliasing, since it goes hand-in-hand with firewalls.
Networks sometimes become notworks. In , we'll see what
we can do to solve network problems.
, describes Sun's classic system for sharing file systems between
networked computers.
We'll look at the basic network access programs in .
Despite the World Wide Web, traditional two-way personal communication is still
very popular. We'll look at it in .
Most people think the World Wide Web is the Internet. We'll look at
both client and server access in .
Computers can send faxes a lot more cheaply and flexibly than fax machines.
We'll look at how to do that with FreeBSD in .
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 .
, explains some of the terms used in this book.
In , we'll look at Microsoft's MS-DOS commands and how to perform
similar functions with FreeBSD.
, suggests some books for further reading.
Finally, , contains the licence agreements under which FreeBSD
software is distributed.
FreeBSD 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 Berkeley Software Distribution (BSD) of UNIX.
For copyright reasons, FreeBSD may not be called UNIX. You be the judge of how
much difference this makes.
FreeBSD provides you with
many advanced features previously available only on much more expensive
computers, including:
FreeBSD on the Intel platform is a 32-bit operating system. 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.
On the Alpha platform, FreeBSD is a 64 bit operating system.
preemptivemultitaskingmultitasking
FreeBSD uses preemptive multitasking with dynamic priority adjustment to
ensure smooth and fair sharing of the computer between applications and users.
multiuser
FreeBSD is a multi-user system: 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.
TCP/IP
FreeBSD provides complete TCP/IP networking 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—see for more details.
memoryprotectionMemory protection ensures that neither applications nor users can
interfere with each other. If an application crashes, it cannot affect other
running applications.
XWindow SystemX11R6graphicaluser interfaceGUIXFree86
FreeBSD includes the XFree86 implementation of the industry standard
X Window System (X11R6) graphical user interface
(GUI).
binarycompatibilitycompatibilitySCOcompatibilityBSD/OScompatibilityLinuxcompatibilityNetBSDcompatibility386BSDSCOcompatibilityBSD/OScompatibilityNetBSDcompatibility386BSDcompatibilityLinuxcompatibility
FreeBSD can run most programs built for SCO UNIX and UnixWare, Solaris on the
i386 platform, BSD/OS, NetBSD, 386BSD, and Linux.
The FreeBSD ports and packages collection includes over two thousand
ready-to-run applications.
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.
virtualmemorymemoryvirtual
Demand paged virtual memory (VM) and ``merged VM/buffer cache''
design efficiently satisfies applications with large appetites for memory while
still maintaining interactive response to other users.
sharedlibrarieslibrariessharedShared libraries (the UNIX equivalent of Microsoft's DLLs) provide for
efficient use of disk space and memory.
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.
sourcecode
FreeBSD comes with source code for the entire system, so you have the
greatest degree of control over your environment.
onlinedocumentationdocumentationonlinemanpagesonlinehandbookhandbookonline
Extensive online documentation, including traditional man pages and
a hypertext-based online handbook.
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.
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.
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:
InternetServicesInternet Services: 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.
Education: 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 other work done.
Research: 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.
XWindow workstationX Window workstation: 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.
XIGraphics
See http://www.xig.com for further information about XI Graphics.
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.
softwaredevelopmentSoftware Development: The basic FreeBSD system comes with a full
complement of development tools included the renowned GNU C/C++ compiler and
debugger.
A little 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.
QDOSQuickand Dirty Operating System
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 QDOS
(Quick and Dirty Operating System).
At the time, it seemed just the
thing: it would run just fine without a hard disk (in fact, the original PC
didn't have 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.
CSRGBerkeleyUNIX
By this time, a little further down the West Coast of the USA, the Computer
Systems Research Group (CSRG)
of the University of California at
Berkeley had just modified AT&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 Internet
Protocols. The version of UNIX that they had developed was now sufficiently
different from AT&T's system that it had been dubbed Berkeley UNIX.
FastFile SystemUNIXFile System
As time went on, both MS-DOS and UNIX evolved. Before long MS-DOS was modified
to handle hard disks—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 Fast File System,
now known as the UNIX File System.
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.
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.
ResearchVersionBerkeleySoftware DistributionSystemVSantaCruz Operation
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&T first to license UNIX to other vendors, noticably Microsoft, who
announced XENIX in 1981, and then to market it itself. AT&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 Research Version, used only inside AT&T, the
Berkeley Software Distribution (BSD) from Berkeley, the commercial
System V from AT&T, and XENIX, which no longer interested Microsoft, and
was marketed by the company which had developed it, the Santa Cruz
Operation, or SCO.
USLUNIXSystems
BerkeleySoftware Design
BSDI
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—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&T's subsidiary USL (UNIX Systems Laboratories) filed a
lawsuit against Berkeley Software Design Inc. (BSDI), the
manufacturer of the BSD/386 and (later) the BSD/OS operating systems, both very
similar to FreeBSD, for alleged distribution of AT&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.
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.
Things have changed elsewhere as well. In 1992, AT&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.
Other free UNIX-like operating systems
FreeBSD isn't the only free UNIX-like operating system available—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:
386/BSD386/BSD 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.
NetBSDNetBSD 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 http://www.cons.org/cracauer/bsd-net-vs-free.html.
OpenBSDOpenBSD is a spinoff of NetBSD which focuses on security. You can find
more information at http://www.openbsd.org.
You might get the impression that there are lots of different, incompatible BSD
versions. In fact, they're all very similar.
FreeBSD and LinuxLinux 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.
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.
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:
Differences between FreeBSD and Linux
center,tab(#) ;
lw40 lw40 .
FreeBSD is a direct descendent of the original UNIX, though it contains no residual AT&T code. Linux is a clone and never contained any AT&T code
FreeBSD is a complete operating system, maintained by a central group of software developers. There is only one distribution of FreeBSD. Linux is a kernel, personally maintained by Linus Torvalds. The non-kernel programs supplied with Linux are part of a distribution, of which there are several.
FreeBSD aims to be a stable production environment. Linux is still a ``bleeding edge'' development environment, though many distributions aim to make it more suitable for production use.
As a result of the centralized development style, FreeBSD is straightforward and easy to install. 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.
FreeBSD is still relatively unknown, since its distribution was restricted for a long time due to the AT&T lawsuits. Linux did not have any lawsuits to contend with, so for a long time it was the only free UNIX-type system available.
As a result of the lack of knowledge of FreeBSD, not much commercial software is available for it. A growing amount of commercial software is becoming available for Linux.
As a result of the smaller user base, FreeBSD is less likely to have drivers for brand-new boards than Linux. Just about any new board will soon have a driver for Linux.
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. Linux appears not to need to be able to run FreeBSD programs or drivers.
FreeBSD has a large number of afficionados who are prepared to flame anybody who dares suggest that it's not better than Linux. Linux has a large number of afficionados who are prepared to flame anybody who dares suggest that it's not better than FreeBSD.
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
To quote Eric Raymond's ``The New Hacker's Dictionary'':
: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).
each other. There are signs that both sides are learning to appreciate each
other, and a number of people are now running both systems.
Other documentation on FreeBSD
People occasionally complain that there are so few books on
FreeBSD—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.
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?
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.
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.
In , 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:
onlinehandbookhandbookonlineLiveFilesystem
The FreeBSD online handbook 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 http://www.FreeBSD.org/handbook.html,
and it is also available on each FreeBSD system in the directory
/usr/share/doc/handbook. Before installation, you can access it from the
Live Filesystem CD-ROM. We'll look at how to do that in the next
section.
FAQFrequentlyAsked Questions/usr/share/doc/FAQVIEW
The FreeBSD FAQ (Frequently Asked Questions) 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 /usr/share/doc/FAQ. If
you run MS-DOS, you can view it before installation with the VIEW
program. Check the CD-ROM booklet for the location, which could change.
PeekJerryO'ReillyTimLoukidesMikeUNIX Power Tools, 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.
AbrahamsPaul W.LarsonBruce R.UNIX for the Impatient, 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 Emacs editor.
NemethEviSnyderGarthSeebassScottHeinTrent R.
The UNIX System Administration Handbook, 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.
There are a large number of active Internet groups which deal with FreeBSD.
Read about them in the online handbook.
Reading the handbooklynxcommand
If you're running X, you can use a browser like netscape to read the
handbook. If you don't have X running yet, use lynx. Both of these
programs are included on the CD-ROM. To install them, enter:
# pkg_add /cdrom/packages/All/netscape-communicator-4.5.tgzor
# pkg_add /cdrom/packages/All/lynx-2.8.1.1.tgzThe numbers after the name (4.5 and 2.8.1.1) may change after
this book has been printed. Use ls to list the names if you can't find
these particular versions.
Note that lynx is not a complete substitute for netscape: 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
pkg_addcommandcommandpkg_add
for more information on pkg_add.
In either case, you start the browser with the name of the handbook:
$ lynx /usr/share/doc/handbook/handbook.html
$ netscape /usr/share/doc/handbook/handbook.html &You enter the & after the invocation of netscape to free up the
window in which you invoke it: netscape opens its own window.
You can look at the FAQ in the same way—just substitute the name
FAQ/freebsd-faq.html for handbook/handbook.html.
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 /cdrom, choose the
directory /cdrom/usr/share/doc/handbook/handbook.html.
ghostscriptcommandcommandghostscriptdvipscommandcommanddvips
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 ghostscript. See page for more details of how
to print PostScript.
You can download handbook from
ftp://ftp.FreeBSD.ORG/pub/FreeBSD/doc/handbook.ps.gz. Use ftp
(page ) to transfer the document.
The online manualmancommandmanpagecommandman
The most comprehensive documentation on FreeBSD is in the form of man
pages. Nearly every program on the system comes with a short reference
manual explaining the basic operation and various arguments.
When online, you view the man pages with the command man. For example, to
learn more about the command ls, type:
$ man ls
LS(1) FreeBSD Reference Manual LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [-ACFLRTacdfiloqrstu1] [ file ... ]
DESCRIPTION
For each operand that names a file of a type other than directory, ls
displays its name as well as any requested, associated information. For
each operand that names a file of type directory, ls displays the names.
(etc)In this particular example, with the exception of the first line, the text in
constant width bold is not input, it's the way it appears on the screen.
The online manual is divided up into sections numbered:
User commands
System calls and error numbers
Functions in the C libraries
Device drivers
File formats
Games and other diversions
Miscellaneous information
System maintenance and operation commands
Kernel interface documentation
chmodcommandcommandchmod
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 chmod and a system call
chmod(). In this case, you can tell the man command which you want by
specifying the section number:
$ man 1 chmod chmod(1)chmod(2)
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, chmod(1) refers to the user
command chmod, and chmod(2) means the system call.
aproposcommandcommandapropos
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 -k option, or by
starting the program apropos:
$ man -k mail
$ apropos mail Both of these commands do the same thing: they show the names of the man pages
that have the keyword mail in their descriptions.
Alternatively, you may browse through /usr/bin and see all these file
names, but you don't have any idea what they do. To find out, enter one of the
lines:
$ cd /usr/bin; man -f *
$ cd /usr/bin; whatis * Both of these commands do the same thing: they print out a one-line summary of
the purpose of the program:
$ cd /usr/bin; man -f *
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
\&...etcGNU infoinfocommandcommandinfoemacscommandcommandemacs
The Free Software Foundation has its own on-line hypertext browser called
info. Many FSF programs come with either no man page at all, or with an
excuse for a man page (gcc, for example). To read the online
documentation, you need to browse the info files with the info
program, or from Emacs with the info mode. To start info,
simply type:
$ info In Emacs, enter CTRL-h i or ALT-Xinfo. Whichever way
you start info, you can get brief introduction by typing h, and a
quick command reference by typing ?.
The 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.
SupportSupportInstallationsupport
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
FreeBSD-newbies@FreeBSD.org and freebsd-questions@FreeBSD.org.
In conversation they are typically abbreviated to -newbies and
-questions respectively.
To sign up, send a mail message to majordomo@FreeBSD.org with the text
subscribe FreeBSD-newbies
or
subscribe FreeBSD-questions
You'll get a reply back saying that the request must be authenticated: it'll
look something like this:
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
Just reply to that message, removing all the text except the auth line:
auth 7e06ee31 subscribe freebsd-newbies grog@example.org
Send this message to majordomo@FreeBSD.org (which is what you do if you
just reply), not to the list itself. You'll get another reply back:
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 <Majordomo@FreeBSD.ORG> 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 <owner-freebsd-newbies@FreeBSD.ORG> .
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
As the welcome message says, -newbies is a discussion group for people
new to FreeBSD; it's not intended for real technical problems. Use
-questions for that.
When submitting questions to -questions, 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
http://www.lemis.com/questions.html. You may also like to check out the
FreeBSD World Wide Web (WWW) site at http://www.FreeBSD.org, in particular
the support page at http://www.FreeBSD.org/support.html.
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:
By phone. Call +1 925 603 1234
If you live in North America, you may not recognize the +1. This is the
international dialing code for North America; replace the + symbol with
your national prefix code for international calls. For example, in most parts
of Europe you replace the + with 00; in Australia, you replace
it with 0011, so the complete number becomes 0011 1 925 603
1234.
By fax. Fax to +1 925 674 0821.
By email. Send email to support@cdrom.com.
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.
Reporting bugsIf you find something wrong with FreeBSD, we want to know about it. There are
two ways to report a bug:
Report it via the World Wide Web at http://www.FreeBSD.org/send-pr.html.
Use the send-pr program to send it as a mail message.
The Berkeley dægmonBranaganLindaBerkeleydægmondægmonBerkeleydaemonBerkeleyKolstadRobMcKusickKirk
The little dæ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ægmon's copyright.
The dæ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—see
, page
for a description. The outside world occasionally sees things differently, as
the following story indicates:
Newsgroups: alt.humor.best-of-usenet
Subject: [comp.org.usenix] A Great Daemon Story
From: Rob Kolstad <kolstad@bsdi.com>
Newsgroups: comp.org.usenix
Subject: A Great Daemon Story
Linda Branagan is an expert on dægmons. She has a T-shirt that sports the
dægmon in tennis shoes that appears on the cover of the 4.3BSD manuals and
The Design and Implementation of the 4.3BSD UNIX Operating System 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æ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—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—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—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, big mistake. I should have guessed at what came next.
Native: ``Does the government use these devil computers?''
Me: ``Yes.''
Another big 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.
In fact, the dægmon tradition goes back quite a way. As recently as 1996, the
following message went through the FreeBSD-chat mailing list:
To: "Jonathan M. Bresler" <jmb@freefall.freebsd.org>
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
> details and gifs PLEASE!
If you insist. :-)SalusPeterFerentzMel
Sherman, set the Wayback Machine for around 1976 or so (see Peter Salus'
A Quarter Century of UNIX 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.
ThompsonKenRitchieDennisFoglioPhilO'BrienMike
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 /dev/null, 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.
StettnerArmando
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ægmon, whether knowingly borrowed from the original, or created by parallel
evolution, postdates the first horde of UNIX dægmons by at least a decade and
probably more. And if Lassiter's dæ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
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.
Before you installFreeBSD will run on just about any modern PC. You can skip this chapter and
move to , 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.
Hardware requirements
To run FreeBSD, you will need the following absolute minimum hardware:
PC with 80386 CPU, or Alpha-based machine with SRM firmware.
4 MB memory (Intel) or 24 MB (Alpha?)
Any display board
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.
Absolute minimum hardware for FreeBSDWhen I say absolute minimum, I mean it. You can run FreeBSD 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?
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.
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.
Consider the following the minimum for getting useful work done with FreeBSD and
X:
PC with 80486DX/2-66, or Alpha-based machine
16 MB memory (i386) or 32 MB (Alpha).
SVGA display board with 2 MB memory, 1024x768
Mouse
200 MB free disk space
Recommended small FreeBSD and X11 systemYour 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.
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.
Compaq/Digital Alpha machinesProcessorAXPAXPProcessorProcessorAlphaAlphaarchitectureConsolefirmwareSRMConsole firmwareConsolefirmwareARCConsole firmware
Since version 3.0, FreeBSD supports computers based on the Compaq (previously
Digital) AXP processor, commonly called Alpha. FreeBSD requires
the same SRM 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 ARC 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 ftp://ftp.digital.com/pub/Digital/Alpha/firmware. The easiest way to
access it is via a web browser at
http://gatekeeper.dec.com/pub/Digital/Alpha/firmware/. Be careful to
transfer in binary mode.
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.
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 help command lists all supported console
commands. If your system has been set to boot automatically, you must type
Ctrl-C to interrupt the boot process and get to the SRM console prompt
(>>>). If the system is not set to boot automatically, it will display
the SRM console prompt after performing system checks.
All SRM console versions support the set and show commands which
operate on environment variables that are stored in non-volatile memory. The
show command lists all environment variables, including those that are
read-only.
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
GENERIC kernel configuration (/usr/src/sys/alpha/conf/GENERIC)
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.
In the rest of this chapter, we'll look primarily at the i386 architecture.
Differences for Alpha include:
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.
Most SRM-based Alpha machines don't support IDE drives, so you're limited to
SCSI.
LaptopslaptopHosokawaTatsumi
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
http://www.jp.FreeBSD.org/PAO/.
Driverskernel
driver
The generic FreeBSD kernel
kernel
The kernel 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.
contains support in the form of drivers 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:
You may be able to use a Kernel Loadable Module (kld). A kld is
a kernel component which can be loaded (and in some cases unloaded) while the
kernel is running.
If no kld exists for your product, you will need to build a special
kernel—we'll look at what this entails in .
/dev
Table 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 /stand/help/hardware.hlp.gz,
from which this table was derived, or, even better, in the configuration file
/usr/src/sys/i386/conf/LINT or /usr/src/sys/alpha/conf/LINT for
authoritative information for your release of FreeBSD.
Hardware supported by FreeBSD
center,box,tab(#) ;
| lfCWp8 | cfCWp8 | cfCWp8 | cfCWp8 | cfCWp8 | lw45 | .
Device#Port#IRQ#DRQ#IOMem#Description
=
fdc03f062 Floppy disk controller wdc01f014 IDE/MFM/RLL disk controller wdc117015 IDE/MFM/RLL disk controller ncr0 NCR PCI SCSI controller bt0330\s+4\(bu\s0\s+4\(bu\s0\s+4\(bu\s0 Buslogic SCSI controller uha0330\s+4\(bu\s06\s+4\(bu\s0 Ultrastore 14f aha0330\s+4\(bu\s05\s+4\(bu\s0 Adaptec 154x SCSI controller ahb0\s+4\(bu\s0\s+4\(bu\s0\s+4\(bu\s0\s+4\(bu\s0 Adaptec 174x SCSI controller ahc0\s+4\(bu\s0\s+4\(bu\s0\s+4\(bu\s0\s+4\(bu\s0 Adaptec 274x/284x/294x SCSI controller amd0 Tekram DC-390(T) / AMD 53c974 PCI SCSI aic034011\s+4\(bu\s0\s+4\(bu\s0 Adaptec 152x/AIC-6360 SCSI controller nca01f8810\s+4\(bu\s0\s+4\(bu\s0 ProAudioSpectrum cards sea0\s+4\(bu\s05\s+4\(bu\s0c8000 Seagate ST01/02 8 bit controller wt030051\s+4\(bu\s0 Wangtek and Archive QIC-02/QIC-36 mse023c5 Microsoft Bus Mouse psm06012 PS/2 Mouse (disabled by default) mcd030010 Mitsumi CD-ROM matcd0230 Matsushita/Panasonic CD-ROM scd0230 Sony CD-ROM sio03f84 Serial Port 0 (COM1) sio12f83 Serial Port 1 (COM2) lpt0\s+4\(bu\s07 Printer Port 0 lpt1\s+4\(bu\s0\s+4\(bu\s0 Printer Port 1 de0 DEC DC21x40 PCI based cards (including 21140 100bT cards) ed02805\s+4\(bu\s0d8000 WD & SMC 80xx; Novell NE1000 & NE2000; 3Com 3C503; HP PC Lan+ ed13005\s+4\(bu\s0d8000 Same as ed0 eg03105\s+4\(bu\s0\s+4\(bu\s0 3Com 3C505 ep030010\s+4\(bu\s0\s+4\(bu\s0 3Com 3C509 ex0\s+4\(bu\s0\s+4\(bu\s0\s+4\(bu\s0 Intel EtherExpress Pro/10 cards fe0300\s+4\(bu\s0 Allied-Telesis AT1700, RE2000 and Fujitsu FMV-180 series cards. fxp0\s+4\(bu\s0\s+4\(bu\s0\s+4\(bu\s0 Intel EtherExpress Pro/100B ie03607\s+4\(bu\s0d0000 AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210 ix030010\s+4\(bu\s0d0000 Intel EtherExpress cards le03005\s+4\(bu\s0d0000 Digital Equipment EtherWorks 2 and EtherWorks 3 lnc028010\s+4\(bu\s0 Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL) vx0\s+4\(bu\s0\s+4\(bu\s0\s+4\(bu\s0 3Com 3c59x / 3c9xx ze03005d8000 IBM/National Semiconductor PCMCIA Ethernet Controller zp030010d8000 3Com 3c589 Etherlink III PCMCIA Ethernet Controller
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 /dev directory, but
network interfaces such as Ethernet boards do not have device nodes. See
for some other exceptions.
If a field is marked with a bullet (\s+4\(bu\s0), 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
LINT configuration in , page
for further details.
Additional drivers supplied in source
center,box,tab(#) ;
| lfCWp9 | lw75 | .
\s10Driver name#Description
=
ctx Cortex-I frame grabber cx Cronyx/Sigma multiport sync/async cy Cyclades high-speed serial driver el 3Com 3C501 fea DEV DEFEA EISA FDDI adater fpa DEC DEFPA PCI FDDI adapter gp National Instruments AT-GPIB and AT-GPIB/TNT board gsc Genius GS-4500 hand scanner gus Gravis Ultrasound - Ultrasound, Ultrasound 16, Ultrasound MAX gusxvi Gravis Ultrasound 16-bit PCM joy Joystick labpc National Instrument's Lab-PC and Lab-PC+ meteor Matrox Meteor frame-grabber card mpu Roland MPU-401 stand-alone card mse Logitech & ATI InPort bus mouse ports mss Microsoft Sound System nic Dr Neuhaus NICCY 3008, 3009 & 5000 ISDN cards opl Yamaha OPL-2 and OPL-3 FM - SB, SB Pro, SB 16, ProAudioSpectrum pas ProAudioSpectrum PCM and MIDI pca PCM audio (/dev/audio) through your PC speaker psm PS/2 mouse port rc RISCom/8 multiport card sb SoundBlaster PCM - SoundBlaster, SB Pro, SB16, ProAudioSpectrum sbmidi SoundBlaster 16 MIDI interface sbxvi SoundBlaster 16 spigot Creative Labs Video Spigot video-acquisition board uart Stand-alone 6850 UART for MIDI wds Western Digital WD7000 IDE
Supported hardware—Alpha architectureAlphasupported hardware
FreeBSD/alpha supports the following alpha platforms:
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)
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
ftp.digital.com/pub/DEC/Alpha/firmwareYou 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).
The CD-ROM distributionInstallationCD-ROMCD-ROMInstallationLiveFile System CD-ROMCD-ROMLive File System
Walnut Creek CDROM distributes FreeBSD on four CD-ROMs:
The Installation Boot CD, packages, X11 CD-ROM. It contains everything
you need to install the system itself.
CD-ROMCVS RepositoryCVSRepository
The Live filesystem, CVS Repository, web pages CD-ROM.
The Packages/ports CD-ROM.
Docsand Extras
The Distribution tarballs and packages (overflow) CD-ROM.
All are mastered in ISO 9660 with Rock Ridge extensions (see page
for an explanation of these terms). We'll look at them in the following
sections.
CD-ROM 1: InstallationThe Installation CD-ROM contains everything you need to install FreeBSD on your
system. It supplies two categories of installable software:
System software is stored as gzipped tar archives in the
directories bin, catpages, compat1x, compat20,
compat21, des, dict, doc, games, info,
manpages and proflibs. 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 bin/bin.aa to
bin/bin.cx.
packages/All
The directory packages/All contains ported, installable software
packages as gzipped tar 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.
packages/All 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 archivers, astro, audio,
benchmarks, cad, chinese, comms, converters,
databases, devel, editors, emulators, games,
german, graphics, japanese, korean, lang,
mail, math, mbone, misc, net, news,
perl5, plan9, print, russian, security,
shells, sysutils, tcl75, tcl76, tcl80,
textproc, tk41, tk42, tk80, vietnamese and
www. Don't get the impression that these are different packages—they
are really pointers to the packages in All. You will find a list of the
currently available packages in the file /usr/ports/INDEX.
Table
lists the files in the main directory of the installation CD-ROM.
The installation CD-ROM
center,box,tab(#) ;
| lfI | lw64 | .
File#Contents
=
VIEW 00_index.txt A description of some of the files on the CD-ROM.
ABOUT.TXT A brief description of FreeBSD.
ERRATA.TXT A list of last-minute changes. Read this file. It can save you a lot of headaches.
HARDWARE.TXT A list of supported hardware.
INSTALL.TXT Information about installing FreeBSD.
LAYOUT.TXT A description of the CD-ROM layout.
README.TXT The traditional first file to read. It describes how to use the other files.
RELNOTES.TXT Release notes.
TRANS.TBL Translation table for Rock Ridge, of no interest to anybody else.
TROUBLE.TXT Information on what to do if you run into trouble.
UPGRADE.TXT Notes on upgrading from older versions of FreeBSD.
XF86333 Directory containing the XFree86 distribution. The release number may change in future releases of FreeBSD.
bin Installation directory: the binary distribution of the system. This is the only required directory for installation. See , for more detail.
book Information relating to this book, including the complete text in ASCII.
catpages Pre-formatted man pages. See page for more detail.
cdrom.cfg Machine-readable file describing the CD-ROM contents for the benefit of Microsoft programs.
cdrom.inf Machine-readable file describing the CD-ROM contents for the benefit of Microsoft programs.
commerce Commercial and shareware software for FreeBSD. Some of these packages are demos, others are supplied with restricted licenses. Read the file README in each subdirectory for more information.
compat1x Directory containing libraries to maintain compatibility with version 1.X of FreeBSD.
compat20 Directory containing libraries to maintain compatibility with version 2.0 of FreeBSD.
compat21 Directory containing libraries to maintain compatibility with version 2.1 of FreeBSD.
des Encryption software. Until recently, this software could be distributed only in the USA and Canada.
dict Installation directory: dictionaries.
doc Installation directory: documentation.
filename.txt A list of all the files on this CD-ROM.
floppies A directory containing installation floppy disk images.
games Installation directory: games.
info Installation directory: GNU info documents.
kernel The boot kernel.
makeflp.bat A Microsoft .BAT file for copying floppy images to floppy.
manpages A directory containing the man pages for installation.
packages A directory containing installable versions of the Ports Collection. See page .
ports The sources for the Ports Collection. See , page .
proflibs A directory containing profiled libraries, useful for identifying performance problems when programming.
setup.exe An Microsoft install program for installing from a running Microsoft system.
setup.hlp Help file for setup.exe.
src A directory containing the system source files.
tools A directory containing Microsoft tools to prepare for installation.
utils More Microsoft utilities.
view.exe An Microsoft based CD-ROM browser program. See page .
view.pif \&.PIF file for view.exe.
xperimnt A number of packages which are under development and were not ready for integration into FreeBSD at the time of release.
CD-ROM 2: Live File System, CVS Repository, web pagesLiveFile System CD-ROMCD-ROMLive File System
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 Live File System 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.
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 , page . This disk also
contains a snapshot of the Web pages at www.FreeBSD.org (directory
www).
CD-ROMs 3 and 4: The Ports CollectionPortsCollection
An important part of FreeBSD is the Ports Collection, 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
make for a given package. The ports mechanism does the rest, so you
need only enough disk space to build the ports you want.
PortsCollection
We'll look at the Ports Collection in more detail in Chapter .
The files are spread over 3 CD-ROMs:
You'll find the ports, the instructions for building the packages, on
CD-ROM 1.
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.
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 make.
The packages, the precompiled binaries of the ports, are spread between
CD-ROM 1, which includes the most popular ones, and CD-ROM 4.
PC hardwareIn 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:
How FreeBSD supports hardware, and what to do if your hardware doesn't
correspond to the system's expectations.
How FreeBSD and other PC operating systems handle disk space, and how to set up
your disk for FreeBSD, starting on page
How to share your disk with another operating system, starting on page
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.
How the system detects hardwareprobing
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
probing. 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:
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.
UserConfig
You can use UserConfig 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—we'll look at it in more
detail in , on page
You can build a kernel to use the current board parameters.
There are four main parameters that you may need to set for PC controller
boards:
portaddress
The port address 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 0x320.
If you come from a Microsoft background, you might be more comfortable with the
notation 320H. The notation 0x320 comes from the C programming
language. You'll see a lot of it in UNIX.
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.
Beware of boards with a large number of registers. Typical port addresses end
in (hexadecimal) 0. Don't rely on being able to take any unoccupied
address ending in 0, though: some boards, such as Novell NE2000
compatible Ethernet boards, occupy up to 32 registers—in our example, from
0x320 to 0x33f. Note also that a number of addresses, such as
the serial and parallel ports, often end in 8.
interruptrequestsIRQ
Boards use an Interrupt Request, also referred to as IRQ, 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.
DirectMemory AccessDMADMARequestDMAAcknowledgeDMAChannel
Some high-speed devices perform Direct Memory Access, also known as
DMA, to transfer data to or from memory without CPU intervention. In
order to transfer data, they assert a DMA Request (DRQ) and wait for the
bus to reply with a DMA Acknowledge (DACK). The combination of DRQ and
DACK is sometimes called a DMA Channel. 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.
memoryI/OI/OmemoryIOmem
Finally, controllers may have on-board memory which is usually located at
addresses between 0xa0000 and 0xeffff. This is sometimes
referred to as I/O memory or IOmem.
DisksIDEmodifiedfrequency modulationMFMRLLencodingrun length limitedrunlength limited encoding
A number of different disks are used on current PCs:
ST-506cablecontrolcabledatacontrolcabledatacableST-506 disks are the oldest. You can tell them by the fact that they
have two cables: a control cable which usually has connections for two
disks, and a thinner data cable which is not shared with any other disk.
They're just about completely obsolete by now, but FreeBSD still supports them
with the wd driver. These disks are sometimes called by their
modulation format, Modified Frequency Modulation or MFM. A
variant of MFM which offers about 50% more storage is RLL or Run
Length Limited modulation.
ESDIEnhancedSmall Device InterfaceATAttachmentATAESDI (Enhanced Small Device Interface) 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
wd driver supports them, too.
IDEIntegratedDevice ElectronicsEIDEenhancedIDEIDE (Integrated Device Electronics), now frequently called
ATA (AT Attachment), 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 EIDE (Enhanced IDE)
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
uses a new driver for all IDE disks.
programmedI/OPIO
A problem with older IDE controllers was that they used programmed I/O
or PIO 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''.
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
for details of how to do this.
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.
SCSISmallComputer Systems InterfacehostadapterwideSCSISCSI is the Small Computer Systems Interface. 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 host adapter. 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.
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.
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.
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.
PC BIOS and disksread/writeheadheadread/write
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 read/write head 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.
tracksectorscylinder
While transferring data, the heads are stationary, so data is written on disks
in a number of circular tracks. Logically, each track is divided into a
number of sectors, 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 cylinder.
LogicalBlock AddressingLBACHS
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 CHS 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 Logical Block Addressing or LBA.
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.
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 ) might bite you. Check
your controller documentation for details.
Logical and physical disk drivesdiskdrivesdiskdriveslogicaldisk drivesphysicaldisk drives
The PC world makes a distinction between logical disk drives and
physical disk drives. Physical disks are easy enough to understand, of
course, but the term logical drive 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.
partitionspartitiontable
Microsoft divides a disk into up to four partitions, headed by a partition
table. FreeBSD uses the term partition differently, as we will see,
so it refers to Microsoft's partitions as slices.
slicedefinedThis double usage of the word partition is really confusing. In this
book, I follow BSD usage, but I will continue to refer to the partition table by
that name.
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
shows a disk with all four slices allocated.
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
"/dev/da0s1" at A below
"Partition (slice) 2" at B above
"/dev/da0s2" at B below
"Partition (slice) 3" at C above
"/dev/da0s3" at C below
"Partition (slice) 4" at D above
"/dev/da0s4" at D below
]
]
Partition tablepartitiontablepartitionactive
The Partition Table 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 active: at system
startup time, its bootstrap record will be used to start the system.
masterboot recordMBR
Although it is not as important as the partition table, the Master Boot
Record (MBR) 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.
MicrosoftpartitionprimaryMicrosoft partitionextendedMicrosoft partition
Microsoft designates one slice as the primary Microsoft partition, the
C: drive. Another slice may be designated as an extended Microsoft
partition, which contains the other ``drives'' (all together in one slice).
filesystemsswappartitionUNIXpartitionspartitionsUNIXda0devicedeviceda0
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:
filesystem
A partition can be a file system, a structure in which UNIX stores files.
swappartition
It can be used as a swap partition. 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.
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 (a, b,
and d through h) should not overlap.
characterdevicedevicecharacter
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—it's more
like treating it as a tape. UNIX calls this kind of access raw access.
You'll also hear the term character device.
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.
blockdevicedeviceblock
The standard term for disks is block device. You can recognize block
and character devices in an ls -l listing by the letters b and
c at the beginning of the permissions. For example:
$ ls -l /dev/rwd0s1a /dev/wd0s1a
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
Let's look more carefully at how BSD names its partitions:
Like all other devices, the device entries are stored in the directory
/dev.
If the partition is raw (character), the name starts with the letter r.
If it isn't, there is no prefix.
Next comes the name of the driver. As we have seen, FreeBSD has drivers for IDE
and friends (wd), SCSI disks (da) and floppy disks (fd).
With our first SCSI disks, we now have the names /dev/rda and
/dev/da.
The abbreviation wd 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 da comes from the CAM
standard and is short for direct access.
Next comes the unit number, generally a single digit. For example, the first
SCSI disk on the system would normally be called /dev/da0.
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 for
more details.
This gives us the names /dev/rda0 and /dev/da0.
slicenamestrictslice name
Next comes the partition information. The so-called strict slice name
is specified by adding the letter s (for slice) and the slice
number (1 to 4) to the disk name. BSD systems name partitions by appending the
letters a to h 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 /dev/rda0s1a and /dev/da0s1a. Partition c
is an exception: by convention, it represents the whole BSD disk (in this case,
the slice in which FreeBSD resides).
compatibilityslice nameslicename
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
/dev/da0s1a, they refer to it as /dev/da0a. FreeBSD supports this
method as well—it's called compatibility slice naming, and it's the
form you'll see most frequently.
Table
gives you an overview of the devices which FreeBSD defines for a single physical
disk /dev/da0:
Disk partition terminology
center,box,tab(#) ;
| lfCWp9 | lw64 | .
\s10Slice name#Usage
=
/dev/rda0 Whole disk, raw access /dev/rda0s1 First slice (Microsoft ``partition''), raw access /dev/rda0s1a First slice (Microsoft ``partition''), partition a, raw access /dev/rda0s1b First slice (Microsoft ``partition''), partition b, raw access /dev/rda0s1d First slice (Microsoft ``partition''), partition d, raw access /dev/rda0s1e First slice (Microsoft ``partition''), partition e, raw access /dev/rda0s1f First slice (Microsoft ``partition''), partition f, raw access /dev/rda0s1g First slice (Microsoft ``partition''), partition g, raw access /dev/rda0s1h First slice (Microsoft ``partition''), partition h, raw access /dev/rda0s2 Second slice (Microsoft ``partition''), raw access /dev/rda0s3 Third slice (Microsoft ``partition''), raw access /dev/rda0s4 Fourth slice (Microsoft ``partition''), raw access /dev/rda0s5 First drive in extended Microsoft partition, raw access /dev/rda0s6 Second drive in extended Microsoft partition, raw access /dev/rda0s7 Third drive in extended Microsoft partition, raw access /dev/rda0a First partition of BSD slice, usually root file system, raw access /dev/rda0b Second partition of BSD slice, usually swap space, raw access /dev/rda0c Whole BSD slice, raw access /dev/rda0d Additional file system, raw access /dev/rda0e/usr file system, raw access /dev/rda0f Additional file system, raw access /dev/rda0g Additional file system, raw access /dev/rda0h Additional file system, raw access /dev/da0s1 First slice (Microsoft ``partition'') /dev/da0s1a First slice (Microsoft ``partition''), partition a /dev/da0s1b First slice (Microsoft ``partition''), partition b /dev/da0s1d First slice (Microsoft ``partition''), partition d /dev/da0s1e First slice (Microsoft ``partition''), partition e /dev/da0s1f First slice (Microsoft ``partition''), partition f /dev/da0s1g First slice (Microsoft ``partition''), partition g /dev/da0s1h First slice (Microsoft ``partition''), partition h /dev/da0s2 Second slice (Microsoft ``partition'') /dev/da0s3 Third slice (Microsoft ``partition'') /dev/da0s4 Fourth slice (Microsoft ``partition'') /dev/da0s5 First drive in extended Microsoft partition /dev/da0s6 Second drive in extended Microsoft partition /dev/da0s7 Third drive in extended Microsoft partition /dev/da0a First partition of BSD slice, usually root file system /dev/da0b Second partition of BSD slice, usually swap space /dev/da0c Whole BSD slice /dev/da0d Additional file system /dev/da0e/usr file system /dev/da0f Additional file system /dev/da0g Additional file system /dev/da0h Additional file system
In the interests of space, I haven't included the names of possible FreeBSD
partitions in slices 1, 2, and 3.
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 C: drive"
move .1i
D: box ht .25i "Microsoft D: drive /dev/da0s5"
E: box ht .25i "Microsoft E: drive /dev/da0s6"
move .25i
FA: box ht .2i "disk label and bootstrap"
box ht .2i "/dev/da0s3a: / file system"
box ht .2i "/dev/da0s3b: swap"
box ht .2i "/dev/da0s3d"
box ht .2i "/dev/da0s3e: /usr file system"
box ht .2i "/dev/da0s3f"
box ht .2i "/dev/da0s3g"
box ht .2i "/dev/da0s3h"
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 "/dev/da0s1"
move up .08i from P2.c "Slice 2 - Microsoft extended"
move down .08i from P2.c "/dev/da0s2"
move up .08i from P3.c "Slice 3 - FreeBSD"
move down .08i from P3.c "/dev/da0s3"
]
Partition table with FreeBSD file system
Figure shows a typical layout on a system with a single
SCSI disk, shared between Microsoft and FreeBSD. You'll note that partition
/dev/da0s3c 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.
FDISKMS-DOS commandMS-DOScommandMasterBoot RecordMBR
If you need to replace the MBR, and you no longer have FreeBSD installed, you
can use the MS-DOS FDISK command to do this:
C: FDISK /MBRThis command doesn't change the partition table: it only writes the Master Boot
Record.
Making the file systems
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:
Do we want to share this disk with any other operating system?
If so, do we have data on this disk which we want to keep?
FDISKMS-DOS commandMS-DOScommand
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 FDISK program to free up enough space for you to install FreeBSD.
If you don't have a slice to delete, you can use the FIPS program to
create one—see , page
fdiskcommandcommandfdisksysinstallcommandcommandsysinstall
If for some reason you can't use MS-DOS FDISK, for example because you're
installing FreeBSD by itself, FreeBSD also supplies a program called
fdisk which manipulates the partition table. Normally you will invoke
it indirectly via the sysinstall program—see page
.
Using a boot managerbootmanager
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
booteasy, a so-called Boot Manager, which is installed in the
Master Boot Record. If you install booteasy, it will prompt you for the
system to install every time you boot the system, for example:
F1 . . . BSD
F2 . . . DOS
F5 . . . Disk 2
Default: F1
When you boot the system, it records what slice you booted from, and offers it
as a default the next time you boot—in this case, it suggests F1 for
FreeBSD. If you don't respond within 10 seconds, it will accept this default
automatically and boot the system accordingly.
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 , page
for further details.
Interaction with Microsoft
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.
Sharing a disk with MicrosoftIf 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
, page
Using compressed MS-DOS file systems from FreeBSDStackerMS-DOS commandDoubleSpaceMS-DOS command
If you are using a utility such as Stacker\(tm or
DoubleSpace\(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
not superfluous, it's everything you have.
Your best choice here is to leave one Microsoft partition uncompressed and use it
for communications between Microsoft and FreeBSD.
Running Microsoft binaries under FreeBSDpcemu
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:
pcemu runs under the X Window System and emulates an 8088 and enough
BIOS services to run MS-DOS text mode applications.
WINEWindowsEmulatorWINE (Windows Emulator) can run some Windows applications. It's
still more experimental than usable.
Disk size limitationsDisk storage capacity has grown by an order of magnitude in the last few years.
As it did so, a number of limits became apparent:
The first was the BIOS 504 MB limit on IDE disks, imposed by their
similarity with ST-506 disks, and discussed on page . 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.
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.
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.
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.
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.
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—if your BIOS supports it.
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.
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
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
"C:" at A
"Microsoft primary partition" at A.e+(.9i,0) ljust
"FreeBSD slice" at B.e+(.9i,-.125i) ljust
"D:, E, etc." at C
"Extended Microsoft partition" 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
]
]
Sharing a disk between Microsoft and FreeBSD
Make particularly sure that the end 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.
Other things to consider are:
If you have other software already installed on the disk, and you want to keep
it, do not change the drive geometry. If you do so, you will no longer
be able to run the other software.
Use LBA addressing if your hardware supports it.
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.
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.
Quick Installation
In chapters to , 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 through .
On page we'll look at the simplest installation, where
FreeBSD is the only system on the disk. Starting on page we'll
look at sharing the disk with Microsoft, and on page
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.
Making things easy for yourselfIt 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.
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?''
As you might expect, the real story is quite involved. In , 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:
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.
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 , you shouldn't have any difficulty.
FIPS
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 FIPS (see page ), to make space for it,
but this requires more care.
RTFM
If you run into trouble, RTFM.
Hackerspeak for ``Read The Manual''—the F is usually silent.
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.
If you do all this, and it still doesn't work, see page for ways of
getting external help.
FreeBSD alone on the disk
To install FreeBSD from CD-ROM on a disk alone, go through the following steps:
If your BIOS supports direct booting from CD-ROM, boot from CD-ROM. Otherwise,
Create two boot floppies by copying the images /cdrom/kern.flp and
/cdrom/mfsroot.flp to 3\(12" diskettes. Refer to page
for more details.
Insert the CD-ROM in the drive before booting.
Boot from the kern.flp floppy. After loading, insert the
mfsroot.flp floppy when the system prompts you to do so, then press
Enter.
If you have a larger floppy, such as 2.88 MB or LS-120, you can copy the image
/cdrom/boot.flp to it and boot from it. In this case you don't need to
change disks.
Select the Novice installation, even if you're an experienced UNIX
hacker. Refer to page .
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
and .
On exiting from the partition editor, select the Standard MBR. Refer to
page .
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 .
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 /usr file system.
Refer to page .
Note particularly that, if you don't create a /var file system, as I'm
recommending here, you'll need to create a symlink later on.
Choose the distributions you want. Refer to page .
Select CD-ROM as installation medium. Refer to page .
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 .
Give final confirmation. The system will be installed. Refer to page
.
After installation, set up at least a user ID for yourself. Refer to page
.
Do you have a separate /usr file system and no /var file system?
Then create a directory /usr/var and make sure that you make
/var point to /usr/var—see page for further
details.
Installing XFree86
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.
XF86331
Log in as root, cd to /usr, and extract all the archives
in /cdrom/dists/XF86331 with tar. If you're using sh or
similar, do this with:
# cd /usr
# for i in /cdrom/dists/XF86331/X331*.tgz; do
# tar xzf $i
# doneIf you're using csh or tcsh, do it with:
% cd /usr
% foreach i (/cdrom/dists/XF86331/X331*.tgz)
% tar xzf $i
% endIdentify the type and memory size of your video board, and the type and serial
port name of your mouse.
Select the name of an X server which will work with your video board. Refer to
page for further details. Look at the list of servers in
table on page X
and create a link between the one you want to use and /usr/X11R6/bin/X.
xf86configcommand
Run xf86config to create a configuration file. Refer to page
for further details.
FreeBSD shared with Microsoft
To install FreeBSD on a disk on which Microsoft is already installed, go through
the following steps:
Make a backup! There's every possibility of erasing your data, and
there's absolutely no reason why you should take the risk.
If you have an IDE disk larger than 504 MB, you may run into problems. Refer to
page for further details.
If you haven't read the documentation in Chapter , consider
performing the next couple of steps using VIEW, which can show you the
on-line documentation and start the programs for you. Refer to page
for more information about VIEW.
Repartition your disk with FIPS. Refer to page . You can start
FIPS directly or via the VIEW program.
Insert the CD-ROM in the drive before booting.
Boot the FreeBSD system. If your Microsoft system is configured in a
FreeBSD-friendly manner, you can boot directly from Microsoft using the program
INSTALL.BAT for most CD-ROMs, or INST_IDE.BAT for IDE CD-ROM
drives. You can also start either of these programs from the VIEW
program.
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 and in more detail on page .
Select the Novice installation, even if you're an experienced UNIX
hacker. Refer to page .
In the partition editor, delete only 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
.
On exiting from the partition editor, select the BootMgr MBR. Refer to
page .
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 .
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
.
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 /usr file system.
Refer to page .
Note particularly that, if you don't create a /var file system, you'll
need to create a symlink later on.
Choose the distributions you want. Refer to page .
Select CD-ROM as the installation medium. Refer to page .
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
.
Confirm installation. The system will be installed. Refer to page .
After installation, set up at least a user ID for yourself. Refer to page
.
Do you have a separate /usr file system and no /var file system?
Then create a directory /usr/var and make sure that you make
/var point to /usr/var—see page for further
details.
Shared OS InstallationIn 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.
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.
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
Repartitioning with FIPSFIPSMS-DOS commandMS-DOScommand
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:
You can reinstall the software. This approach is common in the Microsoft world,
but FreeBSD users try to avoid it.
You can use FIPS shrink a Microsoft partition, leaving space for
FreeBSD. FIPS is a public domain utility, and it is included on the
FreeBSD CD-ROM. Unfortunately, it cannot shrink more recent Microsoft file
systems.
If you can't use FIPS, use a commercial utility like PartitionMagic.
This is not included on the CD-ROMs, and we won't discuss it further.
In the rest of the section, we'll look at how to shrink a partition with
FIPS. If you do it with PartitionMagic, the details are different, but
the principles are the same. In particular:
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.
DEFRAGMS-DOS commandMS-DOScommandNortondisk tools
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 DEFRAG.
Alternatively, you can use a third-party defragmenter such as the one supplied
with the Norton Disk tools. Before proceeding, consider a few gotchas:
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.
The second partition is also a Microsoft partition. To install FreeBSD on it, you
need to delete it and create a new FreeBSD partition.
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 .
MSCDEXMicrosoft driverFIPS 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.
For further information, read the FIPS documentation in
/cdrom/tools/srcs/fips/fips.doc. In particular, note these limitations:
FIPS works only with Hard Disk BIOSes that use interrupt 0x13
for low level hard disk access. This is generally not a problem.
FIPS splits only partitions with 16 bit FATs. Older versions of
Microsoft use 12 bit FATs, which are too small to be worth splitting.
LinuxFIPS 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
not split Linux partitions.
FIPS does not yet work on extended Microsoft partitions.
FIPS needs one free partition entry, so it will not work if you already
have four partitions.
FIPS 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.
Repartitioning—an exampleIn 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.
CHKDSKMS-DOS programSCANDISKMS-DOS program
First, run CHKDSK or SCANDISK 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.
RESTORRBMS-DOS program
Next, prepare a bootable floppy. When you start FIPS, you will be given
the opportunity to write backup copies of your root and boot sector to a file on
drive A:. These will be called ROOTBOOT.00x, where x
represents a digit from 0 to 9. If anything goes wrong while
using FIPS, you can restore the original configuration by booting from
the floppy and running RESTORRB.
ROOTBOOTfile
If you use FIPS more than once (this is normally not necessary, but it
might happen), your floppy will contain more than one ROOTBOOT file.
RESTORRB lets you choose which configuration file to restore. The file
RESTORRB.000 contains your original configuration. Try not to confuse
the versions.
Before starting FIPS you must 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:
Most defragmentation programs don't move the windows swap file. You have to
uninstall it (in the 386enhanced part of the Windows Control Panel) and
reinstall it after using FIPS.
IMAGEMS-DOS programMIRRORMS-DOS program
Programs like IMAGE or MIRROR store a hidden system file with a
pointer to your mirror files in the last sector of the hard disk. You
must delete this file before using FIPS. It will be recreated the
next time you run MIRROR. To delete it, in the root directory enter:
C> attrib -r -s -h image.idx for IMAGE
C> attrib -r -s -h mirorsav.fil for MIRROR
Then delete the file.
If FIPS does not offer as much disk space for creation of the new
partition as you expect, this may mean that:
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 FIPS again.
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.
If the file belongs to some sort of copy protection, you must uninstall the
program to which it belongs and reinstall it after repartitioning.
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.
Running FIPSAfter defragmenting your Microsoft partition, you can run FIPS. In
VIEW, select tools, then fips. It's easier to do it from
the command line:
C> R:change to CD-ROM
R> cd \etoolsmake sure you're in the tools directory
R> fipsand start the FIPS program
\&... a lot of copyright information omitted
Press any key do what the computer says
Which Drive (1=0x80/2=0x81)?
The message Which Drive 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, (C:), enter 1, otherwise enter
2. Like MS-DOS, FIPS handles only two hard disks.
If you start FIPS 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.
Next, FIPS reads the root sector of the hard disk and displays the
partition table:
| | 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
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—we'll deal with that in the FreeBSD installation. First, FIPS
does some error checking and then reads and displays the boot sector of the
partition:
Checking Rootsector ... OK
Press any Key do what it says
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
After further checking, FIPS asks you if you want to make a backup
floppy. Enter your formatted floppy in drive A: and make the backup.
Next, you see:
Enter start cylinder for new partition (263 - 987):
Use the cursor keys to choose the cylinder, <enter> to continue
Old partition Cylinder New Partition
53.9 MB 263 148.7 MB
Use the Cursor Left and Cursor Right keys to adjust the cylinder
number at which the new partition starts. You can also use the keys Cursor
Up and Cursor Down to change in steps of ten cylinders. FIPS
updates the bottom line of the display to show the new values selected.
Initially, FIPS chooses the smallest possible Microsoft partition, so
you can only increase the size of the old partition (with the Cursor Right
key). When you're happy with the sizes, press Enter to move on to the
next step.
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.
In this example, we choose the following combination:
Old partition Cylinder New Partition
82.0 MB 400 120.6 MB
(pressed Enter
| | 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)? cCONFIG.SYSAUTOEXEC.BATMIRRORMS-DOS programIMAGEMS-DOS programCHKDSKMS-DOS program
In order for the partition to be recognized, reboot immediately. Make sure to
disable all programs that write to your disk in CONFIG.SYS and
AUTOEXEC.BAT before rebooting. It might be easier to to rename the
files or to boot from floppy. Be particularly careful to disable programs like
MIRROR and IMAGE, which might get confused if the partitioning
is not to their liking. After rebooting, use CHKDSK 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 CONFIG.SYS and AUTOEXEC.BAT.
Start some programs and make sure you can still read your data.
After that, you have two valid Microsoft partitions on your disk. Read the next
section to install FreeBSD on the second one.
Installing FreeBSD on a second partition
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 FIPS 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 Building
a partition table on page
When you enter the partition editor, you will see something like:
Disk name: wd0FDISK Partition Editor
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 reverse video
Use F1 or ? to get more help, arrow keys to move.
This display shows the two Microsoft partitions, wd0s1 and wd0s2. To
install FreeBSD, you need to remove one of them. Be very careful to remove
the correct partition. It's always the second of the two partitions, in this
case wd0s2. We remove the partition with the d command. After
this, our display looks like:
0 35 34 - 6 unused 0
35 167965 167999 wd0s1 2 fat 6 =
168000 247380 415379 - 2 unused 0
The next step is to allocate a FreeBSD partition with the C 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:
0 35 34 - 6 unused 0
35 167965 167999 wd0s1 2 fat 6 =
168000 247380 415379 wd0s2 3 freebsd 165 C
fdiskcommandcommandfdisk
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 (0xa5), which identifies it as a FreeBSD partition.
All we need to do now is to mark the partition active or bootable, by pressing
s. The a flag appears at the end of the partition line:
0 35 34 - 6 unused 0
35 167965 167999 wd0s1 2 fat 6 =
168000 247380 415379 wd0s2 3 freebsd 165 CA
After this, we select a boot method as described on page
Since we have two operating systems on the disk, we select the BootMgr
option.
slicediskpartitiondisk
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 slices. That wouldn't be bad in itself, but it also
uses the term partition to refer to the contents of the slice. See page
for further details.
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
/usr
we will typically need a root file system, a /usr file system and swap
space. When we select Label, we get the following screen:
FreeBSD Disklabel Editor
Disk: wd0 Partition name: wd0s2 Free: 247380 blocks (120MB)
Part Mount Size Newfs Part Mount Size Newfs
---- ----- ---- ----- ---- ----- ---- -----
wd0s1 <none> 82MB DOS
Be careful here. The partition shown in the list is the active
Microsoft partion, not 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
/usr
so we'll just look at the manual generation here. If we enter c 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 /usr. We hit c and
get a prompt window asking how much we want, suggesting the whole disk. We
replace this with 20m (the trailing m 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 file system and get a further prompt
asking where to mount it. We enter /, and come back to the display,
which now shows:
Part Mount Size Newfs Part Mount Size Newfs
---- ----- ---- ----- ---- ----- ---- -----
wd0s1 <none> 82MB DOS
wd0s2a / 20MB UFS Y
Next we define the swap space. This time we specify 32 MB, and that it should
be swap space. Now the display looks like:
Part Mount Size Newfs Part Mount Size Newfs
---- ----- ---- ----- ---- ----- ---- -----
wd0s1 <none> 82MB DOS
wd0s2a / 20MB UFS Y
wd0s2b <none> 32MB SWAP
/usr
Finally, we create the /usr file system. This time we accept the offer
of everything available, and end up with:
Part Mount Size Newfs Part Mount Size Newfs
---- ----- ---- ----- ---- ----- ---- -----
wd0s1 <none> 82MB DOS
wd0s2a / 20MB UFS Y
wd0s2b <none> 32MB SWAP
wd0s2e /usr 68MB UFS Y
After this point, we can continue at Section Selecting distributions on
page
The rest of the installation is the same as for a dedicated disk.
Installing FreeBSD
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 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 .
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 .
Installing FreeBSD on the Intel i386 architecture
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:
ElTorito
CD-ROM. This is by far the easiest way to install FreeBSD. If your system BIOS
supports the El ToritoEl 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.
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.
Over the network. You have the choice of ftp or NFS connection.
From a locally mounted disk partition, either FreeBSD (if you have already
installed it) or Microsoft.
From tape in tar 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.
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.
Booting from CD-ROMFinally 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 El
Torito 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 Preparing a boot floppybootfloppyfloppies/boot.flpbootdisk
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 Kernel Disk
and the MFS Root Disk to boot the installation programs. If you are
using 2.88 MB floppies or a LS-120 disk, you can copy the single Boot
Disk, which is 2.88 MB long. The images of these floppies are on the CD-ROM
distribution in the files floppies/kern.flp, floppies/mfsroot.flp
and floppies/boot.flp respectively. If you have your CD-ROM mounted on
a Microsoft system, they will be called FLOPPIES\eKERN.FLP,
FLOPPIES\eMFSROOT.FLP and FLOPPIES\eBOOT.FLP respectively. The
bootstrap does not recover bad blocks, so the floppy must be 100% readable.
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
# dd if=/cdrom/floppies/kern.flp of=/dev/fd0c bs=36bchange the floppy
# dd if=/cdrom/floppies/mfsroot.flp of=/dev/fd0c bs=36brfd0cdevicedevicerfd0c
This assumes that your software is on CD-ROM, and that it is mounted on the
directory /cdrom. It also assumes that your floppy drive is called
/dev/fd0c (this is the FreeBSD name, which is also used by other BSD
systems—see page
for an overview). If you're using Linux, the device name would be
/dev/fd0 or /dev/fd1.
Some versions of UNIX, particularly older System V variants, may complain about
the option bs=36b. 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.
VIEW.EXEMS-DOS commandMS-DOScommandMAKEFLP.BATMS-DOS commandMS-DOScommandfloppies/boot.flp
If you have to create the boot floppy from Microsoft, use the program
Makeflp.bat 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
View.exe, 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 View.exe and follow the
instructions.
Creating floppies for a floppy installation
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:
Before starting, format all floppies in the drive you intend to use, even if
they are preformatted.
floppies/boot.flpRAWRITE.EXEMS-DOS commandddcommandcommanddd
The first two floppies you'll need are the Kernel floppy and the MFS Root
floppy, which were described in the previous section.
In addition, you will need at minimum as many floppies as it takes to hold all
files in the bin directory, which contains the binary distribution.
Read the file LAYOUT.TXT paying special attention to the ``Distribution
format'' section which describes which files you need.
If you're creating the floppies on a FreeBSD machine, you can put ufs
file systems on the floppies instead:
# fdformat -f 1440 fd0.1440
# disklabel -w -r fd0.1440 floppy3
# newfs -t 2 -u 18 -l 1 -i 65536 /dev/fd0Next, 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
A:\BIN\BIN.INF, A:\BIN\BIN.AA, A:\BIN\BIN.AB etc.
Make very sure to put the file bin.inf on the first floppy, since it is
needed to find out how many floppies to read.
Installing via FTPinstallingfrom Internet
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.
There are two FTP installation modes you can use:
Regular FTP mode does not work through most firewalls but will often work
best with older ftp servers that do not support passive mode. Use this
mode if your connection hangs with passive mode.
FTPpassive
If you need to pass through firewalls that do not allow incoming connections,
try passive FTP.
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 . This
information is also generally correct for other UNIX systems.
Setting up the ftp server\*[Fver]-RELEASE/usr/ftp
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 ftp, which in FreeBSD defaults to
/usr/ftp. The name of the directory is the name of the release, which in
this example we'll assume to be -RELEASE.
You can put this directory in a subdirectory of /usr/ftp, for example
/usr/ftp/FreeBSD/-RELEASE,
but the only optional part in this example is the parent directory
FreeBSD.
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
/cdrom, and that you are installing in the directory
/usr/ftp/FreeBSD/-RELEASE, perform the following steps:
# cd /usr/ftp/FreeBSD/-RELEASE
# mkdir floppies
# cd floppies
# cp /cdrom/floppies/* . don't omit the . at the end
# cd /cdrom the distribution directory on CD-ROM
# tar cf - [b-d]* g* man* po* pr* [s-z]* | (cd /usr/ftp/FreeBSD/-RELEASE; tar xvf -)This copies all the directories of /cdrom into
/usr/ftp/FreeBSD/-RELEASE except for packages, a total of about
180 MB. If you have enough space for the packages file as well (about
500 MB more), you can simplify the last line to:
# tar cf - . | (cd /usr/ftp/FreeBSD/-RELEASE; tar xvf -)For a minimal installation, you need only the directory bin, about 16
MB. To just install bin rather than all of the distribution, change the
last line of the example above to
# mkdir bin
# cp /cdrom/bin/* binInstalling via NFS
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 sharing). 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 /cdrom on the system
presto.example.org, enter presto.example.org:/cdrom. That's all
there is to it!
Older versions of FreeBSD stored the distribution on a subdirectory dists.
Newer versions store it in the root directory of the CD-ROM.
Installing from a Microsoft partitionOn 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 \eFREEBSD.
For example, to do a minimal installation of FreeBSD from Microsoft using files
copied from a CD-ROM mounted on E:, you might do something like this:
C> MKDIR C:\eFREEBSD
C> XCOPY /S E:\eBIN C:\eFREEBSD\eBIN
C> XCOPY /S E:\eFLOPPIES C:\eFREEBSD\eFLOPPIESsysinstallcommandcommandsysinstallboot.flp
You need the directory FLOPPIES because that's where sysinstall
looks for the boot.flp, the first image in every installation.
Thebin directory
The only required directory is bin. 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 XF86312 and manpages,
you would copy them to C:\eFREEBSD\eXF86312 and
C:\eFREEBSD\eMANPAGES.
Installing from tapeinstallingfrom tape
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 tar
format with a block size of 5120 bytes (10 sectors). Don't use tar's
default value of 10240 bytes or 20 sectors. Since the install program reads the
entire tape onto disk, you will need a big disk. As a further
restriction, you can install only from the first tape unit in the system.
Installing from a FreeBSD partitioninstallingfrom disk partition
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—consider it an
experimental option.
Booting the 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.
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.
Booting from CD-ROMBooting 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:
If you're booting from an IDE CD-ROM, you enter your system BIOS setup routines
and set the Boot sequence parameter to select CD-ROM booting ahead of
hard disk booting, and possibly also ahead of floppy disk booting. A typical
sequence might be CDROM,C,A.
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, SCSI,A,C. 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.
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.
Booting from floppybootingfrom floppy
If you are installing from tape or CD-ROM, put the medium in the drive
before booting. The installation may fail if you boot before inserting the
medium.
/dev/fd0A:drive
Boot the system in the normal manner: insert the kernel diskette in
/dev/fd0, the first floppy drive (which Microsoft calls A:), 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.
Installing from a running Microsoft systemIf 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 (E:
in this example) and start INSTALL or VIEW:
C> E:change to CD-ROM
E> cd \emake sure you're in the root directory
E> installand start the INSTALL program
Don't try this from Microsoft Windows—the installation will fail with the
message not enough memory. The boot will progress in the same way as if
you had booted from floppy. The advantage of starting VIEW is that you
get more documentation: ultimately VIEW will start INSTALL to
boot the system.
INSTALL 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 .
The boot processThe boot process itself is very similar to the normal boot process described on
page . There are a couple of differences:
At the beginning, you will see the message:
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<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR>
real memory = 134217728 (131072K bytes)
If the system stops at this point, it probably means that you have memory
problems (either not enough memory or defective memory).
If you're booting from a two-floppy set, the loader will issue the following
prompt after loading the kernel:
Please insert MFS root floppy and press enter:
When you do that, it continues with the probes.
After the probes (page ) you always go into the UserConfig menu:
B Kernel Configuration Menu
Skip kernel configuration and continue with installation
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 certain that you do not need to configure your kernel
then simply press ENTER or Q now.
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 UserConfig (the
kernel configuration editor) is for, and why you get the chance to run it at
this point in the installation. See page for an example
of how to tell the kernel about your hardware configuration.
If your hardware configuration matches what the generic kernel expects (see page
), or if your hardware is all PCI, just press ENTER.
The kernel will continue with the device probes (see page
). 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.
Shortly after you leave UserConfig, the screen will be cleared and you will see
the main sysinstall menu (in colour, if your system supports it).
Using sysinstallsysinstallusingFAQ/TextMain installation menu
Figure shows the main sysinstall menu.
sysinstall includes on-line help at all stages. Simply press F1
and you will get appropriate help. Also, if you haven't been here before, the
Doc menu gives you a large part of the appropriate information from the
handbook.
Kinds of installationstandardinstallationexpressinstallationcustominstallationinstallationstandardinstallationexpressinstallationcustom
To get started, you select one of Standard, Express or
Custom. The names imply that the Standard installation is the
best way to go, the Express installation is for people in a hurry, and
Custom installation is for you if you want to specify exactly what is to
be done.
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:
Possibly set up options.
Set up disk partitions, which we'll discuss in the next section.
Set up file systems and swap space within a FreeBSD slice, which we start on
page
Choose what you want to install, which we discuss on page
Choose where you want to install it from. We'll look at this on page
Actually install the software. We'll treat this on page
We looked at disk partitions and file systems on page . We'll
look at the other points when we get to them.
So what's the difference?
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.
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.
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.
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.
Custom Installation optionsSetting installation optionsThe 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.
Custom Installation options
About the only thing of interest might be the editor ec, which is a
compromise between a simple editor for beginners and more complicated editors
like vi. If you're planning to edit anything during the installation, for
example the file /etc/exports, which we'll look at on page
, 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.
Creating space on diskpartitiontablediskscreating file systemsdiskscreating space
The first installation step is to set up space for FreeBSD on the disk. We
looked at the technical background in , page
In this section, we'll use the term partition to refer to a slice or
Microsoft partition, since that's the usual terminology, even if it's a little
confusing.
partition
Even if your disk is correctly partitioned, select Partition: 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 q (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:
Disk selection menuad0
This screen shows entries for each drive that sysinstall has detected;
in this example, the system has one ATA (IDE) drive, ad0, and one SCSI
drive, da0. You only get this screen if you have at least two drives
connected to your machine; otherwise sysinstall automatically goes to
the next screen.
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 , on page
As you'll see there, it's much easier to do it now.
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:
Partition editor menu
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.
fdisk information
box,center,tab(#) ;
| lfCWp9w8 | lw66 | .
\s10Column#description
=
fatfileallocation table Offset the number of the first sector in the partition
Size the length of the partition in sectors
End the number of the last sector in the partition
Name where present, this is the name by which FreeBSD knows the partition. In this example, only the second entry has a name.
Ptype 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.
fatFileAllocation Table Subtype Desc These describe the type of partition numerically and in text. fat stands for File Allocation Table, 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.
Flagscan be one or more of the following characters:
= The partition is correctly aligned
> The partition finishes after cylinder 1024, which can cause problems for Microsoft. A This is the active (bootable) partition.
B The partition employs BAD144 bad-spot handling.
C This is a FreeBSD compatibility partition.
R This partition contains a root file system.
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
FIPS—see , page
if that's what you want to do—but in this example we choose to remove it.
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.
We remove the partition with the d command. After this, our display
looks like:
0 40088160 40088159 - 6 unused 0
The next step is to allocate a FreeBSD partition with the C 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 c
(create) command. We'll look at that in , page
. In our case, though, we want to use the entire disk for
FreeBSD, so we choose the a option:
Partition editor menu
If you answer Yes to this question, you will get a display effectively
the same as in Figure : the only difference will be
that the Desc field will now show freebsd instead of fat.
If you select No, you will get the following display:
Partition editor menu
This layout gives you slightly more space: it omits the partition table and the
630 sectors of waste space at the end.
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 dangerously dedicated to refer to a drive
partitioned in this way.
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.
commandfdiskfdiskcommandbootselectorMBRmasterboot record
That's all we need to do here: we leave fdisk with the q
command.
Don't use the W (Write Changes) command here. It's intended for use
only once the system is up and running.
If we have selected a partition table, the next screen asks what kind of boot
selector (in other words, MBR) we want:
Partition editor menuBootMgr
You don't get this screen if you dedicate the entire disk to FreeBSD, by
answering No to the question about a true partition entry. Since we
plan to have only one operating system on this disk, we select Standard.
If we were sharing with, say, Microsoft, we could choose BootMgr
instead.
MBR choices
box,center,tab(#) ;
lfCWp9 | lw66 .
\s10Choice#Description
=
booteasy BootMgr Install the FreeBSD boot manager in the MBR. This will enable you choose which partition to boot every time you start the system.
Standard Use a standard MBR. You will only be able to boot from the active partition.
None Don't change the MBR. This is useful if you already have another boot manager installed.
Where we are nowAt this point in the installation, we have told sysinstall 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.
Specifying disk labelsdisklabel/usr
In the next step we tell the installation program what to put in our FreeBSD
partition. By default, sysinstall gives you three file systems: the
root file system /, /usr and /var. See , page
for the reasoning behind the file system layout. When we select Label, we
get the following screen:
Label editor menuWhat size partitions?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 sysinstall 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.
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 Communications of the
ACM in July 1974:
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...
As time went on, UNIX got bigger, but so did the disks. By the early 80s, disks
were large enough to put / and /usr on the same disk, and it
would have been possible to merge / and /usr, but they didn't.
Since that time, an additional file system, /var, has come into common use
for frequently changed data. This is what sysinstall does by default:
Default disk partition sizes
It's relatively simple to estimate the size of the root file system, and
sysinstall's value of 50 MB is fine. But what about /var? 20 MB
isn't worth the trouble any more. In fact, both file systems put together would
be lost in the 19 GB of /usr file system. Why do we still do things
this way? Let's look at the advantages and disadvantages:
If you write to a file system, a system crash can have serious consequences for
the data integrity of that file system.
If you have a crash and lose the root file system, recovery can be difficult.
If a file system fills up, it can cause lots of trouble. Most messages about
file systems on the FreeBSD-questions 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.
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 /bin
and /sbin. In order to run any other programs, you must first mount the
file system on which they are located.
It's nice to keep your personal files separate from the system files. That way
you can upgrade a system much more easily.
It's very difficult to calculate the sizes of some file systems. For example,
on some systems /var 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 /var system
of 50 or 100 GB. How do you choose the correct size for your system?
When doing backups, it's a good idea to be able to get a file system on a single
tape.
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.
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 /usr file system on the first (or only) disk on the system.
/var was to be a symbolic link to /usr/var.
This is still a valid layout, but it has a couple of problems:
In the example we're looking at, /usr is about 19 GB in size. Not many
people have backup devices which can write this much data on a single medium.
Many people had difficulty with the symbolic link to /usr/var.
As a result, I now recommend:
Make a single root file system of between 2 and 4 GB.
Do not have separate /usr or /var file systems.
Use the rest of the space on disk for a /home file system, as long as
it's possible to back it up on a single tape. Otherwise make multiple file
systems. /home is the normal directory for user files.
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 /var 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 / was
undamaged, so it made sense to have a small root file system, on which little
data was written, and a larger /usr file system which included file
systems which changed more frequently.
In fact, this never quite happened. UNIX has a directory /tmp 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?
We've already seen how big to make /usr: 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 ), 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.
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.
How much swap space?swapspace
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
automatic 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?
It's almost impossible to know in advance what your system will require. Here
are some considerations:
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.
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.
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 (gcc) are not in
the same league.
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.
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.
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 /usr partition.
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.
A couple of examples might make this clearer:
I used to run X, StarOffice, Netscape 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.
commandpstatpstatcommand
To view the current swap usage, use pstat. Here's a typical view of this
machine's swap space:
$ pstat -s
Device 1024-blocks Used Avail Capacity Type
/dev/da0s1b 122880 65148 57668 53% Interleaved
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:
$ pstat -s
Device 1024-blocks Used Avail Capacity Type
/dev/ad0s1b 524020 22328 501692 4% Interleaved
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''.
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''.
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.
UNIXFile SystemMountNewfsUFS
For the file systems, the column Mount now shows the mount points, and
Newfs contains the letters UFS for UNIX File System,
and the letter Y, 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:
Creating the file systemsWith these considerations in mind, we'll divide up the disk in the following
manner:
4 GB for the root file system, which includes /usr and /var.
512 MB swap space.
The rest of the disk for the /home file system.
To create a file system, we press c. 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:
When we press ENTER, we see another prompt asking for the kind of partition. We
select A File System:
When we press ENTER, we see another prompt asking for the mount point for the
file system. We enter / for the root file system, after which the
display looks like:
After we press ENTER again, the display shows:
Next, we repeat the operation for the swap partition and the /home file
system, entering the appropriate values each time. We don't change the value
offered for the length of /home: we just use all the remaining space.
At the end we have:
Second time throughIf 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 Mount will be <none>. Under
Newfs, you will find an asterisk (*) instead of the text
UFS Y. The label editor has found the partitions, but it doesn't know
where to mount the file systems. Before you can use them, you must tell
the label editor the types and mount points of the UFS partitions. To do this:
Position the cursor on each of the partitions in turn.
/home
MountNewfs
Press m (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
/, then press return. The label editor will enter the name of the mount
point under Mount, and under Newfs it will enter UFS
N—it knows that this is a UFS file system, so it will just check its
consistency, not overwrite it. Repeat this procedure for /home, and
you're done.
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.
commandfsckfsckcommand
Unless you are very sure that the file system is valid, and you really want to
keep the data in the partitions, press t to specify that the file system
should be created. The UFS N will change to UFS Y. If you
leave the N there, the commit phase will check the integrity of the file
system with fsck rather than creating a new one.
Where we are nowWhen you get to this point in the installation, you have told sysinstall
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.
Selecting distributionsdistributionsselecting
The next step is to decide what to install. Figure
shows us the menu we get when we enter Distributions. 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 All, as
shown, and press the space bar.
Distribution selection menuWhy 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 sysinstall.
The next menu is
XXXX See what's up with crypto.
Next, you see the message:
We'll look at the Ports Collection in . 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.
Whatever you answer to this question, you are returned to the distribution menu
of figure . Press ENTER again, and you're done
selecting your distributions.
Earlier versions of sysinstall asked you questions about XFree86 at this
point. Nowadays we do that after completing the installation.
Installation medium menuWhere we are nowNow sysinstall 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.
Selecting the installation mediuminstallationmediummenumedia
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 shows the
Media 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
Installing via FTPFigure
shows the menu you get when you select FTP or FTP Passive.
Selecting FTP server/usr/ftp/pub/FreeBSD/\*[Fver]-RELEASEcommandsysinstallsysinstallcommand
To see the remainder of the sites, use the PageDown key. We want to
install from presto, a system on the local network. presto isn't
on this list, of course, so we select URL. Another menu appears, asking
for an ftp pathname in the URL form ftp://hostname/pathname.
hostname is the name of the system, in this case
presto.example.org, and pathname is the path relative to the
anonymous ftp directory, which on FreeBSD systems is usually /usr/ftp.
The install program knows its version number, and it attaches it to the name you
supply.
You can change the version number from the options menu, for example in order to
install a snapshot of a newer release of FreeBSD.
In this case, we're installing version of FreeBSD, and it's in the
directory /pub/FreeBSD/-RELEASE. sysinstall knows the
-RELEASE, so we enter only
ftp://presto.example.org/pub/FreeBSD. 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—see page
for details.
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
presto from freebie, since they're both on the same local net.
After entering this information, you continue with Commit (below).
Installing via NFSWe considered the prerequisites for NFS installation on page
. All you need to do at this point is to give this
information to sysinstall, as shown in figure . After
entering this information, sysinstall will ask you to configure an
interface. This is the same procedure which you would otherwise do after
installation—see page . After performing this configuration,
you continue with Commit (below).
Specifying NFS file systemInstalling from floppy disk
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 , page
floppy
The installation itself is straightforward enough: select Floppy and
follow the prompts.
Where we are nowNow sysinstall knows everything it needs to install the software. It's
just waiting for you to tell it to go ahead.
Performing the installation
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.
That changes completely in the next step, which we call committing 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.
If you are installing with the Custom installation, you need to select
Commit explicitly. The Standard installation asks you if you want to
proceed:
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!
commandsysinstallsysinstallcommand
When you answer yes, sysinstall does what we've been preparing
for:
It creates the partitions and disk partitions.
It creates the file system structures in the file system partitions, or it
checks them, depending on what you chose in the label editor.
It mounts the file systems and swap space.
commandsysinstallsysinstallcommand/dev/ttyv1
At this point, two other virtual terminals become available. /dev/ttyv1
shows you what's going on behind the scenes. You can switch to it with
ALT-F2. Right at the beginning you'll see a whole lot of error messages
as sysinstall 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
ALT-F1.
/dev/ttyv3
In addition, after sysinstall mounts the root file system, it starts an
interactive shell on /dev/ttyv3. 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 ALT-F4.
After reading in all the files, sysinstall displays further information
messages:
Remaking all devices.. Please wait!
Making slice entries
Fixing permissions..
And we're done!
commandsysinstallsysinstallcommandWhere we are nowWhen 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.
Network servicesnetworkservices
Figure
shows the Network Services Menu. You don't see this menu in the Standard and
Express installations: after setting up your network interfaces,
sysinstall presents you with various items from the Network Services
Menu. The Custom installation presents you with the menu itself.
Network services menu
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.
Setting up network interfacesnetworkinterfacescommandsysinstallsysinstallcommand
Figure
shows the network setup menu. If you installed via FTP or NFS, you will already
have set up your network interfaces, and sysinstall won't ask the
questions again.
Network setup menu
The only real network board on this list is ep0, 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
shows the network configuration menu after filling in the values.
Network configuration menu
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
, on page . We have chosen to call this
machine presto, and the domain is example.org. In other words, the
full name of the machine is presto.example.org. Its IP address is
223.147.37.2. In this configuration, all access to the outside world
goes via gw.example.org, which has the IP address 223.147.37.5.
The name server is located on the same host, presto.example.org. Since
the name server isn't running when this information is needed, we specify all
addresses in numeric form.
What happens if you don't have a domain name? Well, the simple answer is ``go
out and get one''—see page . But in the meantime, don't fake
it. Just leave the fields empty.
commandsysinstallsysinstallcommandcommandifconfigifconfigcommand
As is usual for a class C network, the net mask is 255.255.255.0. You
don't need to fill in this information—if you leave this field without
filling it in, sysinstall will insert it for you. Normally, as in this
case, you wouldn't need any additional options to ifconfig.Other network optionsYou don't need to specify any of the remaining configuration options during
configuration. See the online handbook for further details.
Machine configurationcommandsysinstallsysinstallcommand
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.
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
shows you the menu that Custom installation presents.
Final configuration menuRebooting the new systemFinally, it's done. You exit the main menu by selecting Quit. Before
you answer the question asking for confirmation, remember to remove the boot
diskette—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.
After that, the system will reboot. The results look much the same as before,
but this time, instead of going in to the sysinstall menu, it continues to
start up the machine and give you a login prompt. We're done!
Where to put /var and /tmp/var/usr/var/var/usr/var
Now the installation is completed, but you may still have some housekeeping to
do. Did you include a /var file system on your disk? In the example,
we didn't. If we don't specify anything else, /var 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 /usr/var and a symbolic link /var which
points to /usr/var:
# mkdir /usr/var create a new directory
# cd /var move to the old /var directory
# tar cf - . | (cd /usr/var; tar xf - ) copy its contents
# cd / get out of the directory
# rm -rf /var and remove it
# ln -s /usr/var /var now link to the new directoryAfter performing these steps, you might see messages like:
Jan 9 13:15:00 myname syslogd: /var/run/utmp: no such file or directory
syslogdSystemLog dægmondægmonSystem Logsyslogd is the System Log dægmon.
See page for a description of dægmons.
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 syslogd:
# ps waux | grep syslogd look for the syslog dægmon
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
# kill -9 58 stop the PID of syslogd
# syslogdand start it again
The PID of the syslogd is the second field on the line which ends with
just syslogd. The first line is the process which is looking for the
text syslogd. See , page
for more information on stopping processes.
/tmpfilesystem/var/tmpfilesystem
Programs should not write large files to /tmp; if a program needs to
create a large temporary file, it should create it in /var/tmp.
Unfortunately, the location of the temporary files is not usually in your hands.
It would be tempting to also replace /tmp with a symbolic link to
/var/tmp, but the system handles /tmp and /var/tmp
slightly differently: after a reboot, it removes all files from /tmp, but
it leaves the files in /var/tmp. You can solve this problem by creating a
directory /usr/tmp and creating a link to it.
Perform the following steps in single-user mode (see , page
for a description of single user mode and how to get into it).
# mkdir /usr/tmp create a new directory
# rm -rf /tmp and remove the old /tmp
# ln -s /usr/tmp /tmp now link to the new directoryInstalling FreeBSD on a Compaq AXP (Alpha) systeminstallingon AlphaAlphainstalling on
FreeBSD 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 ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/alpha/
or on a mirror site.
In principle, you perform the same steps to install FreeBSD on the Alpha
architecture that you perform for the Intel architecture. See page
for some differences.
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
floppies/kern.flp and floppies/mfsroot.flp as described for the
Intel architecture on page . Use the CD-ROM marked ``Alpha
installation''. From the SRM console prompt, insert the kern.flp floppy
and type the following command to start the installation:
>>>boot dva0Insert the mfsroot.flp 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 .
To install over the net, fetch the floppy images from the FTP site, boot as
above, then proceed as for the Intel architecture.
Once the install procedure has finished, you will be able to start FreeBSD/alpha
by typing something like this to the SRM prompt:
>>>boot dkc0This instructs the firmware to boot the specified disk. To find the SRM names of
disks in your machine, use the show device command:
>>>show device
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
This example comes from a Digital Personal Workstation 433au and shows three
disks attached to the machine. The first is a CD-ROM called dka0 and the
other two are disks and are called dkc0 and dkc100 respectively.
You can specify which kernel file to load and what boot options to use
with the -file and -flags options to boot:
>>>boot -file kernel.old -flags sTo make FreeBSD/alpha boot automatically, use these commands:
>>>set boot_osflags a
>>>set bootdef_dev dkc0
>>>set auto_action BOOTUpgrade installation
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.
Changing configurationconfigurationchanging
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 sysinstall after the system is running: it's
called /stand/sysinstall. For an alternative way to configure additional
disks, see , page .
Installing additional softwareemacscommandcommandemacsbashcommandcommandbashlesscommandcommandlesspinecommandcommandpine
Once your system is up and running, you may find that things you expect are
missing. Where's Emacs? Where's bash? Where's less?
They're all there, and just about everything else is as well. We'll look at how
to install them in , starting on page .
How to uninstall FreeBSDuninstallremovingFreeBSD from disk
What, you want to remove FreeBSD? Why would you want to do that?
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 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)
Setting up X11
FreeBSD comes with XFree86
version .,
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
README.FreeBSD and README.Config in the directory
/usr/X11R6/lib/X11/doc. If you find any discrepancy, the material in
those files will be more up-to-date than this description. In addition, the
file /usr/X11R6/lib/X11/doc/RELNOTES contains OS-independent information
about the release.
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.
For the impatientThere'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:
An incorrect installation can burn out your monitor or your video board.
Read page
for further details.
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
, page
If things don't work, come back here and read on.
Installing XFree86The easiest way to install XFree86 is with the sysinstall program,
either when you're installing the system, or later by starting the program
/stand/sysinstall. See , 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.
The XFree86 distributionXF86333
XFree86 is distributed as a bewildering number of archives in the directory
/cdrom/XF86333. 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.
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.
Required components of XFree86
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 to the XFree86 release.
T}
The file X3331upd.tgz updates XFree86 from the base release ()
to release .. 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
CD-ROM include update of XFree86 . They are not
the same as the XFree86 archives on ftp://ftp.XFree86.org/.
The X ServerX
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 /usr/X11R6/bin/X, and it is a
link to a specific server binary /usr/X11R6/bin/XF86_xxxx. You'll
find the server archives for the standard PC architecture in
/cdrom/XF86333/Servers, and the servers for the Japanese PC98 architecture
in /cdrom/XF86333/PC98-Servers:
XFree86 servers for standard PC architecture
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{
>=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}
XFree86 servers for Japanese PC98 architecture
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}
Each of these servers includes a manual page which contains details of supported
chipsets and server-specific configuration options.
A number of archives are provided for X programmers:
XFree86 programmer's files
box, center, tab(#) ;
lfI | lw57 .
Archive#Description
=
X333prog.tgz#T{
config, lib*.a and *.h 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}
X333lkit.tgz#T{
The ``link kit'' for building servers, normal architecture version.
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}
You'll need X333prog.tgz if you intend to install ports of X software.
Finally, XFree86 includes a number of optional parts:
XFree86 documentation
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}
XFree86 setup programs
box, center, tab(#) ;
lfI | lw67 .
Archive#Description
=
X333cfg.tgz
X333cfg.tgz#T{
Customizable xinit and xdm runtime configuration files.
T}
X333set.tgz#T{
The XF86Setup utility, a graphical version of the xf86config
utility that we will look at on page .
T}
X333jset.tgz#T{
The XF86Setup utility, Japanese version, for the normal PC architecture.
T}
XF86Setup is a graphical mode setup program for XFree86, and you may
prefer it to the standard setup program xf86config. You don't need any
special archives for xf86config: it's included in X333bin.tgz.
The first time you install, you will need X333cfg.tgz to create your
initial configuration files. Don't use it when upgrading: it overwrites your
configuration files.
Additional fonts
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}
Unlike the X servers described above, the archives for the following servers are
all in the main directory /cdrom/disk/XF86333:
Miscellaneous servers
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 mmapped
file.
T}
xdmcommandDES
Earlier versions
of FreeBSD
also supplied a separate xdm archive due to export restrictions on the
encryption software included in xdm. FreeBSD
handles encryption in shared libraries now, so that xdm no longer
contains DES, and has been included in the standard archives.
In addition, earlier versions of XFree86 included the archives
X333pex.tgz, with software for 3D applications, and X333lbx.tgz, 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.
Installing XFree86 manuallyIf you don't use sysinstall to install X, you need to perform a number
of steps:
First, create the directories and unpack the required archives.
Choose and install an X server.
Install any updates.
Set up the environment to be able to access X.
Find a virtual terminal in which to run X.
Configure X for your hardware.
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.
Unpacking the archivesYou must unpack the archives as root, since a number of the executables
are set-user-id (they run as root 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 umask value of 022 (permissions
rwxr-xr-x), because the X server requires special permissions. See page
for an explanation of umask.
$ su
Password:
# umask 022If you don't have enough space in the /usr file system, create a directory
on another partition and symlink it to /usr. For example, if you have a
file system /home with adequate space, you could do:
# cd /home
# mkdir X11R6
# ln -s /home/X11R6 /usr/X11R6Next, decide which archives you want to install.
xinitrcxdmX333xdcf.tgzX333fscl.tgz
For a minimal installation, choose /cdrom/XF86333/X333bin.tgz,
/cdrom/XF86333/X333fnts.tgz, /cdrom/XF86333/X333lib.tgz,
/cdrom/XF86333/X333cfg.tgz, and finally any updates, in this case
/cdrom/XF86333/X3331upd.tgz. If you have already configured X for your
hardware, omit /cdrom/XF86333/X333cfg.tgz.
If you are using sh, unpack like this:
# mkdir -p /usr/X11R6
# cd /usr/X11R6
# for i in bin fnts lib cfg 1upd; do
# tar xzf /cdrom/XF86333/X333$i.tgz
# doneIf you are using csh, enter:
% mkdir -p /usr/X11R6
% cd /usr/X11R6
% foreach i (bin fnts lib cfg 1upd)
? tar xzf /cdrom/XF86333/X333$i.tgz
? endIf 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 (1upd): 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
/cdrom/XF86333/X333*.tgz, since that would install the update
(1upd) before most of the other archives. Instead, you need to spell it
out:
# mkdir -p /usr/X11R6
# cd /usr/X11R6
# for i in 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
# tar xzf /cdrom/XF86333/X333$i.tgz
# doneIf you are using csh, enter:
% mkdir -p /usr/X11R6
% cd /usr/X11R6
% 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
? tar xzf /cdrom/XF86333/X333$i.tgz
? endAs with the minimal install, make sure that the abbreviation for the update
archive 1upd comes last.
The prompts during the command (# and >, or %, nothing
and ?) are typical. Depending on your shell, you may get other prompts.
Installing the serverChoose a server archive corresponding to your VGA board. If table
on page
doesn't give you enough information, check the server man pages,
/usr/X11R6/man/man1/XF86_*, 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:
# cd /usr/X11R6
# tar xzf /cdrom/XF86333/Server/X333SVGA.tgz substitute your server name hereIf you are using csh, enter:
% cd /usr/X11R6
% tar xzf /cdrom/XF86333/Server/X333SVGA.tgz substitute your server name hereSetting up the environmentXXF86_SVGA
Next, you may wish to create a symbolic link /usr/X11/bin/X that points
to the server that matches your video board. In this example, it's the
XF86_SVGA server:
# cd /usr/X11R6/bin change to bin directory
# rm X remove the current server
# ln -s XF86_SVGA X and create a link to the new serverX needs this symbolic link in order to be able to work correctly, but you have
the option of setting it when you run xf86config—see below.
profilecsh.loginNext, check that the directory /usr/X11R6/bin is in the default path for
sh in /etc/profile and for csh in /etc/csh.login,
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:
# echo 'set path = ($path /usr/X11R6/bin)' >>/etc/csh.login
# echo 'PATH=$PATH:/usr/X11R6/bin' >>/etc/profileAlternatively, make sure everybody who uses X puts /usr/X11R6/bin in their
shell's PATH variable.
ldconfigld.so
Next, invoke ldconfig to put the shared libraries in ld.so's
cache:
# ldconfig -m /usr/X11R6/libYou can omit invoking ldconfig if you plan to reboot before using X.
X333f100.tgzmkfontdir
You don't need to uncompress the font files, but if you do, you must run
mkfontdir in the corresponding font directory; otherwise your server will
abort with the message ``could not open default font `fixed'\^''.
Assigning a virtual terminal to Xgettycommand
Next, make sure you have a spare virtual console which is running a getty.
First check how many virtual consoles you have:
# dmesg | grep virtual
sc0: VGA color <16 virtual consoles, flags=0x0>
/etc/ttys
Then check /etc/ttys to make sure there is at least one virtual terminal
(ttyvxx device) which doesn't have a getty enabled. Look for
the keyword off:
# grep ttyv /etc/ttys
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 off secure
In this case, /dev/ttyv3 is available, if your kernel has least 4 VTs.
If not, either disable a getty in /etc/ttys by changing on to
off, or build another kernel with more virtual terminals—see
, page
for details of how to set the kernel parameter MAXCONS.
Configuring X for Your HardwareXF86Config
After installing the X software, you will need to customize the file
/usr/X11R6/lib/X11/XF86Config, which tells the X server about your
hardware and how you want to run it.
XF86ConfigreconfigcommandXConfig
The format of XF86Config has changed since version 2 of XFree86. If you
are upgrading from version 2, use the reconfig utility to perform a
partial translation of the old XConfig file to the new format. You'll
still need to make some changes manually.
# reconfig < Xconfig > XF86ConfigXF86ConfigXF86Config.eg
The man page XF86Config(5) and the file
/usr/X11R6/lib/X11/XF86Config.eg will help you complete the changes.
XF86Config
In order to set up XF86Config, you'll need the following hardware
information:
/dev/ttyd0/dev/ttyd1/dev/mse0/dev/psm0
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 /dev/ttyd0 or
/dev/ttyd1 for a serial mouse, /dev/psm0 for a PS/2 mouse, or
/dev/mse0 for a bus mouse.
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.
The parameters of your monitor: vertical and horizontal frequency.
Identifying the hardwareHow do you decide what your hardware is? The manufacturer should 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 anything else about
the display board. As we'll see in , 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.
You could be unlucky trying to get some of this information, but you can get
some with the SuperProbe program. It should always be able to tell you
the chip set and the amount of memory on board.
Occasionally SuperProbe can crash your system. Make sure you are not doing
anything important when you run it.
Running SuperProbe looks like this:
# SuperProbe(warnings and acknowledgements omitted)
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))
SuperProbe is very finicky about running at all, and you'll often get
messages like:
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
In other words, even if no X server is running, SuperProbe won't work if
you have the environment variable DISPLAY set. How do you unset it?
With Bourne-style shells, you enter:
# unset DISPLAYIn the C shell, you enter:
% unsetenv DISPLAYRunning xf86configxf86configcommand
The easy way to create your configuration file is with one of the utilities
xf86config (note the lower case name) or XF86Setup. Both leads
you through the configuration step by step. xf86config runs in
character mode, while XF86Setup runs in a graphical mode.
XF86Setup can have problems with unusual hardware, so I personally
prefer xf86config.
You can also use sysinstall, but this doesn't change much:
sysinstall just starts xf86config for you, and it's easier to
start it directly. In this section, we'll use an example to illustrate
xf86config 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, /dev/ttyd0.
To run xf86config, type in the name. If /usr/X11R6/bin is
included in your PATH environment variable (see page ), you just
need to type xf86config:
# /usr/X11R6/bin/xf86config
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. ENTER
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: 6Logitech 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? nYou 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 ChordMiddle in order to use the button. If you find that the
third button doesn't work when you start X, you can enable ChordMiddle
by editing the configuration file—it's much easier and less error-prone than
re-running XF86Setup. See page for details
of how to edit the configuration file.
Continuing,
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? n
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: /dev/ttyd1Be very careful about this entry: you must specify the correct name for the
device to which the mouse is connected. xf86config is not specific to
FreeBSD, and the suggested example is just plain wrong for FreeBSD. Use the
names /dev/ttyd0 through /dev/ttyd3 for serial mice,
/dev/psm0 for PS/2 mice or /dev/mse0 for a bus mouse. See page
for more details.
Continuing, we see:
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? y
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.
1Choose 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. ENTER
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):
See , page
for an explanation of the warnings.
Unfortunately, our monitor isn't mentioned in the file
/usr/X11R6/lib/X11/doc/Monitors, 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 XF86Config 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:
Enter your choice (1-11): 11
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: 30-64Next, we select the vertical frequency range:
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: 3this time, exactly the range of the monitor
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
xf86config do it for you:
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: ENTER
Enter the vendor name of your monitor: ENTER
Enter the model name of your monitor: ENTERNext 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:
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? y
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.
ENTERDozens of board definitions come in alphabetic order. Finally we see:
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.
117
Your selected card definition:
Identifier: Diamond SpeedStar (Plus)
Chipset: ET4000
Server: XF86_SVGA
Press enter to continue, or ctrl-c to abort.ENTER
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)?
The system already chose XF86_SVGA 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:
Which one of these screen types do you intend to run by default (1-5)? 5
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? yAll the programs that start X (xinit, startx and xdm) start
a program /usr/X11R6/bin/X. This symbolic link makes
/usr/X11R6/bin/X point to your X server. If you don't have a link, you
won't be able to start X.
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: 3
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: ENTER
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: ENTER
Enter the model (board) name of your video card: ENTER
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&T 20C490 (S3 and AGX servers, ARK driver) att20c490
2 AT&T 20C498/21C498/22C498 (S3, autodetected) att20c498
3 AT&T 20C409/20C499 (S3, autodetected) att20c409
4 AT&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.
qWe 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)? ENTER
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>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?
This last question is worth thinking about. You should run X -probeonly
at some point, but it requires some extra work. We'll take the recommendation
and try it later.
Do you want me to run 'X -probeonly' now? n
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:
"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: 5accept 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? nIt'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
n. You might find it useful, especially if your highest resolution is
small.
Now the configuration is complete, and sysinstall just need to write the
configuration file:
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? y
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.
Once you have completed this configuration, you are ready to start X. We'll
look at how to do that in . If you run into trouble, or if you're
interested in the background, read .
The Ports Collectionporting
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—normally called porting—can be a long and frustrating one.
See my book Porting UNIX Software for more details of the porting
process.
In order to get a software package up and running on your system, you need to go
through most of these steps:
archivetarcommandcommandtargzipcommandcommandgzipftpcommandcommandftp
Get the source files on your machine. They are usually contained in an
archive, a file containing a number of other files. Archives used for the
ports collection are generally gzipped tar files, packed with
tar and compressed with gzip, but other formats are also possible.
Whatever the format, you'll typically use ftp to get them to your
machine.
sourcetree
Unpack the archive into a source tree, using gunzip and tar.
Configure the package. Most packages include shell scripts to do this.
Configuration performs a threefold adaptation of the package:
It adapts it to the system hardware.
It adapts it to the software environment you're running (in this case, FreeBSD).
It adapts it to your personal preferences.
Build the package. For most packages, this involves compiling the
source files and creating executables.
Installing the package. This involves mainly copying the executables,
configuration files and documentation created by a build to the correct
place in the directory hierarchy.
Configuring 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.
PortsCollection
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
Ports Collection. In addition, the CD-ROM edition of FreeBSD includes a
large number of pre-built packages which just need to be installed.
In this chapter, we'll consider the following points as they relate to the
FreeBSD ports collection:
How to install a pre-compiled package. We'll look at this in the next section.
What the ports tree is, and how to compile and install (``build'') a package.
We'll look at this on page .
How to create and submit a new port, on page How to install a packageinstallinga packagepackageinstallingpackagesdirectory
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—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 packages 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—check the online handbook for some places to look.
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 /usr/ports/INDEX for a list. For example, emacs under
editors is in the file packages/editors/emacs-20.3.tgz. To
install it, you simply enter:
# pkg_add /cdrom/packages/editors/emacs-20.3.tgzAlternatively, you can install packages from the /stand/sysinstall Final
Configuration Menu. We saw this menu on page in figure on
page . When you start sysinstall from the
command line, you get to this menu by selecting Index, and then
selecting Configure.
Building a portbuildinga portportbuildingportFreeBSD definition
The FreeBSD project uses the term port to describe the additional files
needed to adapt a package to build under FreeBSD. It does not include
the code itself, though many code archives are on the third and fourth CD-ROMs
in the directory /ports/distfiles.
/usr/portsdirectory
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
/usr/ports.
portstree
This directory tree is frequently called the Ports Tree. There are a
number of ways to install them.
Installing ports during system installationportsinstalling
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 Custom
distribution and include the ports collection.
Install ports from the first CD-ROMThe file ports/ports.tgz on the first CD-ROM is a tar 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 /cdrom), and enter:
# cd /usr
# tar xzvf /cdrom/ports/ports.tgzIf you only want to extract a single package, say inn, which is in the
category news, enter:
# cd /usr
# tar xzvf /cdrom/ports/ports.tgz ports/news/innInstalling ports from the ports CD-ROMAlternatively, 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 ports on the CD-ROM. Let's
assume you have found a directory /ports/graphics/hpscan on the CD-ROM,
and it is your current working directory. You can move the data across with the
following:
# cd /cdrom/ports/graphics
# mkdir -p /usr/ports/graphics
# tar cf - . | (cd /usr/ports/graphics; tar xvf -)Ports via FTPportsvia FTP
Of course, maybe you've just heard about this great new port of
xmbase-grok, 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.
All ports are kept in subdirectories of the URL
ftp://ftp.FreeBSD.org/pub/FreeBSD. The directory
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/ports contains ports for
FreeBSD-CURRENT (see , page ). The other
directories are named after the release. For example, for FreeBSD-3.2, you
would select ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/ports-3.2. To get
this one, you might perform the following steps:
# ftp ftp.freebsd.org
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.
\&...lots of blurb omitted
ftp> cd /pub/FreeBSD/ports/ports-3.2/databases
250 CWD command successful.
ftp> ls -ltr
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> get xmbase-grok.tar.gz
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)
Since xmbase-grok is a directory, you tell ftp to automatically
tar and gzip the directory and return you a file
xmbase-grok.tar.gz. Not all ftp servers support tarring and gzipping,
since gzipping in particular takes up a lot of CPU time.
Next, you unpack it in your /usr/ports/databases directory:
# cd /usr/ports/databases/
# tar xzvf /home/Book/FreeBSD/xmbase-grok.tar.gz
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
What's in that port?
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:
You can print the index with the following commands:
# cd /usr/ports
# make print-index | lprYou can search for a specific keyword with the search target. For
example, to find ports related to Emacs, you might enter:
# cd /usr/ports
# make search key=EmacsYou can build a series of html pages like this:
# cd /usr/ports
# make readmesYou can then browse them at the URL file:/usr/ports/README.html.
You can find a printable version in the files /cdrom/docs:
Ports overview
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 .
Ports via CVSupportsvia CVSup
If you're using CVSup to keep up to date with the source tree, you have
the option of including the ports tree /usr/ports in the trees you
maintain. See page for more details.
Getting the source archiveYou'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!
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 make, 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.
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
/\f(CIcdrom/ports/distfiles. The ports collection Makefiles look for
them in this directory (another good reason to mount your CD-ROM on
/cdrom) and also in /usr/ports/distfiles.
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, /cd4), 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
/cd4/ports/distfiles to /usr/ports/distfiles. The trouble with
this approach is that you will then no longer be able to load new distribution
files into /usr/ports/distfiles, since it will be on CD-ROM. Instead, do:
# cd /cd4/ports/distfiles
# mkdir -p /usr/ports/distfiles make sure you have a distfiles directory
# for i in *; do
> ln -s /cd4/ports/distfiles/$i /usr/ports/distfiles/$i
> doneIf you're using csh or tcsh, enter:
# cd /cd4/ports/distfiles
# mkdir -p /usr/ports/distfiles make sure you have a distfiles directory
# foreach i (*)
? ln -s /cd4/ports/distfiles/$i /usr/ports/distfiles/$i
? endThis 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.
Building the portbuildingportsportsbuilding
Once you have the skeleton files for the port, the rest is simple. Just enter:
# cd /usr/ports/databases/xmbase-grok
# make
# make installIt's a good idea to perform the make step first: make install
does not always build the package.
Port dependenciesportsdependencies
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, tkdesk depends on tk. tk depends on tcl.
If you don't have any of them installed, and you try to build tkdesk, it
will recursively install tk and tcl for you.
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 tkdesk
depends on tk version 4.1. Older versions depended on version 3.6. If
you update the directory /usr/ports/x11/tkdesk, but not
/usr/ports/x11/tk, the build will probably fail.
There are two possible solutions to this problem:
CVSupcommandcommandCVSupctmcommandcommandctm
Keep the tree up to date with CVSup or ctm (see ).
Check the dependencies, and update them manually.
To check the dependencies, look at the Makefile. For example, the current
version of /usr/ports/x11/tkdesk/Makefile contains:
# New ports collection makefile for: tkdesk
# Version required: 1.0b2
# Date created: 30 Jul 1996
# Whom: shanee@rabbit.augusta.de
#
# $I\&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 look at this line
post-patch:
-rm ${WRKSRC}/tcldesk/*.orig ${WRKSRC}/tcldesk/*/*.orig
\&.include <bsd.port.mk>
The definition LIB_DEPENDS tells you the dependencies. In this case, it
will first look for the libraries /usr/lib/libtk41.so.1.0 or
/usr/local/lib/libtk41.so.1.0. If it finds them, it will be satisfied.
Otherwise it will build the port at /usr/ports/x11/tk41. The make
variable PORTSDIR represents the name of the top-level ports directory,
currently /usr/ports.
Getting common softwareGettingcommon softwarenetscapecommandcommandnetscape
A lot of software doesn't need to be ported. For example, if you want
Netscape, you can just download it from ftp.netscape.com. In fact,
you have a choice of three different versions of Netscape: you can take
the native FreeBSD version, the BSD/OS version or the Linux version.
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.
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.
StarOfficecommandcommandStarOffice
This method can be used to install some other software as well, for example
StarOffice. The moral is simple: always check the ports collection before
getting a software package from the net.
Maintaining portsmaintainingportsportsmaintaining
Once you install a port, you might consider that to be the end of the story.
That's seldom the case. For example:
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?
You might need to replace a port by a newer version. How do you do it?
Controlling installed portscontrollinginstalled portsportscontrolling
We've already seen the program pkg_add when installing pre-compiled
packages. There are a number of other pkg_ programs which can help you
maintain installed ports, whether they have been installed by pkg_add or
by make install from the Ports Collection:
pkg_infocommandcommandpkg_infopkg_info will tell you which ports are installed. For example,
$ pkg_info -I -a | sort -f | less
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
\&... etc
elm-2.4ME+22 ELM Mail User Agent
elm-2.4ME+32 ELM Mail User Agent
\&... etcpkg_listcommandcommandpkg_list
The option -a tells pkg_list to list all packages; otherwise you
should specify a package name. The option -I specifies that the list
should be a one-line ``Index'' description; otherwise you get a multi-line
description of the package.
By default, pkg_info lists the packages in the order in which they were
installed, which is not normally of great interest. By piping into the command
sort -f, we get it in alphabetical order. The -f flags tells
sort to fold upper case into the same sort order as lower case;
otherwise all packages with names starting with a capital letter would come
first. Finally, less allows us to page through what could be a very
long list.
Note the advantage of sorting in this example: it seems we have two versions of
apache and two versions of elm installed, probably not what we
intended. If it had been unsorted, it would be difficult to discover this fact.
pkg_deletecommandcommandpkg_delete
You can remove a package with pkg_delete. You need to be
root to do this. For example, the list above shows two versions of the
elm mail user agent. To remove the older one, we enter:
# pkg_delete elm-2.4ME+22
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'
\&... etc
Couldn't entirely delete package (perhaps the packing list is
incorrectly specified?)
In this case, it looks as if somebody has tried to remove the files before, so
pkg_delete couldn't do so.
Another problem with pkg_delete is that it might delete files of the
same name which have been replaced by newer packages. After performing this
operation, we try:
$ elm
bash: elm: command not found
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.
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 both packages and re-install the one you
want to keep.
Keeping track of updatesThe best way to find out about updates is to subscribe to the
FreeBSD-ports 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.
Submitting a new portsubmittinga portportssubmitting
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?
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:
Read the instructions before starting the port. There are many ways to
port a package—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.
Write a top-level Makefile 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).
Perform the port.
Submit it.
Installation ProblemsIn , and , we saw what should 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.
If things go wrongIn this section, we'll look at the most common installation problems. Before
you start, though, a couple of general recommendations:
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 -v (verbose) flag: enter it at the Boot: prompt:
Boot: -vIt will give you additional information which might help diagnose the problem.
If you get the system installed to the point where you can start it, but it
doesn't run quite the way you want, don't reinstall. In most cases,
reinstallation doesn't help. Instead, try to find the cause of the
problem—with the aid of the FreeBSD-questions mailing list if
necessary—and fix the problem.
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:
Modify the kernel's viewpoint to match the hardware. See page
for an example of how to do this.
Modify the hardware to match the kernel's viewpoint. Check your hardware
manuals to do this.
Beyond these problems, however, specific hardware or combinations of hardware
can cause problems. Check out the file TROUBLE.TXT on the first CD-ROM
for details of specifics. In the following sections we'll look at the more
common cases that it mentions.
Problems with sysinstallcommandsysinstallsysinstallcommandsysinstall 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.
Problems with CD-ROM installationIf you select to install from CD-ROM, you may get the message:
No CD-ROM device found
This might even happen if you have booted from CD-ROM! The most common reasons
for this problem are:
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
CTRL-ALT-DEL or the reset button, or power cycle the computer).
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
FreeBSD-questions@FreeBSD.org and describe your CD-ROM as accurately as
you can.
You have an old proprietary CD-ROM drive which is not set up the way the generic
kernel expects it. See page 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—see page
Install tries to install from floppycommandsysinstallsysinstallcommand
Sometimes when an installation medium fails, sysinstall decides to try
to get the root file system from floppy. For some reason, you can't cancel this
menu. Instead, just let sysinstall look for the file system on the
floppy. When it doesn't find it, it'll give up by itself.
Can't bootOne 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).
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.
Still, all is probably not lost. The two most frequent causes of boot failure
are:
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:
Boot: hd()kernelAfter booting, install the correct bootstrap with disklabel -B, and you
should be able to boot from hard disk again.
Things might continue a bit further: you elect to install booteasy, and
when you boot you get the Boot Manager prompt, but it just prints F? 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.
Can't find correct geometryIf 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 for further details.
Alternatively, if you don't want to share your disk with any other operating
system, select the option to use the entire disk (a in the partition
editor). This will leave all geometry considerations aside.
System hangs during bootA number of problems may lead to the system hanging during the boot process.
Here are a couple:
After installation, you might find that the system hangs after the message:
Changing root to /dev/da0a
Ethernet3Com 3C5093Com3C509
This may happen if your system has a 3com 3c509 Ethernet adapter. The
ep device driver is sensitive to probes for other devices that also use
the same address (by default address 0x300). 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 Boot: prompt specify the -c option to invoke
UserConfig and use the disable command to disable the device
probes for all devices at address 0x300 except the ep0 driver.
After this, your machine should boot successfully.
Sometimes the system appears to hang after the message:
fd0: 1.44MB 3.5in
fd1: 1.2MB 5.25in
In fact, this usually isn't a hang, just a very long probe for wdc0.
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:
wdc0 at 0x1f0-0x1f7 irq 14 on isa
wdc0: unit 0 (wd0): <WDC AC2200F>
wd0: 202MB (415380 sectors), 989 cyls, 12 heads, 35 S/T, 512 B/S
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 wdc1, or by building a custom kernel.
When booting from floppy, the system might hang after the message:
Uncompressing kernel...
This is normally an indication that you have a memory problem (not enough
memory, faulty cache, or incorrect chipset parameters).
Panic: cannot mount rootIf you install FreeBSD on any disk except the first, you might find that the
boot proceeds normally, but then dies with the message:
changing root device to wd1s1a
panic: cannot mount root
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.
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:
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 wd0 and wd2, in other words
disk 2. To tell the loader how to find it, stop it before booting and enter:
disk1s1a:> boot 1:wd(2,a)kernel
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.
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:
disk1s1a:> boot 2:da(0,a)kernel
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 1:
instead.
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
/boot.config. FreeBSD uses the contents of this file as the default
response to the boot:prompt.
Can't find Intel EtherExpress boardA couple of problems can prevent recognition of an EtherExpress board:
You don't have a choice of I/O parameters for the EtherExpress 16. You must set
it to be memory mapped at address 0xD0000, and set the amount of mapped
memory to 32K using the Intel-supplied program softset.exe.
The mcd driver can mistakenly recognize Intel EtherExpress boards as
mcd devices. Check the dmesg output: if it claims to have an
mcd0 device, disable the mcd driver in UserConfig. See page
for details of UserConfig.
Can't see 3Com PCMCIA boardThere are a couple of possible problems in this area:
FreeBSD does not support multi-function boards such as the 3C562 ethernet/modem
board.
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.
No packets are transmitted on PCMCIA network boardMany 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
ifconfig flags link0, link1 and link2.
Typically, one of the following commands selects the correct connector:
# ifconfig zp0 -link0 link1
# ifconfig zp0 link0 -link1Check the man page for your board for the details: they vary from one board to
another. You can set these flags in sysinstall by using the Extra
options to ifconfig: field in the network setup screen.
Device timeout on ed Ethernet boardsYou might find that the system finds your ed board, but after starting up
the system you get device timeout errors. There are two typical reasons for
this:
The Ethernet board may not be correctly attached to the network. If it's not
connected, you at least need a terminator.
Your board is set up for a different IRQ from what the kernel expects. By
default, the ed driver does not use the ``soft'' configuration (values
entered using EZSETUP in MS-DOS), but it will use the software configuration if
you specify ? in the IRQ field of your kernel config file.
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 -1 in UserConfig or ? in your kernel config
file. This will tell the kernel to use the soft configuration.
Devices at IRQ 9 don't workYou 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.
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.
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 do cut the wrong one by mistake, you can solder it back again
relatively easily.
Kernel doesn't find Matsushita/Panasonic CD-ROMIf you have a Matsushita/Panasonic CD-ROM, and the kernel doesn't recognize it,
check that the port address for the matcd 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.
If you can't figure out the settings by examining the board or documentation,
you can restart the system and use UserConfig (see page ) to
change the address to -1. 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 port set to -1 increases the amount of time that
it takes the system to boot, and this could interfere with other devices.
MatsushitaCD-562MatsushitaCD-563MatsushitaCD-522MatsushitaCD-523PanasonicCD-562PanasonicCD-563PanasonicCD-522PanasonicCD-523TeacCD55aCD-ROMMatsushita CD-562CD-ROMMatsushita CD-563CD-ROMMatsushita CD-522CD-ROMMatsushita CD-523CD-ROMPanasonic CD-562CD-ROMPanasonic CD-563CD-ROMPanasonic CD-522CD-ROMPanasonic CD-523CD-ROMTeac CD55a
FreeBSD 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—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.
Can't install from tapeIf you try to install from tape you might get messages like:
sa0(aha0:1:0) NOT READY csi 40,0,0,0
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.
Can't detect SCSI boards on HP NetserverThere 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.
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:
eisa 12
quit
Later, you can compile a custom kernel with the option line
options EISA_SLOTS=12
Can't install on Panasonic AL-N1 or Rios ChandlerFor 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 i586_copyout and
i586_copyin functions. To disable this, boot the installation boot
floppy and enter UserConfig and type the following at it:
flags npx0 1
quit
Then proceed normally to boot. This will be saved into your kernel, so you only
need to do it once.
Problems with the CMD640 IDE controllerThis 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
options "CMD640"
Can't find the floppy on Compaq Aero notebookCompaq 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 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.
Read errors on Intel AL440LX based systemsThe AL44LX is also called Atlanta. 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).
Can't recognize Dell DSA on Poweredge XEBy 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 0x340. In emulation mode the system will use the DSA RAID disks,
but you cannot use DSA specific features such as watching RAID health.
Can't use the AMD PCnet-FAST Ethernet boardThese boards are fitted to machines such as the IBM Netfinity 5xxx or 7xxx
series. The lnc 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.
Can't operate IBM EtherJet boardSometimes the fxp 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.
IBM Netfinity 3500 freezes during network installationThere 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.
TEAC CD-220E (rev 1.0D) IDE CD-ROM hangs the systemThere 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.
Root file system fills upYou 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—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.
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
/tmp and /var file systems. See page for
further information.
Panicpanic
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
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...
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 General protection error, which doesn't tell you very much either.
When a UNIX system panics, it tells you why—in this case here, the reason is
free vnode isn't. 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
do 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—if you get
one—will be ``What was the panic string?''
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.
dumpingthe system
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 dumping 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 /etc/defaults/rc.conf, you will find:
dumpdev="NO" # Device name to crashdump to (if enabled).
To enable dumping, put something like this in /etc/rc.conf:
dumpdev=/dev/wd0s1b
If you don't already have a file /etc/rc.conf, just create it. Make sure
that the name of the dumpdev corresponds to a swap partition with at
least as much space as your total memory. You can use pstat to check
this:
# pstat -s
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%
As long as this machine doesn't have more than about 192 MB of memory, it will
be possible to take a dump on /dev/da2b.
In addition, ensure you have a directory /var/crash. 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 /var/crash.
It's always worth enabling dumping, assuming your swap space is at least as
large as your memory. You can analyze the dumps with kgdb—see the
online handbook for more details.
To get the best results from a dump analysis, you need a debug kernel.
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 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.
Fixing a broken installationFixitfloppy
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:
Boot from the second CD-ROM (Live Filesystem). It will be mounted as
the root file system.
floppies/fixit.flp
Boot from the Fixit floppy. The Fixit floppy is in the distribution in
the same directory as the boot diskette, floppies. Just copy
floppies/fixit.flp to a disk in the same way as described for boot
diskettes in page . 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 /mnt2.
/mnt2mount point
In either case, the hard disks aren't mounted: you might want to do repair work
on them before any other access.
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.
\" This file is in -*- nroff-fill -*- mode
XFree86 configuration in depthIn most cases, the information in , 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.
In the next section, we'll look at the technical background, and on page
we'll look at setting up the XF86Config file.
X configuration: the theory
Setting up your XF86Config 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:
How display boards and monitors work.
How to set up XFree86 to work with your hardware.
How to tune your hardware for maximum display performance.
How to fry your monitor.
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 please don't start tuning until you understand the dangers
involved.
How TVs and monitors workYou 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.
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.
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.
deflectionunitsdeflectionhorizontaldeflectionverticaldeflectionlinedeflectionframe
To perform this scan, the TV has two deflection units: one scans from left
to right, and the other scans, much more slowly, from top to bottom. Not
surprisingly, these units are called the horizontal and vertical
deflection units. You may also encounter the terms line and frame
deflection.
flybackhorizontalflybackvertical
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 horizontal flyback, 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 vertical flyback, 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—about the only thing I can suggest is
to get hold of the book.
\}
Figure
shows the resultant pattern.
[
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)
"etc" 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
]
Scanning pattern on the monitorIt'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.
videoblankingporchfrontporchback
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 blanking, and
the delays are called the front porch (before the sync pulse) and the
back porch (after the sync pulse).
In the printed version of this book there's another diagram here.
\}
Figure
depicts a complete scan line.
p3=.3i
p02=.02i
p1=.1i
p15=.15i
p05=.05i
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)
"Registers:" at HDE.w - (p80,0i)
Scan line and register valuesinterlacing
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
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 interlacing: 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.
How monitors differ from TVsSo how do we apply this to computer displays? Let's look at the US standard
NTSC system—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,
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.
we need to have one-third more pixels per line. This means that we can display
640 pixels per line on 480 lines.
Does this look familiar? Now you know why.
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.
The first problem is interlace: it works reasonably for TVs, but it's a pain for
computer displays—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—the resultant picture looks out
of focus and is very tiring to read.
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—we'll see
how high further down.
How to fry your monitorlinetransformer
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 line transformer) 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.
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,
Color Graphics Adapter and Hercules Display Adapter.
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.
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—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:
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.
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.
videocompositecompositevideo
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 red signal, the green signal, the blue signal, and
the horizontal and vertical sync pulses. This kind of signal is called
composite video. 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—this could be one of the reasons.
The CRT controller
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.
dotclock
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 dots. To count, we need a
pulse source, which also determines the duration of individual dots, so it is
normally called a dot clock. 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—see the
diagram on page
registerHorizontal Display End
The Horizontal Display End 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.
registerStart Horizontal Retrace
The Start Horizontal Retrace
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.
registerEnd Horizontal Retrace
The End Horizontal Retrace
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.
registerHorizontal Total
The Horizontal Total
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.
registerStart Horizontal BlankingregisterEnd Horizontal Blanking
In addition, the Start Horizontal Blanking and End Horizontal
Blanking 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.
registerVertical Display EndregisterStart Vertical RetraceregisterEnd Vertical RetraceregisterVertical TotalregisterStart Vertical BlankingregisterEnd Vertical Blanking
The control of the vertical deflection is similar. In this case, the registers
are Vertical Display End (VDE), Start Vertical Retrace (SVR), End
Vertical Retrace (EVR), Vertical Total (VT), Start Vertical
Blanking (SVB), and End Vertical Blanking (EVB). The values in these
registers are counted in lines.
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.
The XF86Config mode lineOne 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:
Modeline "640x480a" 28 640 680 728 776 480 480 482 494
These ten values are required. In addition, you may specify modifiers at the
end of the line. The values are:
XF86Config
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 XF86Config 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
a at the end of the label is a clue that it's an alternative value.
The clock frequency, 28 MHz in this example.
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.
The Start Horizontal Retrace (SHR) value.
The End Horizontal Retrace (EHR) value.
The Horizontal Total (HT) value.
The Vertical Display End (VDE) value. This value and the three following are
specified in lines.
The Start Vertical Retrace (SVR) value.
The End Vertical Retrace (EVR) value.
The Vertical Total (VT) value.
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 your system. 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.
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:
Horizontal sync pulse: 1 to 4 \(*ms, front porch 0.18 to 2.1 \(*ms, back porch
1.25 to 3.56 \(*ms.
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—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.
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.
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.
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.
You now need to calculate four register values to define the horizontal lines:
The first value is the Horizontal Display End, the number of pixels on a line.
We know this one: it's 640.
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.
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.
The final horizontal value is HT. Again, we add the front porch—64 dot
clocks—to EHR and get 768 + 64 = 832.
At this point, our vestigial mode line looks like:
Modeline "640x480" 28 640 704 768 832
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?
To figure that out, we need to know our real 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—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—they're just values which the monitor can accept.
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:
VDE is 480.
SVR is 481.
EVR is 483.
VT is 493.
Now our mode line is complete:
Modeline "640x480" 28 640 704 768 832 480 481 483 493
XF86config
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—that's
not bad either. By comparison, if you use the standard entry in
XF86config, you will get a horizontal frequency of 31.5 kHz and a vertical
frequency of only 60 Hz.
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.
XF86ConfigXF86ConfigXF86ConfigXF86Config.egXF86Config
The XF86Config file contains several sections; these procedures will
lead you through filling out each part. There is a sample XF86Config
file in /usr/X11R6/lib/X11/XF86Config.eg. You can copy this to
/usr/X11R6/lib/X11/XF86Config, and edit that file to your specific
configuration. In the following examples, we'll look at the relevant sections
of XF86Config and discuss what might need changing. Refer to the man
page XF86Config(5) as you fill in your XF86Config file. Table
overleaf, gives you an overview of the sections in XF86Config. Note that
the X server treats lines beginning with # as comments. You'll see many
definitions with a # in front of them in the following examples. You
activate the definition by removing the #.
Normally, you'll set up your XF86Config when you run the
xf86config program (note the difference in character case; in UNIX,
XF86Config and xf86config are two different file names). We
looked at that in , on page
The following discussion will apply equally well to the XF86Config file
that you generate by this procedure.
XF86Config sections
center,box,tab(#) ;
| l | lw67 | .
Section#Description
=
Files Sets the default font and RGB paths—see page .
Server Flags Sets a few general server options. Refer to the server manual page for more information about them.
Keyboard Sets up keyboard devices, and sets a few optional parameters—see page Pointer Sets up the pointer devices, and sets a few optional parameters—see page Monitor Describes your monitor to the server—see page Device Describes your video hardware to the server—see page Screen Describes how to use the monitor and video hardware—see page
The Files sectionXF86ConfigFiles section
The Files section of the XF86Config 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 FontPath lines in
your XF86Config are concatenated to form a search path. Ensure that
each directory listed exists and is a valid font directory.
The standard Files section looks like:
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
Sometimes the server complains about:
Can't open default font 'fixed'
mkfontdircommand
This is almost certainly the result of an invalid entry in your font path. Try
running mkfontdir in each directory if you are certain that each one is
correct. The XF86Config man page describes other parameters that may be
in this section of the file.
The Keyboard sectionXF86ConfigKeyboard section
The Keyboard section specifies the keyboard protocol, the repeat rate, and
the default mapping of some of the modifier keys:
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
About the only thing you're likely to want to change are the definitions of the
modifier keys for non-English keyboards. See the XF86Config(5) man page
for details.
The Pointer sectionXF86ConfigPointer section
The Pointer section specifies the pointer protocol and device, which is
almost always a mouse.
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
These values are defaults, and many are either incorrect for FreeBSD (for
example the device name /dev/com1) or do not apply at all (for example
Xqueue). If you are configuring manually, select one Protocol
and one Device entry from the following selection. If you must use a
two-button mouse, uncomment the keyword Emulate3Buttons—in this mode,
pressing both mouse buttons simultaneously within Emulate3Timeout
milliseconds causes the server to report a middle button press.
Section "Pointer"
Protocol "Microsoft" for Microsoft protocol mice
Protocol "MouseMan" for Logitech mice
Protocol "PS/2" for a PS/2 mouse
Protocol "Busmouse" for a bus mouse
Device "/dev/ttyd0" for a mouse on the first serial port
Device "/dev/ttyd1" for a mouse on the second serial port
Device "/dev/ttyd2" for a mouse on the third serial port
Device "/dev/ttyd3" for a mouse on the fourth serial port
Device "/dev/psm0" for a PS/2 mouse
Device "/dev/mse0" for a bus mouse
Emulate3Buttons only for a two-button mouse
EndSection
You'll notice that the protocol name does not always match the manufacturer's
name. In particular, the Logitech 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.
If you are using a bus mouse or a PS/2 mouse, make sure that the device driver
is included in the kernel. The GENERIC kernel contains drivers for both
mice, but the PS/2 driver is disabled. Use UserConfig (see page )
to enable it.
The Device sectionXF86ConfigDevice section
The Device section describes the video hardware. You can specify multiple
device sections, each section describing a single graphics board. Here are some
typical examples:
# 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
Be sure to read the server manual pages and the chipset-specific README
files for any non-generic information that may apply to your setup.
To create a Device section you need to collect the data for your hardware,
and make some configuration decisions. The hardware data you need is:
Chipset
Amount of video memory
Dot-clocks available or clock chip used (if programmable)
Ramdac type (for some servers)
XF86ConfigChipset specification
The server can usually determine this information on its own, but it is best to
fully specify things in the XF86Config file, so that no mistakes are made.
The Chipset is one of the keyword strings for a configured driver—you
can display it with
$ X -showconfig
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
Note that the operating system is reported as FreeBSD 3.0-CURRENT. 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.
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.
devicesXF86Config entrymodeDB.txtAccelCards
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
/usr/X11R6/lib/X11/doc/Devices. If you find one for your board, you can
start with that. Also, the first part of the file
/usr/X11R6/lib/X11/doc/modeDB.txt lists information for a myriad of SVGA
boards. For accelerated boards, you can also look in the file
/usr/X11R6/lib/X11/doc/AccelCards. If you find your board, copy the
numbers from the database to the Clocks line in your XF86Config 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
XF86Config file to identify the type of clock generator. For example,
for a #9 GXe board you would specify
ClockChip "icd2061a"
If you can't find a listing for your board, you can attempt to have the server
detect them. Run the command:
$ X -probeonly >/tmp/out 2>&1 for sh, ksh, bash, or zsh
% X -probeonly >&/tmp/out for csh or tcshBe sure that the XF86Config 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 /tmp/out
for the detected dot-clocks. Copy these to the Clocks line in your
XF86Config file, exactly as they appear in /tmp/out. Don't sort
them or rearrange them in any way.
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 comp.windows.x.i386unix.
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 Ramdac and DacSpec. 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.
You may need to specify some option flags for your hardware. The server manual
pages will describe these options, and the chipset-specific README files
will tell you if any are required for your board.
Configuring the Monitor and its ModesVideoModes.doc
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 /usr/X11R6/lib/X11/doc/VideoModes.doc.
The Monitor sectionXF86ConfigMonitor sectionMonitorsdocumentation
The monitor specs and video modes are described in the Monitor sections in
the XF86Config file:
# 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
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 /usr/X11R6/lib/X11/doc/Monitors to see if it
has an entry for your monitor. The XF86Config man page describes how to
enter this information into the Monitor section.
Next, you need to provide a set of video modes that are suitable for the
monitor. The first step is to check in the Monitors and modeDB.txt
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 XF86Config file.
Verify that there is a clock listed on the Clocks line in your XF86Config
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.
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
/usr/X11R6/lib/X11/doc/README.Config. 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 XF86Config 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 Fixing Problems
with the Image in VideoModes.doc.
A note before you are done. If the same mode name occurs more than once in the
Monitor section of the XF86Config 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 XF86Config file.
The Screen sectionXF86ConfigScreen section
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
Screen sections in the XF86Config file:
# 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
Supply a Screen section for each of the server driver types you will be using.
The driver types are SVGA (XF86_SVGA), VGA16
(XF86_VGA16), VGA2 (XF86_Mono), MONO
(XF86_Mono, XF86_VGA16), and ACCEL (XF86_S3,
XF86_Mach32, XF86_Mach8, XF86_Mach64, XF86_8514,
XF86_P9000, XF86_AGX, and XF86_W32). Each Screen section
specifies which Monitor description and Device description are to be used.
The Screen sections include one or more Display 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 root window larger than can be displayed on your monitor. For
example, you can have an 800x600 display, but a 1280x1024 virtual size. Use the
keyword Virtual 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.
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 Monitor section. By
convention, these names are the display resolution (for example
1024x768), 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 Ctrl-Alt-Keypad+ or Ctrl-Alt-Keypad- hotkey sequences.
Making friends with FreeBSDSo 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:
FreeBSD (freebie.example.org) (ttyv0)
login:
Where do you go from here? This chapter tells you.
AbrahamsPaul W.LarsonBruce R.PeekJerryO'ReillyTimLoukidesMikeNemethEviSnyderGarthSeebassScottHeinTrent R.
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 UNIX for the
Impatient, by Paul W. Abrahams and Bruce R. Larson, UNIX Power Tools,
by Jerry Peek, Tim O'Reilly, and Mike Loukides, and UNIX System
Administration Handbook, by Evi Nemeth, Garth Snyder, Scott Seebass, and
Trent R. Hein. See , for more information.
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
.
In this chapter, we'll look at FreeBSD from the perspective of a newcomer with
no UNIX background. If you do have a UNIX background, you may still
find it interesting. Specifically, we'll consider:
Your primary interface with FreeBSD is via the shell. 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.
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 we'll
look at how to define users.
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
Not all users are created equal. In particular, the system administration login
root has power over all other users. We'll look at this topic on page
UNIX implements multi-tasking via a mechanism called processes. We'll
look at them on page .
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
we'll look at how to ensure that your system is running the
correct time.
Other aspects of FreeBSD are so extensive that we'll dedicate separate chapters
to them. We'll look at them in , , , and
. In particular, on page we'll see how to access multiple
``terminals'' or windows.
Differences from other environmentsDifferencesfrom other environments
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.
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:
Upper and lower case namesFilenames
UNIX file names are case-sensitive: the names FOO, Foo and
foo 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 Blödsinn?
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: / 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 NUL
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.
This isn't the problem it used to be: web browsers have made UNIX file names
more popular with Uniform Resource Locators or URLs. We'll look
at them on page .
File names and extensionsThe 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 foo.bar.bazzot are perfectly valid file names. The system
doesn't assign any particular meaning to file name extensions; instead, it looks
for magic numbers, specific values in specific places in the file.
Globbing charactersglobbingcharacterscharactersglobbing
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 *, ? and the square brackets
[]. UNIX calls these characters globbing characters. The
Microsoft usage comes from UNIX, but the underlying file name representation
makes for big differences. Table gives some examples.
box,center,tab(#) ;
lfCWp9 | lw32 | lw32 .
Name#Microsoft meaning#UNIX meaning
=
CONFIG.*#T{
All files with the name CONFIG, no matter what their extension.
T}#T{
All files whose name starts with CONFIG., 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 CONFIG and an extension which starts with
BA, no matter what the last character.
T}#T{
All files which start with CONFIG.BA 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 foo[127].
T}#T{
foo1, foo2 and foo7.
T}
Globbing examplesShell parametersShellparametersparametersshellparsingargumentshellwhitespacespacewhite
When you invoke a program with the shell, it first parses the input line
before passing it to the program: it turns the line into a number of parameters
(called arguments in the C programming language). Normally the
parameters are separated by white space, either a space or a tab
character. If you write a program or script foo, and invoke it like this:
$ foo and a lot morethe 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
What happens if you want to pass a name with a space? For example, you might
want to look for the text ``Mail rejected'' in a log file. We have a
program for looking for text, called grep. The syntax is:
grep expressionfilesArgument 1 is the expression; all additional arguments are the names of files to
search. We could write
$ grep Mail rejected /var/log/maillogbut that would try to look for the text Mail in the files
rejected (probably causing an error message that the file did not exist)
and /var/log/maillog (where just about every line contains the text
Mail). That's not what we want. Instead, we do pretty much what I
wrote above:
$ grep "Mail rejected" /var/log/maillogIn other words, if we put quote characters "" around a group of words,
the shell will interpret them as a single parameter. The parameter that is
passed to grep is Mail rejected, not "Mail rejected".
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.
It's even more interesting to see what happens when you pass a globbing
character to a program, for example:
$ cc -o foo *.cThis invocation compiles all C source files (*.c) and creates a program
foo. 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 *.c 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.
Fields which can contain spacesThe 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 (:) 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
, in the login class file on page , and in the
PATH environment variable on page .
Slashes: backward and forwardrootdirectoryslashcharacterescapecharactercharacterslashcharacterescape
Some of the most confusing characters in computers are / and \e.
UNIX uses / to delimit directories: for example, /etc/fstab
starts from the root directory (/), and represents the directory
etc inside this directory, and the file fstab within that
directory. The backslash \e is called an escape character it
has a number of different purposes:
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 Mail rejected to "Mail rejected" to stop the shell
from interpreting it. We could also have written it like this:
Mail\e\ rejected.
quoting
A more common use for this quoting 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 immediately before the end of the line:
$ grep \e
"Mail rejected" \e
/var/log/maillogDon't put any spaces between the \e 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.
controlcharacterscharactercontrol
In the C programming language, the backslash is used to represent several
control characters. For example, \en means ``new line''. This
usage appears in many other places as well.
Using \e as an escape character causes problems: how do we put a
\e character on a line? The answer: quote it. Write \e\e when
you mean \e. This causes particular problems when interfacing with
Microsoft—see page for an example.
There are many more such surprises in store; take a look at UNIX Power
Tools for a good overview.
Tab charactersTabcharacterscharactertabmakecommandcommandmakesendmailcommandcommandsendmailsyslogdcommandcommandsyslogd
We've seen that the shell treats white space, either spaces or tab characters,
as the same. Unfortunately, some other programs do not. make,
sendmail and syslogd make a distinction between the two kinds of
characters, and they all require tabs (not spaces) in certain places. This is a
real nuisance, since hardly any editor makes a distinction between them.
Carriage control charactersCarriageReturn characterLineFeed charactercharactercarriage returncharacterline feed
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
Carriage Return control character told it to move the carriage back to
the beginning of the line, and the Line Feed character told it to move
to the next line.
Newlinecharactercharacternewline
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 Newline character. For some reason, they
chose the line feed to represent newline, though the character generated by
Enter is a carriage return. As we saw above, the C programming language
represents it as \en.
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 , and the printer issues on
page .
Users and groupsusersand 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—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.
user
In order to access a FreeBSD system, you must be registered as a user.
The registration defines a number of parameters:
usernameuserID
A user name, also often called user ID. This is a name which you
use to identify yourself to the system.
password
A password, 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.
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.
shellCOMMAND.COMshcommandcommandshcshcommandcommandcshbashcommandcommandbashtcshcommandcommandtcshzshcommandcommandzshCOMMAND.COM
A shell, a program which reads in your commands and executes them. MS-DOS
uses the program COMMAND.COM to perform this function. UNIX has a large
choice of shells: the traditional UNIX shells are the Bourne shell sh
and the C shell csh, but FreeBSD also supplies bash, tcsh,
zsh and others. The UNIX shells are orders of magnitude more powerful
than COMMAND.COM—see UNIX Power Tools for a good discussion. I
personally use the bash shell.
homedirectorydirectoryhome
A home directory. 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 /home/username, where username 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
bash used in these examples, use the special notation ~ (tilde)
to represent the name of the home directory.
group
A group number. UNIX collects users into groups 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 , your user and group determine what access you
have to the system. You can belong to more than one group.
/etc/group
Group numbers generally have names associated with them. The group names and
numbers are stored in the file /etc/group. 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.
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 group(5).
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.
/etc/passwd/etc/master.passwd/etc/pwd.db/etc/spwd.db
The list of users is kept in the file /etc/passwd. 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 /etc/master.passwd, and for performance
reasons it also makes it available in database form in /etc/pwd.db and
/etc/spwd.db. /etc/passwd remains for compatibility reasons: some
programs access it directly to get information about the environment in which
they are running.
By default, there are no real users on a freshly installed system. Optionally,
sysinstall 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.
Choosing a user nameusernamechoosinga user nameloggingin
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:
First name. In my personal case, this would be greg.
Last name (lehey).
First name and initial of last name (gregl).
Inital of first name, and last name (glehey).
Initials (gfl).
Nickname (for example, grog).
I choose the last possibility, as we will see in the following discussion.
Adding usersaddingusersusersaddingsysinstallcommandcommandsysinstalladdusercommandcommandadduserSchneiderWolframLeheyYana
There are two ways to add users. One is the program adduser:
# adduser
Use option ``-verbose'' if you want see more warnings & questions
or try to repair bugs.
Enter username [a-z0-9]: yana
Enter full name []: Yana Lehey
Enter shell bash csh date no sh [bash]: accept the default
Uid [1000]: accept the default
Enter login class: default []: accept the default
Login group yana [yana]: home
Login group is ``home''. Invite yana into other groups: no
[no]: wheelin order to use su
Enter password []: no echo
Enter password again []: no echo
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]: accept the default
Added user ``yana''
Add another user? (y/n) [y]: nvipwcommandcommandvipwLeheyNorman/etc/master.passwd
An alternative way of adding or removing users is with the vipw program.
This is a more typical UNIX-hackish approach: vipw starts your favourite
editor and allows you to edit the contents of the file /etc/master.passwd.
After you have finished, it checks the contents and rebuilds the password
database. Figure shows an example.
/etc/master.passwdvipw display
/etc/master.passwd format
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 passwd program.
T}
1005#T{
User number
T}
1000#T{
Group number
T}
/etc/passwd
(empty)#T{
Login class. We'll look at this below. This field is not included in
/etc/passwd.
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 /etc/passwd.
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 /etc/passwd.
T}
LeheyYvonnegecos
T{
Yvonne Lehey, Echunga, +61-8-8388-8250
T}#T{
The so-called gecos
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}
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 fields (which may be empty), and
that each field is separated from the next by a colon (:). Table
describes the fields you see on the line on which the
cursor is positioned. You can read more about the format of
/etc/master.passwd in the man page for passwd for further
details.
We'll see a valid use of this approach on page : 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.
Adding or changing passwordsaddingpasswordschangingpasswordspasswordsaddingpasswordschangingpasswdcommandcommandpasswd
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 passwd
program. The input doesn't look very interesting:
$ passwd
Changing local password for yana.
Old password: doesn't echo
New password: doesn't echo
Retype new password: doesn't echo
passwd: rebuilding the database...
passwd: done
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 root and
change the password: root doesn't have to enter the old password, and it
can change anybody's password. For example:
# passwd
Changing local password for yana.
New password: doesn't echo
Retype new password: doesn't echo
passwd: rebuilding the database...
passwd: done
In this case, you specify the name of the user for whom you change the password.
rootsucommandcommandsu
If you are changing the root 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 su to become
root. If you're running in character mode, select another virtual
terminal and log in as root there. Only when you're sure you can still
access root should you log out.
If you do manage to lose the root password, all may not be lost.
Reboot the machine to single user mode (see page ), and enter:
# mount -u / mount root file system read/write
# mount /usr / mount /usr file system (if separate)
# passwd root change the password for root
Enter new password:
Enter password again:
# ^Denter ctrl-D to continue with startup
If you have a separate /usr file system (the normal case), you need to
mount it as well, since the passwd program is in the directory
/usr/bin. Note that you should explicitly state the name root: in
single user mode, the system doesn't have the concept of user IDs.
The super usersuperusersucommandcommandsu
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 daemon and uucp, exist to run particular programs. One user
stands above all others, however: root may do just about anything. The
kernel gives root special privileges, and you need to become
root in order to perform a number of functions, including adding other
users. Make sure root 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, root is a user like any other, but to quote
the man page su(1),
By default (unless the prompt is reset by a startup file) the super-user
prompt is set to # to remind one of its awesome power.
Becoming super userbecomingsuper usersuperuser
Frequently when you're logged in normally, you want to do something which
requires you to be root. You can log out and log in again as
root, of course, but there's an easier way:
$ subecome super user
Password: as usual, it doesn't echo
# root prompt/etc/group
In order to be able to use su, you must be a member of the group
wheel. 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 /etc/group:
wheel:*:0:root,grogadd the text in bold face
BSD treats su somewhat differently from System V. First, you need to be
a member of the group wheel, and secondly BSD gives you more of the
super-user environment than System V. See the man page
for further information.
Login classesloginclasses/etc/login.conf
In UNIX tradition, root 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, login classes, which determine session accounting, resource
limits and user environment settings. Various programs in the system use the
database described in /etc/login.conf 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.
When creating a user, you may optionally enter a class name, which should match
an entry in /etc/login.conf—see page for more details.
If you don't, the system uses the entry default for a non-root user.
For the root user, the system uses the entry root if it is present, and
default otherwise.
The structure of the login configuration database is relatively extensive. It
describes a number of parameters, many of which can have two values: a
current value and a maximum value. On login, the system sets
the values to the -cur (current) value, but the user may, at his option,
increase the value to the -max (maximum) value. We'll look at the
default entry for an example.
# 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:
backslash
As in the password file, the fields are delimited by colons (:). In
this example, though, lines are continued by placing a backslash
(\e) 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.
This entry defines the following parameters:
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.
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.
The user may lock a maximum of 10 MB of memory per process.
The total memory use per process may not exceed 100 MB.
There is no limit on the size of data files or core dump files that the user may
create.
The user may have up to 64 processes.
Each process may have up to 64 open files. For some programs, this could be a
limitation.
The user need not have a home directory in order to log in. The
@ symbol specifies that the preceding symbol (requirehome)
should be undefined. As a result, the system does not require the home
directory.
umask
By default, the umask is set to 022. See page for
more details of umask.
The system uses the default authentication scheme for this user.
See the man page login.conf(5) for further details.
Referring to other classesIf 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:
glutton:\e
:tc=default:\e
:memoryuse-cur=infinity:
The property tc refers to the default class. A good example of
this is the xuser class, designed for the needs of X11 users:
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:
In this example, you'll notice also that the class definition defines a default
for the environment variable MANPATH.
Using login classesLogin classes are a relatively recent addition to FreeBSD. There are a couple
of things to note about their use:
At the time of writing, not all parameters are implemented.
/etc/login.conf
The data is stored in the file database format for faster access. After
modifying the file /etc/login.conf, be sure to run the following command
to update the database:
# cap_mkdb /etc/login.confUsing the shellusingthe shellshellusing
So now we have a user ID, and we can get beyond the prompt on page
\&. When you log in, you start your shell. As we saw on
page , 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:
login: grog
Password: password doesn't show on the screen
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 ->
There's a lot of stuff here, and it's worth looking at it in more detail:
gettycommandcommandgettylogincommandcommandlogin
The program that asks you to log in is called getty. It reads in your
user ID and starts a program called login and passes the user ID to it.
login asks for the password and checks your user ID.
If the user ID and password are correct, login starts your designated
shell.
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.
Messageof the day/etc/motd
In this case, though, we can see the results: one file contains the time you
last logged in, another one contains the Message of the day
(/etc/motd), and a third one contains your mail. The shell prints out
the message of the day unaltered—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.
The line ``erase ^H, kill ^U, intr ^C, status ^T'' looks strange. It's
telling you the current editing control characters. We'll look at these on page
.
homedirectorydirectoryhome
It changes the current directory to your home directory.
WirthNiklausfortunecommandcommandfortune
Then it runs the fortune 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.
Finally, the last line is a prompt, the information that tells you that the
shell is ready for input.
shcommandcommandshcshcommandcommandcsh
It's worth looking at the prompt in more detail, since it illustrates a number
of things about the UNIX environment. By default, sh and friends prompt
with a $, and csh and friends prompt with a %. In the
same way that you can change the MS-DOS command prompt away from C:\e>
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.
xtermcommand
The first part, ===, is just to make it easier to find in a large list
on an X display. An xterm 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.
Next, grog@freebie 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.
/dev/ttyv0/dev/ttyv0 is the name of the current controlling terminal. This can
sometimes be useful.
~ is the name of the home directory. Most shells, but not all of them,
support this symbolism.
1 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 !!1 (two exclamation marks and the number of the
command). We'll look at more comfortable ones in the next section.
Command line editingCommandline editing
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:
$ groff -rex=7.5 -r$$ -rL -rW -rN2 -mpic tmac.M unixerf.mm
troff: fatal error: can't open `unixerf.mm': No such file or directory
This command should create the PostScript version of this chapter, but
unfortunately I messed up the name of the chapter: it should have been
unixref.mm, and I typed unixerf.mm.
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
make unixref.
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 Backspace key
erases the last character you entered. Well, most of the time. What if you're
running on a machine without a Backspace key? You won't have that problem
with a PC, of course, but a lot of workstations have a DEL key instead of
a Backspace key. UNIX lets you specify what key to use to erase the last
character entered. By default, the erase character really is DEL, but the
shell startup changes it and prints out a message saying what it has done:
erase ^H, kill ^U, intr ^C, status ^T
in the example above. ^H (CTRL-H) is an alternative representation
for Backspace.
The three other functions kill, intr, and status perform
similar editing functions. kill erases the whole line, and intr
stops a running program.
signal
More correctly, intr sends a signal called SIGINTR to
the process. This normally causes a program to stop.
bashcommandcommandbash
You'll notice that it is set to Ctrl-C, so its function is very similar to
that of the MS-DOS Break key. status is an oddball function: it
doesn't change the input, it just displays a statistics message. bash
doesn't in fact use it: it has a better use for Ctrl-T.
In fact, these control characters are just a few of a large number of control
characters that you can set. Table gives an
overview.
Terminal control characters
box, center,tab(%) ;
lfCWp9 | lfCWp9 | lf(R)w59 .
\s10Name%Default%Function
=
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).
NL%\en% End line. Normally, this also terminates input.
INTR%CTRL-C% Generate an \s10SIGINT\s0 signal. This normally causes the process to terminate.
QUIT%CTRL-|% Generate a \s10SIGQUIT\s0 signal. This normally causes the process to terminate.
ERASE%DEL% Erase last character. FreeBSD sets this to Backspace on login, but under some unusual circumstances you will find it still set to DEL.
KILL%CTRL-U% Erase current input line.
EOF%CTRL-D% Return end-of-file indication. Most programs stop when they receive an EOF.
EOL%% Alternate end-of-line character. This is not normally used, and by default it is disabled.
EOL2%% Alternate end-of-line character. Also seldom used.
START%CTRL-Q% Resume output after stop. See the next entry.
STOP%CTRL-S% Stop output. Use this to examine text which is scrolling faster than you can read.
fgcommandcommandfg SUSP%CTRL-Z% Suspend process. This key generates a \s10SIGTSTP\s0 signal when typed. This normally causes a program to be suspended. To restart, use the fg command.
DSUSP%CTRL-Y% Delayed suspend. Generate a \s10SIGTSTP\s0 signal when the character is read. Otherwise, this is the same as SUSP.
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.
DISCARD%CTRL-O% Discard all terminal output until another \s10DISCARD\s0 character arrives, more input is typed or the program clears the condition.
WERASE%CTRL-W%Erase the preceding word.
LNEXT%CTRL-V% Interpret next character literally. Many shells disable this function.
STATUS%\\377% Send a SIGINFO signal to the foreground process group. If NOKERNINFO is not set, the kernel also prints a status message on the terminal.
sttycommandcommandstty
To set these characters, use the stty program. For example, if you're
used to erasing the complete input line with Ctrl-X, and specifying an
end-of-file condition with Ctrl-Z, you could enter:
$ stty susp \e377 kill ^X eof ^ZYou need to set SUSP to something else first, because by default it is
Ctrl-Z, so the system wouldn't know which function to perform if you
press ^ZThe combination \e377 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 \e0
for the same purpose.
In this particular case, ^X really does mean the letter ^
followed by the letter X, and not CTRL-X, the single character
created by holding down the Control character and pressing X at the
same time.
Command history and other editing functionsCommandhistory
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 Enter, there's nothing they can do any more.
Nowadays, most shells supply a command history function and additional
functionality for editing it. We'll take a brief look at these features
here—for more details, see the man pages for your shell.
emacscommandcommandemacs
Command line editing—Emacs mode
box, center,tab(#) ;
lf(B)w11 | lw67 .
Key#Function
=
Ctrl-A Move to the beginning of the line LeftArrow Move to previous character on line Ctrl-B Move to previous character on line (alternative) Ctrl-D Delete the character under the cursor. Be careful with this character: it's also the End-of-file character, so if you enter it on an empty line, it stops your shell and logs you out. Ctrl-E Move to the end of the line RightArrow Move to next character on line Ctrl-F Move to next character on line (alternative) Ctrl-K Erase the rest of the line Ctrl-L Erase screen contents DownArrow Move to next input line Ctrl-N Move to next input line (alternative) UpArrow Move to previous input line Ctrl-P Move to previous input line (alternative) Ctrl-R Incremental search backward for text Ctrl-S Incremental search for text forward Ctrl-T Transpose the character under the cursor with the character before the cursor Ctrl-U Erase the current line Ctrl-Y Insert previously erased with Ctrl-K or Alt-D Ctrl-_ Undo the last command Alt-C Capitalize the following word Alt-D Delete the following word Alt-F Move forward one word Alt-L Convert the following word to lower case Alt-T Transpose the word before the cursor with the one after it Alt-U Convert the following word to upper case
bashcommandcommandbashkshcommandcommandkshzshcommandcommandzsh
Shell command line editing has been through a number of evolutionary phases.
The original Bourne shell supplied no command line editing at all, though the
version supplied with FreeBSD gives you many of the editing features of more
modern shells. Still, it's unlikely that you'll want to use the Bourne shell as
your shell: bash, ksh, and zsh are all compatible with the
Bourne shell, but they also supply better command line editing.
cshcommandcommandcshvicommandcommandvi
The next phase of command line editing was introduced with the C shell,
csh. By modern standards, it's also rather pitiful. It's described in
the csh man page if you really want to know. About the only part that
is still useful is the ability to repeat a previous command with the !!
construct.
Modern shells supply command line editing which resembles the editors vi
or Emacs. In bash, sh, ksh, and zsh you can
make the choice by entering
$ set -o emacs for Emacs-style editing
$ set -o vi for vi-style editingtcshcommandcommandtcsh
In tcsh, the corresponding commands are:
% bind emacs
% bind viNormally you put one of these commands in your startup file.
Command line editing—vi mode
box,center, tab(#) ;
| lf(B)w11 | lw58 | .
Key#Function
=
^ Move to the beginning of the line h Move to previous character on line x Delete the character under the cursor $ Move to the end of the line l Move to next character on line D Erase the rest of the line Ctrl-L Erase screen contents j Move to next input line k Move to previous input line K Search for text backward J Search for text forward u Undo the last command w Move forward one word i Change to insert mode
tcshcommandcommandtcshvicommandcommandvi
In Emacs mode, you enter the commands simply by typing them in. In
vi mode, you have to press ESC first. Table
shows an overview of the more typical Emacs-style commands in bash, and
Table shows the commands for tcsh in vi mode.
Many other shells supply similar functionality.
File name completionfilename completionemacscommandcommandemacs
As we have seen, UNIX file names can be much longer than traditional Microsoft
names, and it becomes a problem to type them correctly. To address this
problem, newer shells provide file name completion. In Emacs
mode, you typically type in part of the name, then press the Tab key. The
shell checks which file names begin with the characters you typed. If there is
only one, it puts in the missing characters for you. If there are none, it
beeps (rings the ``terminal bell''). If there are more than one, it puts in as
many letters as are common to all the file names, and then beeps. For example,
if I have a directory documentation in my home directory, I might enter:
=== grog@freebie (/dev/ttyp4) ~ 14 -> cd documentation/
=== grog@freebie (/dev/ttyp4) ~/documentation 15 -> ls
freebsd.faq freebsd.fbc freeware
=== grog@freebie (/dev/ttyp4) ~/documentation 16 -> emacs freebeepbsd.fbeepaq
Remember that my input is in \s\n[cwfontsize]fixed bold\s0 font, and the
shell's output is in \s\n[cwfontsize]fixed\s0 font. On the first line,
I entered the characters cd doc followed by a Tab character, and
the shell completed with the text umentation/. On the last line, I
entered the characters emacs f and a Tab. In this case, the shell
determined that there was more than one file which started like this, so it
added the letters ree and rang the bell. I entered the letter b
and pressed Tab again, and the shell added the letters sd.f and
beeped again. Finally, I added the letters aq to complete the file name
freebsd.faq.
vicommandcommandvi
Command line completion in vi mode is similar: instead of pressing
Tab, you press ESC twice.
Environment variablesenvironmentvariablesvariablesenvironmentenvironmentvariables
The UNIX programming model includes a concept called environment
variables. This rather unusual sounding name is simply a handy method of
passing relatively long-lived information of a general nature from one program
to another. It's easier to demonstrate the use than to describe. Table
takes a look at some typical environment
variables. To set environment variables from Bourne-style shells, enter
$ TERM=xterm export TERMThis sets the value of the TERM variable to xterm. If you
want, you can also set it at the beginning of a command line:
$ TERM=xterm-color muttmuttcommandcommandmutt
This starts the mutt mail reader (see page ) with
xterm's colour features enabled.
For csh and tcsh, set environment variables with:
% setenv TERM xtermTo start a process with these variables, enter:
% env xterm-color mutt
Common environment variables
box,center,tab(#) ;
| lfCWp9 | lw68 | .
\s10Name#Purpose
=
df BLOCKSIZE The size of blocks which programs like df count. The default is 512 bytes, but it's often more convenient to use 1024.
termcap COLUMNS The number of columns on the current display. This variable should not be used, since the number of columns is defined in the termcap description for terminals with a fixed display size, and the software should be able to ask the others, such as xterm, for their size. Unfortunately, other systems frequently have difficulties in this area, and COLUMNS can help.
DISPLAY When running X, the name of the X server. For a local system, this is typically unix:0. For remote systems, it's in the form
system-name:server-number.screen-number. For the system bumble.example.org, you would probably write bumble.example.org:0.
EDITOR The name of your favourite editor. Various programs that start editors look at this variable to know which editor to start.
HOME The name of your home directory.
locale LANG The locale which you use. This should be the name of a directory in /usr/share/locale.
LINES See COLUMNS above. This second variable defines the number of lines on the screen.
MAIL Some programs use this variable to find your incoming mail file.
/usr/share/man/usr/local/man MANPATH A list of path names, separated by colons (:), which specifies where the man program should look for man pages. A typical string might be /usr/share/man:/usr/local/man, and specifies that there are man pages in each of the directories /usr/share/man and /usr/local/man.
NTAPE The name of the non-rewinding tape device. See page for more details.
PATH A list of path names, separated by colons (:), which specifies where the shell should look for executable programs if you specify just the program name.
PS1 In Bourne-style shells, this is the prompt string. It's usually set to $, but can be changed. See page for a discussion of a possible prompt for bash.
PS2 In Bourne-style shells, this is the prompt string for continuation lines. It's usually set to >.
SHELL The name of the shell. You can use this for starting a new copy.
TAPE The name of the rewinding tape device. See page for more details.
/usr/share/zoneinfo TERM The type of terminal emulation you are using. This is very important: there is no other way for an application to know what the terminal is, and if you set it to the wrong value, full-screen programs will behave incorrectly. TZ Time zone. This is the name of a file in /usr/share/zoneinfo which describes the local time zone. See the section on timekeeping on page for more details.
Note particularly the PATH variable. One of the most popular questions
in the FreeBSD-questions mailing list is ``I have compiled a program,
and I can see it in my directory, but when I try to run it, I get the message
command not found''. This is usually because the current directory is
not in the PATH.
It's good practice not to have your current directory or your home
directory in the PATH: if you do, you can be subject to security
attacks.
.profile
You should set your PATH variable to point to the most common executable
directories. Add something like this to your .profile file (for
Bourne-style shells):
PATH=/usr/bin:/usr/local/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
export PATH
.cshrc
Alternatively, for csh-style shells, put this in your .cshrc:
set path = (/usr/bin /usr/local/bin /usr/sbin /bin /sbin /usr/X11R6/bin)
This specifies to look for executable programs in the sequence /usr/bin,
/usr/local/bin, /usr/sbin, /bin, /sbin and
/usr/X11R6/bin. This variable is of great importance: one of the leading
problems that beginners have is to have an incorrect PATH variable.
Shell startup filesShellstartup files
As we saw above, there are a lot of ways to customize your shell. It would be
inconvenient to have to set them every time, so all shells provide a means to
set them automatically when you log in. Nearly every shell has its own startup
file. Table gives an overview.
The format of these files is like a shell script—in other words, straight
shell commands. Figure shows a typical .bashrc file to set
the environment variables we discussed.
Shell startup files
box,center,tab(#) ;
l | lI .
Shell#startup file
=
bash.profile, then .bashrc
csh.login on login, always .cshrc
sh.profile
tcsh.login on login, always .tcshc, .cshrc if .tcshrc not found
umask 022
BLOCKSIZE=1024 # for df
CVSROOT=/src/ncvs
EDITOR=/opt/bin/emacs;export EDITOR
LANG=en_AU.ISO8859-1 export LANG
MANPATH=/usr/share/man:/usr/local/man
MOZILLA_HOME=/usr/local/netscape export MOZILLA_HOME
PAGER=less export PAGER
PATH=/usr/bin:/usr/local/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
PS1="=== \eu@\eh (`tty`) \ew \e# -> "
PS2="\eu@\eh \ew \e! ++ "
SHELL=/bin/bash export SHELL
TAPE=/dev/nrst0 export TAPE # note non-rewinding as standard
if [ "$TERM" = "" ]; then
TERM=xterm
fi
if [ "$DISPLAY" = "" ]; then
DISPLAY=unix:0;export DISPLAY
fi
/usr/games/fortune # print a fortune cookie
.bashrcMinimal .bashrc file
It would be tedious for every user to put settings in their private
initialization files, so the shells also read a system-wide default file. For
the Bourne shell family, it is /etc/profile, while the C shell family has
three files: /etc/csh.login to be executed on login, /etc/csh.cshrc
to be executed when a new shell is started after you log in, and
/etc/csh.logout to be executed when you stop a shell. The start files are
executed before the corresponding individual files.
In addition, login classes (page ) offer another method of
setting environment variables at a global level.
Changing your shellcommandchshchshcommand
The FreeBSD installation gives root a C shell, csh. This is the
traditional Berkeley shell, but it has a number of disadvantages: command line
editing is very primitive, and the script language is significantly different
from that of the Bourne shell, which is the de facto standard for shell
scripts: if you stay with the C shell, you may still need to understand the
Bourne shell. The latest version of the Bourne shell sh also includes
some command line editing. See page for details of how to enable
it.
You can get better command line editing with tcsh, in the Ports
Collection. You can get both better command line editing and Bourne shell
syntax with bash, also in the Ports Collection.
If you have root access, you can use vipw to change your shell,
but there's a more general way: use chsh (Change Shell). Simply
run the program. It starts your favourite editor (as defined by the
EDITOR environment variable). Here's an example before:
VelteJack
#Changing user database information for velte.
Shell: /bin/csh
Full Name: Jack Velte
Location:
Office Phone:
Home Phone:
You can change anything after the colons. For example, you might change this
to:
#Changing user database information for velte.
Shell: /usr/local/bin/bash
Full Name: Jack Velte
Location: On the road
Office Phone: +1-408-555-1999
Home Phone:
chsh checks and updates the password files when you save the
modifications and exit the editor. The next time you log in, you get the new
shell. chsh tries to ensure you don't make any mistakes—for example,
it won't let you enter the name of a shell which isn't mentioned in the file
/etc/shells—but it's a very good idea to check the shell before
logging out. You can try this with su, which you normally use to become
super user:
bumble# su velte
Password:
su-2.00$ note the new promptThere are a couple of problems in using tcsh or bash as a root
shell:
The shell for rootmust be on the root file system, otherwise
will not work in single user mode. Unfortunately, most ports of shells put the
shell in the directory /usr/local/bin, which is almost never on the root
file system.
Most shells are dynamically linked: they rely on library routines in
files such as /usr/lib/libc.a. These files are not available in single
user mode, so the shells won't work. You can solve this problem by creating
statically linked versions of the shell, but this requires programming
experience beyond the scope of this book.
If you can get hold of a statically linked version, perform the following steps
to install it:
Copy the shell to /bin, for example:
# cp /usr/local/bin/bash /binAdd the name of the shell to /etc/shells, in this example the line in
bold print:
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/sh
/bin/csh
/bin/bashProcessesprocessdefinedprocessIDPID
As we have seen, UNIX is a multi-user, multi-tasking operating system. In
particular, you can run a specific program more than once. We use the term
process to refer to a particular instance of a running program. Each
process is given a process ID, more frequently referred to as PID, a
number between 0 and 29999 which uniquely identifies it. There are many things
that you might like to know about the processes which are currently running,
such as:
How many processes are running?
Who is running the processes?
Why is the system so slow?
Which process is blocking my access to the modem?
pscommandcommandpsprocessstatus
Your primary tool for investigating process behaviour is the ps
(process status) command. It has a large number of command options, and
it can tell you a whole lot of things which you will only understand when you
have investigated how the kernel works, but it can be very useful for a number
of things. Here are some typical uses:
What processes do I have running?After starting a large number of processes in a number of windows under X, you
probably can't remember what is still running. Maybe processes that you thought
had stopped are still running. To display a brief summary of the processes you
have running, use the ps command with no options:
$ ps
PID TT STAT TIME COMMAND
187 p0 Is+ 0:01.02 -bash (bash)
188 p1 Ss 0:00.62 -bash (bash)
453 p1 R+ 0:00.03 ps
This display shows the following information:
The PID of the process.
controllingterminal/dev/ttyp0teletypeTT is short for teletype, and shows the last few letters of the
name of the controlling terminal, the terminal on which the process is
running. In this example, the terminals are /dev/ttyp0 and
/dev/ttyp1.
STAT shows the current process status. It's involved and requires a
certain amount of understanding of how the kernel runs in order to interpret
it—see the man page for ps for more details.
TIME is the CPU time that the process has used in minutes, seconds and
hundredths of a second. Note that many other UNIX systems, particularly System
V, only show this field to the nearest second.
pscommandcommandpsCOMMAND is normally the command you entered, but don't rely on this. In
the next section, you'll see that sendmail has changed its
COMMAND field to tell you what it is doing. You'll notice that the
command on the last line is the ps which performs the listing. Due to
some complicated timing problems in the kernel, this process may or may not
appear in the listing.
What processes are running?There are many more processes in the system than the list above shows. To show
them all, use the a option to ps. To show dæmons as well
(see the next section for a definition of dæmon), use the x
option. To show much more detail, use the u or l options. For
example,
$ ps waux
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
grog 510 0.0 0.9 448 272 p1 R+ 2:49PM 0:00.02 ps -waux
root 1 0.0 0.6 324 180 ?? Is 10:10AM 0:00.15 /sbin/init --
root 2 0.0 0.1 0 12 ?? DL 10:10AM 0:00.00 (pagedaemon)
root 3 0.0 0.1 0 12 ?? DL 10:10AM 0:00.00 (vmdaemon)
root 4 0.0 0.1 0 12 ?? DL 10:10AM 0:08.61 (update)
root 23 0.0 0.3 196 72 ?? Is 10:10AM 0:00.02 adjkerntz -i
root 49 0.0 0.4 220 116 ??- I 9:11AM 0:00.10 mount -a -t nfs
root 71 0.0 1.1 188 340 ?? Ss 9:11AM 0:00.78 syslogd
daemon 76 0.0 0.9 176 272 ?? Is 9:11AM 0:00.03 portmap
root 81 0.0 0.9 160 280 ?? Is 9:11AM 0:00.84 rwhod
root 85 0.0 0.6 408 176 ?? Is 9:11AM 0:00.03 mountd
root 87 0.0 0.4 232 104 ?? Is 9:11AM 0:00.03 nfsd: master (nfsd)
root 90 0.0 0.2 224 56 ?? I 9:11AM 0:00.02 nfsd: server (nfsd)
root 91 0.0 0.2 224 56 ?? I 9:11AM 0:00.00 nfsd: server (nfsd)
root 92 0.0 0.2 224 56 ?? I 9:11AM 0:00.00 nfsd: server (nfsd)
root 93 0.0 0.2 224 56 ?? I 9:11AM 0:00.00 nfsd: server (nfsd)
root 98 0.0 1.0 192 300 ?? Is 9:11AM 0:00.54 inetd
root 105 0.0 1.1 236 340 ?? Is 9:11AM 0:01.19 cron
root 107 0.0 1.1 192 320 ?? Is 9:11AM 0:00.07 lpd
root 110 0.0 1.3 484 376 ?? Is 9:11AM 0:00.16 sendmail: accepting connecti
root 150 0.0 1.8 156 536 v0 Is+ 9:11AM 0:00.06 /usr/libexec/getty Pc ttyv0
root 151 0.0 1.8 156 536 v1 Is+ 9:11AM 0:00.06 /usr/libexec/getty Pc ttyv1
root 152 0.0 1.8 156 536 v2 Is+ 9:11AM 0:00.06 /usr/libexec/getty Pc ttyv2
root 153 0.0 1.8 156 536 v3 Is+ 9:11AM 0:00.05 /usr/libexec/getty Pc ttyv3
root 154 0.0 1.8 156 536 v4 Is+ 9:11AM 0:00.07 /usr/libexec/getty Pc ttyv4
root 155 0.0 1.8 156 536 v5 Is+ 9:11AM 0:00.06 /usr/libexec/getty Pc ttyv5
root 156 0.0 1.8 156 536 v6 Is+ 9:11AM 0:00.05 /usr/libexec/getty Pc ttyv6
root 160 0.0 1.8 176 556 ?? I 9:11AM 0:00.08 /usr/libexec/yagetty 38400
root 163 0.0 0.6 284 168 ?? I 9:12AM 0:01.55 nfs radio.example.org /C
root 173 0.0 1.8 168 540 ?? Is 9:29AM 0:00.11 rshd
root 174 0.0 5.7 540 1728 ?? I 9:29AM 0:03.04 xterm
root 180 0.0 1.8 168 544 ?? Is 9:29AM 0:00.21 rshd
root 181 0.1 6.0 540 1820 ?? S 9:29AM 0:06.12 xterm
grog 187 0.0 1.7 808 520 p0 Is 9:30AM 0:01.10 -bash (bash)
grog 188 0.0 1.9 768 568 p1 Ss 9:30AM 0:00.75 -bash (bash)
root 462 0.0 2.0 752 600 p0 I+ 2:35PM 0:00.78 su (bash)
root 0 0.0 0.0 0 0 ?? DLs - 0:00.00 (swapper)
We've seen a number of these fields already. The others are:
realuser IDUSER is the real user ID of the process, the user ID of the
person who started it.
%CPU is an approximate count of the proportion of CPU time that the
process has been using in the last few seconds. This is the column to examine
if things suddenly get slow.
%MEM is an approximate indication of the amount of physical memory that
the process is using.
VSZ (virtual size) is the number of 4096 byte pages of virtual
memory that the process is using.
RSS (resident segment size) is the number of 4096 byte pages of
physical memory currently in use.
STARTED is the time or date when the process was started.
In addition, a surprising number of processes don't have a controlling
terminal. They are dæmons, and we'll look at them in the next
section.
toptop
Another tool for investigating system performance is top, which shows a
number of performance criteria, including the status of the processes which are
using the most resources. Start it with the number of processes you want
displayed, for example:
$ top 4
last pid: 10887; load averages: 0.27, 0.43, 0.32 14:18:05
109 processes: 6 running, 96 sleeping, 7 zombie
CPU states: 3.5% user, 0.0% nice, 5.0% system, 0.0% interrupt, 91.5% idle
Mem: 6456K Active, 53M Inact, 21M Wired, 11M Cache, 8341K Buf, 588K Free
Swap: 314M Total, 97M Used, 218M Free, 31% Inuse
PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
15027 grog 2 0 38788K 16000K select 52:34 2.02% 2.02% X
22478 grog 2 0 6232K 3160K select 3:44 0.72% 0.72% emacs
10887 grog 28 0 920K 692K RUN 0:00 0.70% 0.65% top
15058 grog 2 0 484K 456K select 0:09 0.11% 0.11% fvwm2
See the man page top(1) for more details.
Dæmonsdæmon
daemon
sendmaildæmoninetddæmoncrondæmon
A significant part of the work in a FreeBSD system is performed by
dæmons. A dæmon is not just the friendly little guy on the cover of
this book—it's a process which goes around in the background and does routine
work such as sending mail (sendmail), accepting or denying Internet
access (inetd), or starting jobs at particular times (cron).
To quote the Shorter Oxford English Dictionary: Demon Also
dæmon. ME [In form, and in sense I, a. L. dæmon
(med. L. demon)...] 1. Gr. Myth. (=
\(*d\(*a\h'.05m'\(*i\(*m\(*w\(*n): A being of a nature intermediate
between that of gods and men; an inferior divinity, spirit (including the souls
of deceased persons). Often written dæmon for distinction. 1569.
You can recognize dæmons in a ps waux listing by the fact that they don't
have a controlling terminal. Each dæmon has a man page which describes what it
does.
initdæmondæmoninit
Normally, dæmons are started when the system is booted and run until the system
is stopped. If you stop one by accident, you could be in trouble. For example,
init is responsible for starting other processes. If you kill it, you
effectively kill the system, so, unlike traditional UNIX systems, FreeBSD does
not allow init to be killed.
croncron/etc/daily/etc/weekly/etc/monthly
One of the more useful dæmons is cron, named after Father Time.
cron performs functions at specific times. For example, by default the
system runs the script /etc/daily every day at 2:00 am, the script
/etc/weekly every Saturday at 3:30 am, and the script
/etc/monthly on the first day of every month at 5:30 am.
crontab
To tell cron to perform a function at a particular time, you need a file
called a crontab. The system keeps the real crontab where you
can't get at it, but you can keep a copy. It's a good idea to call it
crontab as well.
Let's look at the format of the default system crontab, located in
/etc/crontab:
# /etc/crontab - root's crontab for FreeBSD
#
# $I\&d: crontab,v 1.10 1995/05/27 01:55:21 ache Exp $
# From: I\&d: crontab,v 1.6 1993/05/31 02:03:57 cgd Exp
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
#
#minute hour mday month wday who command
#
*/5 * * * * root /usr/libexec/atrun
#
# rotate log files every hour, if necessary
#0 * * * * root /usr/bin/newsyslog
#
# do daily/weekly/monthly maintenance
0 2 * * * root /etc/daily 2>&1 | sendmail root
30 3 * * 6 root /etc/weekly 2>&1 | sendmail root
30 5 1 * * root /etc/monthly 2>&1 | sendmail root
#
# time zone change adjustment for wall cmos clock,
# does nothing, if you have UTC cmos clock.
# See adjkerntz(8) for details.
1,31 0-4 * * * root /sbin/adjkerntz -a
As usual, lines starting with # are comments. The others have seven
fields. The first five fields specify the minute, the hour, the day of the
month, the month, and the day of the week on which an action should be
performed. The character * means ``every''. Thus, 0 2 * * *
(for /etc/daily) means ``0 minutes, 2 o'clock (on the 24 hour clock),
every day of the month, every month, every weekday''.
/etc/crontab
Field number six is special: it only exists in /etc/crontab, and it
specifies the user as which the operation should be performed. When you write
your own crontab file, don't use this field.
The remaining fields define the operation to be performed. cron doesn't
read your shell initialization files. In particular, this can mean that it
won't find programs you expect it to find. It's a good idea to put in explicit
PATH definitions, or specify an absolute pathname for the program, as is
done in this example. cron mails the output to you, so you should check
root's mail from time to time.
crontabcommandcommandcrontab
To install or list a crontab, use the crontab program:
$ crontab crontab install a crontab
$ crontab -l list the contents of an installed crontab
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (crontab installed on Wed Jan 1 15:15:10 1997)
# (Cron version -- $\&Id: crontab.c,v 1.7 1996/12/17 00:55:12 pst Exp $)
0 0 * * * /home/grog/Scripts/rotate-log
Stopping processesstoppingprocessesprocessesstopping
Sometimes you may find that you want to stop a currently running process. There
are a number of ways to do this, but the easiest are:
If the process is running on a terminal, and it's accepting input, hitting the
EOF key (usually CTRL-D) will often do it.
If EOF doesn't do it, try the INTR key (usually Ctrl-C).
killcommandcommandkill
If the process is ignoring INTR, or if it is not associated with a
terminal, use the kill command. For example, to find who is using all
the CPU time, use ps and look at the %CPU field:
# ps waux
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 105 97.3 1.1 236 340 ?? Is 9:11AM 137:14.29 cron
\&(other processes omitted)Here, cron is using 97% of the CPU time, and has accumulated over 2
hours of CPU time since this morning. It's obviously sick, and we should put it
out of its misery. To stop it, enter:
# kill 105This command sends a signal called SIGTERM (terminate) to the process.
This signal gives the process time to tidy up before exiting, so you should
always try to use it first. The 105 is cron's PID, which we got from
the ps command.
If the process doesn't go away within a few seconds, it's probably ignoring
SIGTERM. In this case, you can use the ultimate weapon:
# kill -9 105The -9 is the number of SIGKILL, a signal that cannot be caught
or ignored. You can find a list of the signals and their numeric values in
/usr/include/sys/signal.h, which is part of the software development
package.
Timekeepingtimekeeping
FreeBSD is a networking system, so keeping the correct time is more important
than on a standalone system. Apart from the obvious problem of keeping the same
time as other local systems, it's also important to keep time with systems in
other time zones.
TimeZonestzsetupcommandcommandtzsetupepochUTCUniversalCoordinated TimeTimeZonesPSTPacificStandard TimePDTPacificDaylight Time/etc/localtimetzsetupcommandcommandtzsetup
Internally, FreeBSD keeps the time as the number of seconds since the
epoch, the beginning of recorded history: 00:00:00 UTC, 1 January 1970.
UTC is the international base time zone, and means Universal
Coordinated Time, despite the initials. It corresponds very closely, but not
exactly, to Greenwich Mean Time (GMT), the local time in England in the winter.
It would be inconvenient to keep all dates in UTC, so the system understands the
concept of Time Zones. For example, in Walnut Creek, CA, the time zone in
the winter is called PST (Pacific Standard Time), and in the
summer it is PDT (Pacific Daylight Time). FreeBSD stores
information about the local time zone in a file called /etc/localtime.
Normally, sysinstall installs the correct data in this file, but if you
got it wrong, or if you move time zones, you can do it yourself easily enough by
running the tzsetup program.
The TZ environment variable/usr/share/zoneinfo
An alternate means of describing the time zone is to set the environment
variable TZ, which we looked at on page . This
looks like the way that System V does it, but that's not quite accurate. System
V doesn't have the time zone definition files in /usr/share/zoneinfo, so
the TZ variable tells it information about the time zone. For example,
the value of TZ for Berlin, Germany is MEZ1MSZ2 in System V, but
Germany/Berlin in FreeBSD.
Keeping the correct timentp
If you're connected to the Internet on a reasonably regular basis, there are a
number of programs which can help you synchronize your time via the ntp
service.
A number of systems around the world supply time information via the ntp
service. The first thing you need to do is to find one near you. One place to
look is at
http://www.eecis.udel.edu/~mills/ntp/servers.html.
xntpdcommandcommandxntpdntpdatecommandcommandntpdate
Your choice of program depends on the nature of your connection to the Internet.
If you're connected full time, you'll probably prefer xntpd, which keeps
the system synchronized. Otherwise you can use ntpdate, which you can run
as you feel like it.
xntpdxntpd performs periodic queries to keep the system synchronized with a
time server. There are many ways to run it—see the man page xntpd(8).
In most cases, you can set up one system on the network to connect to an
external time reference, and the other systems on the same Ethernet can get the
time information from the first system.
To get the time from an external source and broadcast it to the other systems on
the network, create a file /etc/ntp.conf with a content like this:
server 203.21.37.18 # ns.saard.net
driftfile /etc/ntp.drift
broadcast 223.147.37.255
/etc/ntp.drift
The first line defines the server. It's important to get one near you: network
delays can significantly impair the accuracy of the results. xntpd uses
the file /etc/ntp.drift to record information about the (in)accuracy of
the local system's clock. You only need the final line if you have other
systems on the network which wait for a broadcast message. It specifies the
broadcast address for the network and also tells xntpd to broadcast on
this address
After setting up this file, you just need to start xntpd:
# xntpd/etc/rc.conf
To ensure that xntpd gets started every time you reboot, ensure that you
have the the following lines in /etc/rc.conf:
xntpd_enable="YES" # Run xntpd Network Time Protocol (or NO).
xntpd_flags="" # Flags to xntpd (if enabled).
If /etc/rc.conf doesn't exist, create it.
The comment on the first line is misleading: the value of xntpd_enable
must be YES. You don't need any flags. You put exactly the same text
in the /etc/rc.conf on the other machines, and simply omit the file
/etc/ntp.conf. This causes xntpd on these machines to monitor
broadcast messages.
ntpdatentpdatecommandcommandntpdate
If you only infrequently connect to the Internet, xntpd may become
discouraged and not keep good time. In this case, it's better to use
ntpdate. Simply run it when you want to set the time:
# ntpdate server
You can't use both ntpdate and xntpd: they both use the same
port.
Starting and stopping the systemBefore you can run FreeBSD, you need to start it up. That's normally pretty
straightforward: you turn the machine on, a lot of things scroll off the screen,
and about a minute later you have a login: prompt on the screen.
Nevertheless, there are a number of items of interest on the way. In
particular, the boot process tells you a lot of information about the system
hardware configuration. This can be of use when upgrading the system, or if you
have problems.
It's not so obvious that you need to adhere to a procedure when shutting down
the system. We'll look at the hows and whys on page .
Starting the systemstartingthe system
When you power up the system, or when you reboot, a number of actions occur
before the system is up and running:
PowerOn Self TestPOST
First, the system firmware
BIOSBasicInput/Output SystemSRM
The firmware is called BIOS (Basic Input/Output System) on the
i386 architecture, or SRM on the Alpha architecture. We'll refer to it
as BIOS in the rest of this section.
performs tests which check that the machine is working correctly and determines
the hardware configuration. This Power On Self Test or POST has
nothing to do with FreeBSD.
startingthe systembootstrap
Next, the BIOS loads the first of three bootstraps from the first sector
on the hard disk. This bootstrap may or may not be part of the FreeBSD system.
It's up to this bootstrap to decide which operating system to boot. Typically
it will load the FreeBSD bootstrap from the second sector on disk.
BTX
The FreeBSD bootstrap first loads the second-level bootstrap, BTX, from
the next 15 sectors on disk and executes it. This bootstrap prints out the
message:
BTX loader 1.00 BTX version is 1.00
BIOS drive A: is disk0
BIOS drive C: is disk1
/kernelloaderbootstrap
The second-level boot locates the third-level bootstrap, called loader,
and loads it into memory. loader, which is new with FreeBSD 3.1, is an
intelligent bootstrap component which allows preloading of multiple kernel
components. See the man page loader(8) for more information.
loader locates the kernel, by default the file /kernel on the
root file system, and loads it into memory. It prints the Boot: prompt
at this point so that you can influence this choice—see the man page
boot(8) for more details of what you can enter at this prompt.
probing
The kernel switches the machine into 32-bit mode (on Intel) or 64-bit mode (on
Alpha) and disables the system BIOS. It then performs its own tests to look for
hardware it knows about. It's quite verbose about this, and prints messages
about both the hardware it finds and the hardware it doesn't find. This
operation is called probing. It's normal to have more ``didn't find''
messages than ``found'' messages. You'll see an example of these messages on
pages to .
swapper
After the probe, the kernel starts two processes, numbered 0 and 1. Process 0
is the swapper and is responsible for emergency clearing of memory when
the standard virtual memory algorithms aren't fast enough.
init/etc/rc
Process 1 is called init. As the name suggests, it is responsible for
starting up the system and dæmons. When coming up in the default multi-user
mode, it spawns a shell to execute the shell script /etc/rc.
/etc/defaults/rc.conf/etc/rc.conf/etc/rc first reads in the description files
/etc/defaults/rc.conf, which contains defaults for a number of
configuration variables, and /etc/rc.conf, which contains your
modifications to the defaults. It then proceeds to perform the steps necessary
to bring up the system, first starting virtual disk drivers, mounting swap space
and checking the file system integrity if necessary.
/etc/ttys
When /etc/rc exits, init reads the file /etc/ttys and
starts processes as determined there. It spends the rest of its life looking
after these processes.
Boot messages
As the bootstrap loaders load, you will see something like:
/ this is a ``twirling baton''
BTX loader 1.00 BTX version is 1.00
BIOS drive A: is disk0
BIOS drive C: is disk1
These messages are printed by BTX.
batontwirlingtwirlingbaton
If you're loading from disk, the / character at the end of the previous
line keeps changing through -, \e, and | before going
back to / again, giving the impression that the character is rotating.
This display, called a twirling baton, is your indication that the system
hasn't crashed and burned.
Next, loader prints its prompt:
FreeBSD/i386 bootstrap loader, Revision 0.5 640/64512kB
(jkh@time.cdrom.com, Sun Jul 24 16:25:12 CST 1999)
If you do nothing, or if you press Enter, it will load the kernel. Once
the kernel has been loaded, it will take control of the machine. Messages from
the kernel are in high-intensity text (brighter than normal). This is the only
time you will normally see them, but sometimes you'll see them during normal
machine operation. The boot messages look like:
/kernel text=0x14c395 data=0x180d8+0x22ec4 syms=[0x4+0x1e3c0+0x4+0x210f8]
Booting the kernel
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.
All rights reserved.
FreeBSD 3.0 #0: Wed Jan 28 14:43:28 1998
jkh@westhill.cdrom.com:/usr/src/sys/compile/GENERIC
The first line tells you how large the kernel is. Unless you run into problems,
which are unlikely at this point, this information is of little interest. If
you do have problems, the most important information is the date of
compilation and the pathname of the kernel on the last two lines of this
example. Please include this information if you report a problem.
Next, you see:
Please insert MFS root floppy and press enter:
When you insert the MFS root floppy and press Enter, you see more twirling
batons, then the UserConfig screen appears.
UserConfig: Modifying the boot configurationUserConfig
After the kernel has been loaded, the following screen will appear:
Kernel configuration Menu
Skip kernel configuration and continue with installation
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 certain that you do not need to configure your kernel
then simply press ENTER or Q now.
If your hardware configuration matches what the generic kernel expects (see page
), just press ENTER. The kernel will continue with
the device probes, which we discuss on page .
If you do need to change the configuration, press the down arrow key to
choose the kernel configuration in full-screen mode, then press ENTER.
This starts UserConfig, a part of the kernel which can be activated at
boot time to change the system's idea of device configuration. It presents you
with a full-screen menu:
---Active Drivers----------------------------25 Conflicts------Dev---IRQ--Port--
Storage : (Collapsed)
Network : (Collapsed)
Communications : (Collapsed)
Input : (Collapsed)
Multimedia :
Miscellaneous :
---Inactive Drivers--------------------------------------------Dev--------------
Storage : (Collapsed)
Network : (Collapsed)
Communications : (Collapsed)
Input : (Collapsed)
Multimedia :
Miscellaneous :
Note the word Conflicts at the top of the screen. This is a warning,
not an error. We'll see on page that the drivers look for
hardware in a number of configurations. Not all of these configurations can
coexist, but there will not be a problem unless you install hardware that can't
coexist.
The word (Collapsed) doesn't mean that your hardware has given up the
ghost—it means that the information about the corresponding hardware, which
is usually a large number of devices, has been omitted. You can expand it by
placing the cursor on the appropriate line and pressing Enter. A bar
cursor stretches across the line Storage (Collapsed). You can move it
up and down with the arrow keys. In our example, we have a NE2000 compatible
Ethernet board, but its I/O registers start at address 0x320, it is set
up for IRQ 9, and we want to change the kernel configuration to recognize it.
We move the bar down to the line Network and press Enter. The
display changes to:
---Active Drivers----------------------------25 Conflicts------Dev---IRQ--Port--
Storage : (Collapsed)
Network :
NE1000,NE2000,3C503,WD/SMC80xx Ethernet adapters conf ed0 5 0x280
NE1000,NE2000,3C503,WD/SMC80xx Ethernet adapters conf ed1 5 0x300
3C509 Ethernet adapter conf ep0 10 0x300
Fujitsu MD86960A/MB869685A Ethernet adapters conf fe0 5 0x240
Intel EtherExpress Ethernet adapter conf ix0 10 0x300
DEC Etherworks 2 and 3 Ethernet adapters conf le0 5 0x300
---Inactive Drivers--------------------------------------------Dev--------------
Storage : (Collapsed)
Network : (Collapsed)
Communications : (Collapsed)
Input : (Collapsed)
Multimedia :
Miscellaneous :
The highlighted conf means that the current configuration could conflict
with another device: the I/O address, IRQ or memory address will also be probed
by another driver. This is only a problem if you really have two boards with
the same configuration; otherwise you can ignore this warning. In this case, by
chance our Novell NE2000 board is already highlighted, so all we need to do is
to press Enter again to edit the configuration. The configuration is
copied to individual fields at the bottom of the screen, so we now see:
---Active Drivers----------------------------25 Conflicts------Dev---IRQ--Port--
Storage : (Collapsed)
Network :
NE1000,NE2000,3C503,WD/SMC80xx Ethernet adapters conf ed0 5 0x280
NE1000,NE2000,3C503,WD/SMC80xx Ethernet adapters conf ed1 5 0x300
3C509 Ethernet adapter conf ep0 10 0x300
Fujitsu MD86960A/MB869685A Ethernet adapters conf fe0 5 0x240
Intel EtherExpress Ethernet adapter conf ix0 10 0x300
DEC Etherworks 2 and 3 Ethernet adapters conf le0 5 0x300
---Inactive Drivers--------------------------------------------Dev--------------
Storage : (Collapsed)
Network : (Collapsed)
Communications : (Collapsed)
Input : (Collapsed)
Multimedia :
Miscellaneous :
--------------------------------------------------------------------------------
Port address : 0x280 Memory address : 0xd8000 Conflict allowed
IRQ number : 5
Flags : 0
--------------------------------------------------------------------------------
The port address is in reverse video, which means that we can edit it. We type
in 0x320 and press Tab to get to the IRQ field, where we
enter 9. Then we press Enter to leave the edit mode, and
q to leave the configuration editor. Booting continues as normal, but
this time the system finds our Ethernet board.
This is only an example, of course. It's easier to play around with the editor
than to describe it. Don't worry about damaging anything on disk, since at this
point it's just you and the computer, and the computer doesn't yet know about
any peripherals.
Due to the nature of PC hardware, IRQ 2 and IRQ 9 are the same thing. Never
specify IRQ 2 to UserConfig: use IRQ 9 instead. If you use IRQ 2, the driver
will not work correctly.
Starting UserConfig from hard diskWhen you boot from hard disk, the selection menu does not appear, since this
would be a nuisance: normally you will not want to change your configuration
once it is installed. If you need to do so, however, make sure that UserConfig
is included in your kernel (see , page ). To
activate UserConfig on boot, wait until you see:
BTX loader 1.00 BTX version is 1.00
BIOS drive A: is disk0
BIOS drive C: is disk1
FreeBSD/i386 bootstrap loader, Revision 0.2 640/64512kB
(grog@bumble.example.org, Sun Jan 31 16:25:12 CST 1999)
/ this is a ``twirling baton''
Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [kernel] in 6 seconds... this counts down from 10 secondsNormally, you just wait until the countdown reaches 0, or press Enter, and
the bootstrap will continue and load the kernel. You have a number of options,
however—see the man page boot(8) for a complete discussion. To
interrupt the boot process, press the space bar (most keys will do, but the
space bar is easiest to remember). You will get:
Type '?' for a list of commands, 'help' for more detailed help.
disk1s1a:>
To start UserConfig, enter:
disk1s1a:> boot -c
Copyright (c) 1992-1999 The FreeBSD Project.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
FreeBSD 3.1-RELEASE #0: Wed Feb 17 13:06:56 CST 1999
grog@daemon.lemis.com:/usr/src/sys/compile/GENERIC
Timecounter "i8254" frequency 1193182 Hz
Timecounter "TSC" frequency 132968074 Hz
CPU: Pentium/P54C (132.97-MHz 586-class CPU)
Origin = "GenuineIntel" Id = 0x52c Stepping=12
Features=0x1bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8>
real memory = 67108864 (65536K bytes)
FreeBSD Kernel Configuration Utility - Version 1.2
Type "help" for help or "visual" to go to the visual
configuration interface (requires MGA/VGA display or
serial terminal capable of displaying ANSI graphics).
config> v go into visual modeYou can type help for help, as the prompt suggests, but just about the
only thing you need is the visual configuration interface.
Probing the hardwareprobing
When you continue from the UserConfig selection menu, an incredible amount of
information will scroll off the screen. Once the boot is complete, you can go
back and examine text that has scrolled off the top of the screen: press
ScrollLock. The cursor will disappear, and you can use the PageUp
and PageDown keys to scroll up to 3 previous screenfuls. To exit this
mode, press ScrollLock again. We'll go through this output in some detail
over the next few pages.
Once it has finished loading, the kernel calls all configured drivers to examine
the hardware configuration of the machine on which it is running. This is
called probing for the devices. If you have time to follow it, it's a
good idea to confirm that it's correct. It's not that important unless
something goes wrong, and then it won't scroll off the screen. We see
something like:
Copyright (c) 1992-1999 FreeBSD Inc.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
FreeBSD 3.2-RELEASE #1733: Wed May 12 10:47:53 CST 1999
grog@presto.example.org:/usr/src/sys/compile/PRESTO
Timecounter "i8254" frequency 1193182 Hz
Timecounter "TSC" frequency 132955161 Hz
CPU: Pentium/P54C (132.96-MHz 586-class CPU)
Origin = "GenuineIntel" Id = 0x52c Stepping=12
Features=0x1bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8>
The lines above identify the CPU: it's an original Pentium (internal code P54C),
and it runs at 133 MHz.
real memory = 67108864 (65536K bytes)
avail memory = 62017536 (60564K bytes)
Preloaded elf kernel "kernel" at 0xf0337000.
The real memory is the size of RAM. Some systems reserve 1 kB of RAM in real
mode, but this should not have any effect on the value of real memory.
Available memory is the memory available to users after the kernel has been
loaded and initialized. The load address of the kernel is not of much interest
unless you have specific problems.
Sometimes the kernel will report only 16 MB even on larger systems. This is due
to BIOS incompatibilities, and occurs surprisingly often on big-name machines.
To fix it, build a custom kernel which specifies the memory size
explicitly—see the description of the MAXMEM parameter on page
.
Next we look for the other chips on the motherboard:
Probing for devices on PCI bus 0:
chip0: <Intel 82437FX PCI cache memory controller> rev 0x01 on pci0.0.0
chip1: <Intel 82371FB PCI to ISA bridge> rev 0x02 on pci0.7.0
ide_pci0: <Intel PIIX Bus-master IDE controller> rev 0x02 on pci0.7.1
This is an Intel 82437 FX chipset. We continue to look at the hardware
connected to the motherboard, some of which is in fact implemented in the FX
chipset:
ahc0: <Adaptec 2940 Ultra SCSI adapter> rev 0x00 int a irq 14 on pci0.17.0
ahc0: aic7880 Wide Channel A, SCSI Id=7, 16/255 SCBs
As the first line states, this is a SCSI host adapter using PCI interrupt A, IRQ
14, and its PCI slot number is 17.
Probing for devices on the ISA bus:
sc0 on isa this is the system console
sc0: VGA color <16 virtual consoles, flags=0x0>
ed0 not found at 0x280 ed0 is a possible Ethernet board
ed1 not found at 0x300 and ed1 is another one at a different address
atkbdc0 at 0x60-0x6f on motherboard
atkbd0 irq 1 on isa
sio0 at 0x3f8-0x3ff irq 4 flags 0x0 on isa the first serial port
sio0: type 16550A it's a buffered UART
sio1 at 0x2f8-0x2ff irq 3 on isa the second serial port
sio1: type 16550A
sio2 not found at 0x3e8 no more serial I/O ports
sio3 not found at 0x2e8
COM1:
Recall from page that UNIX devices start counting from 0,
whereas Microsoft starts counting from 1. Devices sio0 through
sio3 are known as COM1: through COM4: in the Microsoft
world.
psm0 not found no PS/2 mouse
mse0 not found at 0x23c and no Microsoft mouse
fdc0 at 0x3f0-0x3f7 irq 6 drq 2 on isa Floppy controller
fdc0: FIFO enabled, 8 bytes threshold
fd0: 1.44MB 3.5in one 3\(12" drive
wdc0 at 0x1f0-0x1f7 irq 14 flags 0xa0ffa0ff on isa first IDE controller
wdc0: unit 0 (wd0): <ST51270A>, DMA, 32-bit, multi-block-32 Seagate ST51270A
wd0: 1223MB (2504880 sectors), 2485 cyls, 16 heads, 63 S/T, 512 B/S
wdc1 at 0x170-0x177 irq 15 flags 0xa0ffa0ff on isa second IDE controller
wdc1: unit 0 (wd2): <IBM-DHEA-36480>, DMA, 32-bit, multi-block-16
wd2: 6197MB (12692736 sectors), 12592 cyls, 16 heads, 63 S/T, 512 B/S
wdc1: unit 1 (wd3): <IBM-DHEA-38451>, DMA, 32-bit, multi-block-16
wd3: 8063MB (16514064 sectors), 16383 cyls, 16 heads, 63 S/T, 512 B/S
This system has only one floppy drive, but three IDE drives on two controllers.
The controllers both run in DMA mode. The flags value
(0xa0ffa0ff) gives more detail about how the controller runs. See page
for more details of the flags.
In this case, both IDE controllers have disks connected, and the boot proceeds
relatively quickly. If one of the controllers has no disks connected, things
are different: before the disk driver gives up, it waits for quite a long time,
about 30 seconds. Don't despair, the system probably hasn't crashed and burned,
the driver just wants to be really sure that there is no disk there. If
this wait gets on your nerves, you can rebuild the kernel with a shorter wait.
See page for further information.
The disk driver reads the information about the disk drives directly from the
drive. This is a relatively new feature of IDE drives. ST506 drives did not
supply this information, and many BIOSes do not read the drive. Instead, they
store information about the drive configuration in their CMOS memory. If the
stored values don't match the real parameters, you may have difficulty booting.
Since FreeBSD doesn't use the BIOS after booting, it might work fine with a
system, but if you also have Microsoft or another operating system on the disk,
it may not work. In this case, compare the values above with those stored in
CMOS memory.
Next, more SCSI drivers check for their boards:
bt_isa_probe: Probe failed for card at 0x330
bt0 not found at 0x330
aha0 at 0x330-0x333 irq 12 drq 6 on isa
aha0: AHA-1542 64 head BIOS FW Rev. 0.5 (ID=41) SCSI Host Adapter, SCSI ID 7, 16 CCBs
aha1 not found at 0x334
Here we have found another SCSI host adapter, this time an Adaptec 1542. The
SCSI driver can read the DMA channel number and the IRQ value, but it hasn't
checked the bus speed, since this can cause some controllers to crash. There is
no particular sequence in booting, and in this example the two host adapters
were found at significantly different times.
Next, a number of other drivers probe:
wt0 not found at 0x300
mcd0 not found at 0x300
matcdc0 not found at 0x230
scd0 not found at 0x230
ppc0 at 0x378 irq 7 flags 0x40 on isa
ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode
lpt0: <generic printer> on ppbus 0
lpt0: Interrupt-driven port
ppi0: <generic parallel i/o> on ppbus 0
plip0: <PLIP network interface> on ppbus 0
lpt0: <generic printer> on ppbus 0
lpt0: Interrupt-driven port
The only thing found here is the parallel port. Since FreeBSD 3.1, this port is
under control of the ppbus driver, and the printer is a subdevice.
Continuing,
1 3C5x9 board(s) on ISA found at 0x250
ep0 at 0x250-0x25f irq 10 on isa
ep0: aui/utp/bnc[*BNC*] address 00:a0:24:37:0c:bd
Here the ep driver has found a 3Com 3C509 Ethernet board. In addition
to I/O address and IRQ, it displays the Ethernet address
(00:a0:24:37:0c:bd) and the information that this board, which has
multiple interfaces, is using the BNC interface.
vga0 at 0x3b0-0x3df maddr 0xa0000 msize 131072 on isa
npx0 flags 0x1 on motherboard
npx0: INT 16 interface
sb_reset_dsp failed
sb0 not found at 0x220
Intel Pentium detected, installing workaround for F00F bug
Here the VGA display driver reports the board that it found. The value
msize is for text mode only. Modern display boards have several
megabytes of memory, but that will not show.
The SoundBlaster driver reports a failure (sb_reset_dsp failed) before
deciding that there is no SoundBlaster board present. This occurs relatively
frequently and is no cause for concern unless you really do have a SoundBlaster
board installed.
The F00F bug refers to a bug in the original Pentium chipset whereby
programs can hang the CPU by executing an invalid instruction with the code
0xf00f. The workaround prevents this bug from having any effect, but it
slows down the machine a little. This bug only affects the original Pentium,
not the Pentium Pro, Pentium II or Pentium III. If you don't have an original
Pentium, you can improve performance fractionally by using the configuration
option NO_F00F_HACK. See page for more details.
Waiting 3 seconds for SCSI devices to settle
At this point, most of the probes are finished. The SCSI drivers reset the SCSI
busses and wait 3 seconds for the devices to complete their reset. This kernel
has been modified to wait only 3 seconds: by default the value is 15 seconds.
See the description of the parameter SCSI_DELAY on page
details of how to change this value.
So far, the kernel has been running entirely in memory. Now it mounts the root
file system:
changing root device to da0s1e
In previous versions of FreeBSD, this was the last message you would see from
the kernel. The disks would already have been located, and there would be no
more highlighted messages. This is also the case if you have an IDE-only
system. The CAM driver, however, delays device probes until they are needed, so
next you see:
da1 at ahc0 bus 0 target 2 lun 0
da1: <CDC 94181-15 0293> Fixed Direct Access SCSI-CCS device
da1: 3.300MB/s transfers
da1: 573MB (1173930 512 byte sectors: 64H 32S/T 573C)
da2 at ahc0 bus 0 target 3 lun 0
da2: <CDC 94181-15 0293> Fixed Direct Access SCSI-CCS device
da2: 3.300MB/s transfers
da2: 573MB (1173930 512 byte sectors: 64H 32S/T 573C)
da3 at ahc0 bus 0 target 4 lun 0
da3: <CDC 94181-15 0293> Fixed Direct Access SCSI-CCS device
da3: 3.300MB/s transfers
da3: 573MB (1173930 512 byte sectors: 64H 32S/T 573C)
da4 at ahc0 bus 0 target 5 lun 0
da4: <CDC 94181-15 0293> Fixed Direct Access SCSI-CCS device
da4: 3.300MB/s transfers
da4: 573MB (1173930 512 byte sectors: 64H 32S/T 573C)
sa0 at aha0 bus 0 target 3 lun 0
sa0: <EXABYTE EXB-8505SMBANSH2 0793> Removable Sequential Access SCSI-2 device
sa0: 5.000MB/s transfers (5.000MHz, offset 11)
sa1 at aha0 bus 0 target 4 lun 0
sa1: <ARCHIVE Python 28849-XXX 4.CM> Removable Sequential Access SCSI-2 device
sa1: 5.000MB/s transfers (5.000MHz, offset 15)
sa2 at aha0 bus 0 target 5 lun 0
sa2: <TANDBERG TDC 3800 -03:> Removable Sequential Access SCSI-CCS device
sa2: 3.300MB/s transfers
pass4 at aha0 bus 0 target 4 lun 1
pass4: <ARCHIVE Python 28849-XXX 4.CM> Removable Changer SCSI-2 device
pass4: 5.000MB/s transfers (5.000MHz, offset 15)
da5 at aha0 bus 0 target 2 lun 0
da5: <CONNER CFP4207S 4.28GB 2847> Fixed Direct Access SCSI-2 device
da5: 3.300MB/s transfers, Tagged Queueing Enabled
da5: 4096MB (8388608 512 byte sectors: 64H 32S/T 4096C)
cd0 at aha0 bus 0 target 6 lun 0
cd0: <NRC MBR-7 110> Removable CD-ROM SCSI-2 device
cd0: 3.300MB/s transfers
cd0: cd present [322265 x 2048 byte records]
da0 at aha0 bus 0 target 0 lun 0
da0: <IBM DORS-32160 WA0A> Fixed Direct Access SCSI-2 device
da0: 10.000MB/s transfers (10.000MHz, offset 15), Tagged Queueing Enabled
da0: 2063MB (4226725 512 byte sectors: 64H 32S/T 2063C)
There are a number of things to note here:
The SCSI subsystem includes a total of six disk drives, three tape drives and a
CD-ROM.
The first SCSI disk drive gets the ID da1, not da0. da0 is
there, but it comes at the very end. This indicates that the drive has been
``wired down'' (see page ), because it is the system disk. This is
the only way to put a system disk on the second SCSI controller in this
configuration.
The probes also find a device pass4 at aha target 4, LUN
(logical unit) 1. This is the same target as sa1, which is on
LUN 0, and it represents the changer device.
commandsysinstallsysinstallcommand
At this point, the kernel has finished probing, and it transfers control to the
shell script /etc/rc. From this point on the display is in normal
intensity. /etc/rc first reads the configuration information in
/etc/defaults/rc.conf and /etc/rc.conf (see page ).
After that, it starts ccd and vinum if requested:
vinum: loaded
vinum: reading configuration from /dev/da2h
vinum: updating configuration from /dev/da3h
vinum: updating configuration from /dev/da4h
vinum: updating configuration from /dev/da1h
Next, it checks the consistency of the file systems. Normally you'll see
messages like this for each file system in /etc/fstab:
/dev/rda0s1a: FILESYSTEM CLEAN; SKIPPING CHECKS
/dev/rda0s1a: clean, 6311 free (367 frags, 743 blocks, 0.9% fragmentation)
/dev/rda0s1e: FILESYSTEM CLEAN; SKIPPING CHECKS
/dev/rda0s1e: clean, 1577 files, 31178 used, 7813 free (629 frags, 898 blocks, 1.6% fr
agmentation)
If your system has crashed, however, either due to a software or hardware
problem, or because it was not shut down correctly, you'll see something like:
WARNING: / was not properly dismounted
/dev/rda0s1a: 6311 free (367 frags, 743 blocks, 0.9% fragmentation)
Next, /etc/rc invokes the first of three network start invocations.
This one initializes the interfaces, sets the routes and starts the firewall if
necessary:
Doing initial network setup: hostname.
ep0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet 223.147.37.2 netmask 0xffffff00 broadcast 223.147.37.255
ether 00:a0:24:37:0c:bd
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet 127.0.0.1 netmask 0xff000000
add net default: gateway 223.147.37.5
Additional routing options:.
routing daemons:.
In this example, there were no additional routing options, and no routing
dæmons. The messages accordingly have nothing between the characters :
and .. You'll see this relatively frequently.
Next, /etc/rc mounts the network file systems, cleans up /var/run/
and then starts syslogd unless you have disabled it:
Mounting NFS file systems.
Additional daemons: syslogd.
Then it checks if we have a core dump. If so, it will try to save it to
/var/crash.
checking for core dump...savecore: no core dump
This may fail if there isn't enough space in /var/crash. If the dump does
fail, you can clean up and save the dump later, as long as you haven't used
enough swap space to overwrite the dump.
Next comes the second pass of the network startup, which starts our choice of
named, ntpdate, xntpd, timed, portmap,
ypserv, rpc.ypxfrd, rpc.yppasswdd, ypbind, ypset,
keyserv and rpc.ypupdated:
Doing additional network setup: named xntpd portmap.
starting. named 8.1.2 Sun May 9 13:04:13 CST 1999 grog@freebie.example.org:/usr/ob
j/usr.sbin/named
master zone "example.org" (IN) loaded (serial 1997010902)
master zone "37.147.223.in-addr.arpa" (IN) loaded (serial 1996110801)
listening on [192.109.197.149].53 (ep0)
listening on [127.0.0.1].53 (lo0)
Forwarding source address is [0.0.0.0].1063
Ready to answer queries.
With the exception of the first line, all the messages come from named.
They may come in the middle of the first line, rather than waiting for the end
of the line.
Next, /etc/rc enables quotas if asked, and then runs the third network
pass, which starts our choice of mountd, nfsd, rpc.lockd,
rpc.statd, nfsiod, amd, rwhod and kerberos:
Starting final network daemons: mountd nfsd rpc.statd nfsiod rwhod.
Now we're almost done. /etc/rc rebuilds a couple of internal databases
(for use by the ps command and some others), then it sets the default
paths for ldconfig:
setting ELF ldconfig path: /usr/lib /usr/lib/compat /usr/X11R6/lib /usr/local/lib
setting a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout /usr/X11R6/lib/aout /
usr/local/lib/aout
Next, it starts your choice of inetd, cron, printer,
sendmail and usbd:
starting standard daemons: inetd cron sendmail.
The last thing that /etc/rc does is to check for other startup files.
These could be in the files specified in the variable local_startup, or
in the file /etc/rc.local. In our case, there are none, so all we see is:
Local package initialization:.
Finally, we're done. /etc/rc stops, and init proecesses
/etc/ttys, which starts getty processes on specified terminals.
On the console, we see:
Wed May 12 13:52:00 CST 1999
FreeBSD (freebie.example.org) (ttyv0)
login:
At this point, we're at the beginning of (page ).
Single user modesingleuser mode
Sometimes it's inconvenient that multiple users can access the system. For
example, if you're repartitioning a disk, you don't want other people walking
all over the disk while you're doing so. Even if you're the only user on the
system, dæmons may be doing things in the background. In order to avoid this
problem, you can stop the boot process before most of the dæmons have been
started and enter single user mode. To do this, specify the -s
flag at boot time:
Boot: -sAs soon as the device probes have been completed, the system startup will be
interrupted, and you will be prompted for a shell. Always choose sh:
some other shells, notably bash, get confused in single user mode. Only
the root file system will be accessible, and it will be mounted read-only. The
reason for this is that the file system may be damaged and require repair before
you can write to it. If you do need to write to the root file system, you
should first check the consistency of the file system with fsck. For
example,
npx0 on motherboard
npx0: INT 16 interface end of the probes (high intensity display)
Enter pathname of shell or RETURN for sh: hit RETURN
erase ^H, kill ^U, intr ^C
# fsck -y /dev/rwd0a check the integrity of the root file system
** /dev/rwd0a
** Last Mounted on /
** Root file system
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
1064 files, 8190 used, 6913 free (61 frags, 1713 blocks, 0.4% fragmentation)
# mount -u / remount root file system read/write
# mount /usr mount any other file systems you needTo leave single user mode and enter multi user mode, just enter CTRL-D:
# ^D
Skipping file system checks...
(the rest of the boot sequence)runlevelsinitS
System V has the concept of run levels, which are controlled by
init. Single user mode corresponds to run level S, and multi user
mode corresponds to run level 3. There is nothing to correspond to the other
System V run levels, in particular run level 2, which starts a System V system
without networking. Networking is such an integral part of FreeBSD that this is
just not practicable. You also can't enter single user mode with the System V
command init S. If you try, you get:
# init S
init: already running
You can enter single user mode from a running FreeBSD system with the
shutdown command, which we'll look at in the next section.
Unfortunately, shutdown leaves some dæmons running and file systems
mounted, so it's preferable to enter by rebooting, as shown above.
Password protecting single-user mode/etc/ttys
If you run a secure environment, you could be concerned about the fact that you
can start up in single-user mode without entering a password. That's the
default—normally, if somebody can access your system console, a password is
no longer much use, and it can be a nuisance—but you can change it. Find
this entry in /etc/ttys, and change the word secure to
insecure:
# If you want to be asked for password, change "secure" to "insecure" here
console none unknown off insecure
FreeBSD configuration files
One of the outstanding things about UNIX is that all system configuration
information is stored in text files, usually in the directory
/etc .
Some people think that this method seems primitive by comparison with a flashy
GUI configuration editor, but it has significant advantages. In particular, you
see exactly what the program reads. WIth a GUI editor, the real
configuration is usually stored in a format which you can't read, and even when
you can, it's undocumented. Also, you can see more of the configuration at a
time: a GUI editor usually presents you with only small parts of the
configuration, and it's difficult to see the relationships.
In the Microsoft world, one of the most common methods of problem resolution is
to reinstall the system. This is a declaration of bankruptcy: it takes forever,
you're liable to cause other problems on the way, and you never find out what
the problem was. If your FreeBSD system doesn't do what you expect, don't
reinstall the system. Take a look at the configuration files, and there's a
good chance that you'll find the problem there.
The vast majority of configuration files are the same across all versions of
UNIX. This appendix touches on them briefly, but you can get in-depth
information in books such as the UNIX System Administration Handbook, by
Evi Nemeth, Garth Snyder, Scott Seebass, and Trent R. Hein. In all cases, you
can get more information from section 5 of the man pages.
In this section, we'll first look at /etc/defaults/rc.conf and
/etc/rc.conf. On page we'll look at the other
non-network configuration files, and on page we'll look at
the files related to network configuration.
/etc/rc.conf/etc/rc.conf/etc/rc.conf
is the main system configuration file, and in this format it is unique to
FreeBSD. In older versions of FreeBSD, this file was called
/etc/sysconfig—only
the name has changed.
/etc/rc.conf
is intended to be the one file which defines the configuration of your
system—that is to say, what the system needs to do when it starts up. It's
not quite that simple, but nearly all site-dependent information is stored here.
We'll walk through the version that was current at the time of writing. The
files will change as time goes on, but most of the information will remain
relevant.
/etc/rc.conf is completely your work. When you install the system,
there is no such file: you have to create it. What you will find is a file
/etc/defaults/rc.conf, which contains default values for everything in
/etc/rc.conf. Why do it this way? In fact, previous versions of FreeBSD
supplied the file /etc/rc.conf and you had to edit it. The problems
arrived when you upgraded: which variables were the old defaults, and which ones
had you changed? It was quite difficult to decide. As a result, FreeBSD
has the defaults in one file. You shouldn't change this file: if you
want to override the default, put the new value in /etc/rc.conf. Then,
when you upgrade, you can keep your old /etc/rc.conf, and you only need to
change it if new features have been introduced and you want to change them.
Let's walk through /etc/defaults/rc.conf. As we do, we'll build up our
/etc/rc.conf. To avoid too much confusion, I show the text which goes
into /etc/rc.conf in \s8constant width bold\s0, whereas the text
in /etc/defaults/rc.conf is in \s8constant width\s0.
#!/bin/sh
#
# This is rc.conf - a file full of useful variables that you can set
# to change the default startup behavior of your system. You should
# not edit this file! Put any overrides into one of the ${rc_conf_files}
# instead and you will be able to update these defaults later without
# spamming your local configuration information.
#
# All arguments must be in double or single quotes.
#
# $I\&d: rc.conf,v 1.1.2.4 1999/05/03 08:13:55 grog Exp $
##############################################################
### Important initial Boot-time options #####################
##############################################################
swapfile="NO" # Set to name of swapfile if aux swapfile desired.
You only need to set swapfile if you want an additional swap file. We
will see an example of this on page .
apm_enable="NO" # Set to YES if you want APM enabled.
pccard_enable="NO" # Set to YES if you want to configure PCCARD devices.
pccard_mem="DEFAULT" # If pccard_enable=YES, this is card memory address.
pccard_ifconfig="NO" # Specialized pccard ethernet configuration (or NO).
The four preceding parameters apply to notebooks only. We don't discuss them in
this book.
local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d" # startup script dirs.
/etc/rc2.d
This is a list of directories which are searched for startup scripts. If you
come from a System V background, you would expect to find these scripts in the
directories such as /etc/rc2.d.
local_periodic="/usr/local/etc/periodic /usr/X11R6/etc/periodic" # periodic script dirs
local_periodic is a list of directories to search for scripts to be run
by cron. Currently it is not used.
rc_conf_files="/etc/rc.conf /etc/rc.conf.local"
rc_conf_files is a list of files to read after this file. You'll
recognize /etc/rc.conf, which we discussed above.
/etc/rc.conf.local is an idea that hasn't completely died, but there's a
good chance that it will. You'd be best off not to use it until you're sure
it's going to stay.
For obvious reasons, this is one entry in /etc/defaults/rc.conf which
you can't override in /etc/rc.conf.
##############################################################
### Network configuration sub-section ######################
##############################################################
### Basic network options: ###
hostname="myname.my.domain" # Set this!
hostname is the fully qualified name of the host. You should always
override it in /etc/rc.conf. See page for more details.
In /etc/rc.conf, we'll put:
hostname="presto.example.org" # Set this!Continuing in /etc/defaults/rc.conf,
nisdomainname="NO" # Set to NIS domain if using NIS (or NO).
If you're using Sun's NIS, set this. We don't discuss NIS in this book.
firewall_enable="NO" # Set to YES to enable firewall functionality
firewall_script="/etc/rc.firewall" # Which script to run to set up the firewall
firewall_type="UNKNOWN" # Firewall type (see /etc/rc.firewall)
firewall_quiet="NO" # Set to YES to suppress rule display
Parameters for the ipfw firewall. See page ,
where we set the following flags in /etc/rc.conf:
firewall_enable="YES" # Set to YES to enable firewall functionality
firewall_type="client" # Firewall type (see /etc/rc.firewall)
natd_program="/sbin/natd" # path to natd, if you want a different one.
natd_enable="NO" # Enable natd (if firewall_enable == YES).
natd_interface="fxp0" # Public interface or IPaddress to use.
natd_flags="" # Additional flags for natd.
Parameters for natd. See page for more details. In the
example there, we'll add these lines to /etc/rc.conf:
natd_enable="YES" # Enable natd (if firewall_enable == YES).
natd_interface="tun0" # Public interface or IPaddress to use.Continuing with /etc/defaults/rc.conf,
tcp_extensions="NO" # Disallow RFC1323 extensions (or YES).
We don't discuss these extensions in this book. Leave this variable set to
NO unless you have problems.
network_interfaces="lo0" # List of network interfaces (lo0 is loopback).
ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration.
#ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry.
This is one area that you must change if you have any network interfaces at
all. On page , we come up with the following entries in
/etc/rc.conf:
network_interfaces="ed0 lo0" # List of network interfaces (lo0 is loopback).
ifconfig_ed0="inet 223.147.37.2 netmask 255.255.255.0"
ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration.Continuing with /etc/defaults/rc.conf,
# If you have any sppp(4) interfaces above, you might also want to set
# the following parameters. Refer to spppcontrol(8) for their meaning.
sppp_interfaces="" # List of sppp interfaces.
#sppp_interfaces="isp0" # example: sppp over ISDN
#spppconfig_isp0="authproto=chap myauthname=foo myauthsecret='top secret' hisauthname
=some-gw hisauthsecret='another secret'"
These are parameters for the sppp implementation for ISDN4BSD,
which we won't discuss here.
### Network daemon (miscellaneous) & NFS options: ###
syslogd_enable="YES" # Run syslog daemon (or NO).
syslogd_flags="" # Flags to syslogd (if enabled).
You should always run syslogd unless you have a very good reason not to.
syslogd_flags is normally empty, as in this example.
inetd_enable="YES" # Run the network daemon dispatcher (or NO).
inetd_flags="" # Optional flags to inetd (always enabled).
We will look at inetd on page . Normally you will want to keep
it enabled, and you won't need any flags for it.
named_enable="NO" # Run named, the DNS server (or NO).
named_program="named" # path to named, if you want a different one.
named_flags="" # Flags for named
#named_flags="-u bind -g bind" # Flags for named
These parameters specify whether we should run the name server, and what flags
we should use if we do. See page for more details. Previous
versions of named required a flag to specify the location of the
configuration file, but the location FreeBSD uses has now become the standard,
so we no longer need to specify any flags. All we put in /etc/rc.conf
is:
named_enable="YES" # Run named, the DNS server (or NO).Continuing with /etc/defaults/rc.conf,
kerberos_server_enable="NO" # Run a kerberos master server (or NO).
kadmind_server_enable="NO" # Run kadmind (or NO) -- do not run non
# a slave kerberos server
kerberos_stash="" # Is the kerberos master key stashed?
Set these if you want to run Kerberos. We don't discuss Kerberos in this book.
rwhod_enable="NO" # Run the rwho daemon (or NO).
rwhod_flags="" # Flags for rwhod
Set this if you want to run the rwhod dæmon, which broadcasts
information about the system load.
amd_enable="NO" # Run amd service with $amd_flags (or NO).
amd_flags="-a /net -c 1800 -k i386 -d my.domain -l syslog /host /etc/amd.map"
amd_map_program="NO" # Can be set to "ypcat -k amd.master"
Enable the automounter. We don't discuss the automounter in this book.
nfs_client_enable="NO" # This host is an NFS client (or NO).
nfs_client_flags="-n 4" # Flags to nfsiod (if enabled).
nfs_access_cache="2" # Client cache timeout in seconds
nfs_server_enable="NO" # This host is an NFS server (or NO).
nfs_server_flags="-u -t -n 4" # Flags to nfsd (if enabled).
mountd_flags="-r" # Flags to mountd (if NFS server enabled).
nfs_reserved_port_only="NO" # Provide NFS only on secure port (or NO).
rpc_lockd_enable="NO" # Run NFS rpc.lockd (*broken!*) if nfs_server.
rpc_statd_enable="YES" # Run NFS rpc.statd if nfs_server (or NO).
portmap_enable="YES" # Run the portmapper service (or NO).
portmap_program="/usr/sbin/portmap" # path to portmap, if you want a different one.
portmap_flags="" # Flags to portmap (if enabled).
rpc_ypupdated_enable="NO" # Run if NIS master and SecureRPC (or NO).
Flags for NFS. See page . There we set the following values in
/etc/rc.conf:
nfs_client_enable="YES" # This host is an NFS client (or NO).
nfs_server_enable="YES" # This host is an NFS server (or NO).
keyserv_enable="NO" # Run the SecureRPC keyserver (or NO).
keyserv_flags="" # Flags to keyserv (if enabled).
rarpd_enable="NO" # Run rarpd (or NO).
rarpd_flags="" # Flags to rarpd.
xtend_enable="NO" # Run the X-10 power controller daemon.
xtend_flags="" # Flags to xtend (if enabled).
These entries refer to the Secure RPC key server, rarpd and the X-10
dæmon. We don't discuss any of them in this book. See the man pages
keyserv(8), rarpd(8) and xtend(8) respectively.
### Network Time Services options: ###
timed_enable="NO" # Run the time daemon (or NO).
timed_flags="" # Flags to timed (if enabled).
ntpdate_enable="NO" # Run the ntpdate to sync time (or NO).
ntpdate_program="ntpdate" # path to ntpdate, if you want a different one.
ntpdate_flags="" # Flags to ntpdate (if enabled).
xntpd_enable="NO" # Run xntpd Network Time Protocol (or NO).
xntpd_program="xntpd" # path to xntpd, if you want a different one.
xntpd_flags="-p /var/run/xntpd.pid" # Flags to xntpd (if enabled).
timed, ntpdate and xntpd are three different ways of
synchronizing your machine with the current date and time. See page
for more information. There we put the following values into
/etc/rc.conf:
xntpd_enable="YES" # Run xntpd Network Time Protocol (or NO).
xntpd_flags="" # Flags to xntpd (if enabled).Continuing with /etc/defaults/rc.conf,
# Network Information Services (NIS) options: ###
nis_client_enable="NO" # We're an NIS client (or NO)
nis_client_flags="" # Flags to ypbind (if enabled).
nis_ypset_enable="NO" # Run ypset at boot time (or NO).
nis_ypset_flags="" # Flags to ypset (if enabled).
nis_server_enable="NO" # We're an NIS server (or NO)
nis_server_flags="" # Flags to ypserv (if enabled).
nis_ypxfrd_enable="NO" # Run rpc.ypxfrd at boot time (or NO).
nis_ypxfrd_flags="" # Flags to rpc.ypxfrd (if enabled).
nis_yppasswdd_enable="NO" # Run rpc.yppasswdd at boot time (or NO).
nis_yppasswdd_flags="" # Flags to rpc.yppasswdd (if enabled).
More parameters for configuring NIS. As mentioned above, this book does not
deal with NIS.
### Network routing options: ###
defaultrouter="NO" # Set to default gateway (or NO).
static_routes="" # Set to static route list (or leave empty).
gateway_enable="NO" # Set to YES if this host will be a gateway.
Here's another area that we need to change if we're using any kind of a network.
On page we set the following values in /etc/rc.conf:
defaultrouter="223.147.37.5" # Set to default gateway (or NO).
static_routes="" # Set to static route list (or leave empty).Continuing with /etc/defaults/rc.conf,
router_enable="NO" # Set to YES to enable a routing daemon.
router="routed" # Name of routing daemon to use if enabled.
router_flags="-q" # Flags for routing daemon.
mrouted_enable="NO" # Do multicast routing (see /etc/mrouted.conf).
mrouted_flags="" # Flags for multicast routing daemon.
These parameters relate to the routing dæmons routed and mrouted.
In the configurations we considered, you don't need them.
ipxgateway_enable="NO" # Set to YES to enable IPX routing.
ipxrouted_enable="NO" # Set to YES to run the IPX routing daemon.
ipxrouted_flags="" # Flags for IPX routing daemon.
IPX is a Novell proprietary networking protocol which is designed to be similar
to IP. FreeBSD supplies the dæmon IPXrouted (note the capitalization)
which handles IPX routing tables. See the man page IPXrouted(8) for
further details.
arpproxy_all="" # replaces obsolete kernel option ARP_PROXYALL.
forward_sourceroute="NO" # do source routing (only if gateway_enable is set to "YES")
accept_sourceroute="NO" # accept source routed packets to us
Various IP options.
### ATM interface options: ###
atm_enable="NO" # Configure ATM interfaces (or NO).
#atm_netif_hea0="atm 1" # Network interfaces for physical interface.
#atm_sigmgr_hea0="uni31" # Signalling manager for physical interface.
#atm_prefix_hea0="ILMI" # NSAP prefix (UNI interfaces only) (or ILMI).
#atm_macaddr_hea0="NO" # Override physical MAC address (or NO).
# ATMARP server address (or local).
#atm_arpserver_atm0="0x47.0005.80.999999.9999.9999.9999.999999999999.00"
#atm_scsparp_atm0="NO" # Run SCSP/ATMARP on network interface (or NO).
atm_pvcs="" # Set to PVC list (or leave empty).
atm_arps="" # Set to permanent ARP list (or leave empty).
### ISDN interface options: ###
isdn_enable="NO" # Enable the ISDN subsystem (or NO).
isdn_fsdev="/dev/ttyv4" # Output device for fullscreen mode (or NO for daemon mode).
isdn_flags="-dn -d0x1f9" # Flags for isdnd
isdn_trace="NO" # Enable the ISDN trace subsystem (or NO).
isdn_traceflags="-f /var/tmp/isdntrace0" # Flags for isdntrace
Parameters for ATM and ISDN, which this book doesn't discuss.
### Miscellaneous network options: ###
icmp_bmcastecho="NO" # respond to broadcast ping packets
smurf
This parameter relates to the so-called smurf ``denial of service''
attack: according to the RFCs, a machine should respond to a ping to its
broadcast address. But what happens if somebody pings a remote network's
broadcast address across the Internet, as fast as he can? Each system on the
remote network will reply, completely overloading the Internet interface. Yes,
this is silly, but there are silly people out there. If you leave this
parameter as it is, your system will not be vulnerable. See
http://www.cert.org/advisories/CA-98.01.smurf.html for more details.
##############################################################
### System console options #################################
##############################################################
keymap="NO" # keymap in /usr/share/syscons/keymaps/* (or NO).
keyrate="NO" # keyboard rate to: slow, normal, fast (or NO).
keybell="NO" # bell to duration.pitch or normal or visual (or NO).
keychange="NO" # function keys default values (or NO).
cursor="NO" # cursor type {normal|blink|destructive} (or NO).
scrnmap="NO" # screen map in /usr/share/syscons/scrnmaps/* (or NO).
font8x16="NO" # font 8x16 from /usr/share/syscons/fonts/* (or NO).
font8x14="NO" # font 8x14 from /usr/share/syscons/fonts/* (or NO).
font8x8="NO" # font 8x8 from /usr/share/syscons/fonts/* (or NO).
blanktime="300" # blank time (in seconds) or "NO" to turn it off.
saver="NO" # screen saver: Uses /modules/${saver}_saver.ko
These parameters describe the use of alternate keyboard mappings when using the
standard character-based terminals only. See the files in
/usr/share/syscons/keymaps
for key map files, and
/usr/share/syscons/fonts
for alternate fonts. These parameters have no effect on the X-based displays
that this book assumes.
moused_enable="NO" # Run the mouse daemon.
moused_type="auto" # See man page for rc.conf(5) for available settings.
moused_port="/dev/cuaa0" # Set to your mouse port.
moused_flags="" # Any additional flags to moused.
allscreens_flags="" # Set this vidcontrol mode for all virtual screens
Parameters for moused, a mouse driver for the character-based terminals,
and global flags for virtual screens.
##############################################################
### Miscellaneous administrative options ###################
##############################################################
cron_enable="YES" # Run the periodic job daemon.
Run cron, the dæmon responsible for running things at specific times. See
page for a description of cron. You should leave this enabled
unless you have a good reason not to.
lpd_enable="YES" # Run the line printer daemon
lpd_program="/usr/sbin/lpd" # path to lpd, if you want a different one.
lpd_flags="" # Flags to lpd (if enabled).
See page for a discussion of printing. There's no particular
reason to change these defaults.
usbd_enable="NO" # Run the usbd daemon.
usbd_flags="" # Flags to usbd (if enabled).
Support for the Universal Serial Bus or USB is relatively new,
and it is liable to change. Consider this an experimental option at the moment.
See the man pages usbd(8) and usb(4) for more information.
sendmail_enable="YES" # Run the sendmail daemon (or NO).
sendmail_flags="-bd -q30m" # -bd is pretty mandatory
See page for a discussion of sendmail. There's normally no
need to change these values.
dumpdev="NO" # Device name to crashdump to (if enabled).
This parameter specifies how to take dumps when the system panics. See page
for details, where we set the following value in /etc/rc.conf:
dumpdev=/dev/wd0s1bContinuing with /etc/defaults/rc.conf,
enable_quotas="NO" # turn on quotas on startup (or NO).
check_quotas="NO" # Check quotas on startup (or NO).
accounting_enable="NO" # Turn on process accounting (or NO).
ibcs2_enable="NO" # Ibcs2 (SCO) emulation loaded at startup (or NO).
linux_enable="NO" # Linux emulation loaded at startup (or NO).
We don't discuss quotas or accounting in this book. We will look at the
parameters ibcs2_enable on page and
linux_enable on page .
rand_irqs="NO" # Stir the entropy pool (or NO).
rand_irqs is used by the random number devices,
/dev/random and /dev/urandom. These devices gather environmental
noise from device drivers and return good random numbers, suitable for
cryptographic use. These numbers are also good for seeding TCP sequence
numbers, and other places where it is desirable to have numbers which are not
only random, but hard to predict by an attacker.
clear_tmp_enable="NO" # Clear /tmp at startup.
In the old days, the startup sequence automatically deleted everything in the
file system /tmp. Sometimes this wasn't desirable, so now it's your
choice. Change this value to YES if you want the old behaviour.
ldconfig_paths="/usr/lib/compat /usr/X11R6/lib /usr/local/lib"
# shared library search paths
ldconfig_paths_aout="/usr/lib/compat/aout /usr/X11R6/lib/aout /usr/local/lib/aout"
# a.out shared library search paths
These two variables are lists of the directories which are searched to find
ELF and a.out dynamic libraries, respectively. See page
for more details. You would normally not remove anything
from these lists, but you might want to add something.
kern_securelevel_enable="NO" # kernel security level (see init(8)),
kern_securelevel="-1" # range: -1..3 ; `-1' is the most insecure
update_motd="YES" # update version info in /etc/motd (or NO)
The kernel runs with four different levels of security. Any superuser process
can raise the security level, but only init can lower it. The security levels
are:
Permanently insecure mode: always run the system in level 0 mode. This is the
default initial value.
Insecure mode: the immutable and append-only flags may be turned off. All
devices may be read or written subject to their permissions.
Secure mode: the system immutable and system append-only flags may not be turned
off. Disks for mounted filesystems, /dev/mem and /dev/kmem may
not be opened for writing.
Highly secure mode. This is the same as secure mode with the addition that
disks may not be opened for writing (except by mount(2)), whether or not
they are mounted. This level precludes tampering with filesystems by unmounting
them, but it also prevents running newfs(8) while the system is
multi-user.
Network secure mode. This is the same as highly secure mode with the addition
that IP packet filter rules (see page ) can not be
changed and dummynet configuration can not be adjusted. We don't discuss
dummynet in this book.
To set the secure level to anything except -1, set the variable
kern_securelevel to the value you want, and set
kern_securelevel_enable to YES.
start_vinum="" # set to YES to start vinum
vinum_drives="" # put in names of disks containing vinum drives
# to start vinum on only specific disks.
We will look at Vinum on page . There we put the following
text into /etc/rc.conf in order to start it on booting:
start_vinum="YES" # set to YES to start vinumOur /etc/rc.confTo summarize the changes from the defaults, our /etc/rc.conf should now
contain the following entries:
hostname="presto.example.org"
firewall_enable="YES" # Set to YES to enable firewall functionality
firewall_type="client" # Firewall type (see /etc/rc.firewall)
natd_enable="YES" # Enable natd (if firewall_enable == YES).
natd_interface="tun0" # Public interface or IPaddress to use.
named_enable="YES" # Run named, the DNS server (or NO).
nfs_client_enable="YES" # This host is an NFS client (or NO).
nfs_server_enable="YES" # This host is an NFS server (or NO).
xntpd_enable="YES" # Run xntpd Network Time Protocol (or NO).
xntpd_flags="" # Flags to xntpd (if enabled).
dumpdev=/dev/wd0s1b # Device name to crashdump to (if enabled).
start_vinum="YES" # set to YES to start vinum
Other configuration files
This section handles the non-network configuration files in alphabetical order.
See page for a description of network configuration files.
/etc/aliases/etc/aliases/etc/aliases
is used by sendmail to describe mail aliases. See page
for more details.
/etc/csh.cshrc, /etc/csh.login, /etc/csh.logout/etc/csh.cshrc/etc/csh.login/etc/csh.logoutcshcommandcommandcsh
These are default initialization files for csh. See the man page
csh(1) for more details.
/etc/crontab/etc/crontabcrondæmondæmoncron/etc/crontab
describes the jobs to be performed by cron on behalf of the system. See
page for more details.
/etc/disktab/etc/disktabdisklabelcommandcommanddisklabel/etc/disktab
contains descriptions of disk geometries for disklabel. See page
for further details.
/etc/fstab/etc/fstab/etc/rcmountcommandcommandmount/etc/fstab
contains a list of file systems known to the system. The script
/etc/rc
starts mount twice during system startup first to mount the local file
systems, and later to mount the NFS file system. mount will mount all
file systems unless they are explicitly excluded.
/etc/fstabfreebie.example.org
Here's a typical
/etc/fstab ,
from host freebie.example.org:
/dev/wd0a / ufs rw 1 1
/dev/wd0s1b none swap sw 0 0
/dev/wd0s1e /usr ufs rw 2 2
/dev/sd0b none swap sw 0 0
/dev/sd0h /src ufs rw 2 2
/dev/sd1h /home ufs rw 2 2
/dev/sd2b none swap sw 0 0
/dev/sd2e /S ufs rw,noauto 2 2
/dev/sd3a /mod ufs rw,noauto 0 0
# /dev/sd1e /src ufs rw,noauto 0 0
proc /proc procfs rw 0 0
# /dev/mcd0a /cdrom cd9660 ro,noauto 0 0
/dev/cd0a /cdrom/1 cd9660 ro,noauto 0 0
/dev/cd1a /cdrom/2 cd9660 ro,noauto 0 0
/dev/cd2a /cdrom/3 cd9660 ro,noauto 0 0
/dev/cd3a /cdrom/4 cd9660 ro,noauto 0 0
/dev/cd4a /cdrom/5 cd9660 ro,noauto 0 0
/dev/cd5a /cdrom/6 cd9660 ro,noauto 0 0
/dev/cd6a /cdrom/7 cd9660 ro,noauto 0 0
/dev/cd7a /cdrom/8 cd9660 ro,noauto 0 0
presto:/ /presto nfs soft,rw,noauto 0 0
presto:/usr /presto/usr nfs soft,rw,noauto 0 0
# presto:/var /presto/var nfs soft,rw,noauto 0 0
presto:/home /presto/home nfs soft,rw,noauto 0 0
bumble:/ /bumble nfs soft,rw,noauto 0 0
bumble:/usr /bumble/usr nfs soft,rw,noauto 0 0
wait:/C /C nfs soft,rw,noauto 0 0
wait:/ /wait nfs soft,rw,noauto,tcp 0 0
This information has the following meaning:
ufscd9660proc
The first column contains either the name of a device (for swap, ufs and
cd9660 file systems), the name of a file system (for NFS file systems),
or proc for the proc file system.
The lines beginning with # are commented out: mount
ignores them completely.
The second column is either a mount point or the keyword none in the
case of a partition which is not mounted, such as swap.
The third column is the kind of file system (or swap).
The fourth column are flags relating to the particular file system being
mounted. Some of the more common are:
Mount flags
box,center,tab(#) ;
| lfCWp9 | lw70 | .
Flag#Purpose
=
ro#Mount read-only
rw#Mount read/write
sw#Mount as swap
noauto#Don't mount automatically
soft#T{
For an NFS mount, fail if the request times out. If you don't specify this
option, NFS will keep retrying for ever.
T}
tcp#T{
For NFS only, mount with TCP transport rather than the standard UDP transport.
This feature is supported almost only by BSD systems—check whether the other
end offers TCP transport.
T}
For NFS mount flags, see , page .
Why are there so many entries with the noauto keyword? If you don't
bother to mount them, why bother to mention them?
If file system has an entry in
/etc/fstab ,
mount is clever enough to get all the information it needs from this
file. You just need to specify the name of the mount point or the name of the
special device (for ufs and cd9660) or the remote file system
(for NFS). This is particularly useful for cd9660. Without an entry in
/etc/fstab ,
you would have to write:
# mount -t cd9660 -o ro /dev/cd0a /cdromWith the entry, you can simplify this to:
# mount /cdrom/etc/gettytab/etc/gettytabgettydæmondæmongetty/etc/gettytab
describes profiles for getty. You probably don't need it; check the man
page (on your system, but not in this book) if you're interested.
/etc/group/etc/group/etc/group
defines the groups known to the system. See page for more details.
/etc/login.conf/etc/login.conf/etc/login.conf
describes user parameters set at login time. See page for more
details.
/etc/manpath.config/etc/manpath.configmancommandcommandman/etc/manpath.config
is a configuration file for man. You don't usually need to change this
file.
/etc/master.passwd/etc/master.passwd/etc/master.passwd
is the real password file. We looked at it on page .
/etc/motd/etc/motdmessageof the day/etc/motd
(message of the day) is a file which is printed out at login. See page
for an example.
/etc/passwd/etc/passwd/etc/passwd
is the old-style password file. It is now present only for programs which
expect to read it. See page for more details.
/etc/printcap/etc/printcap/etc/printcap
describes the printers connected to a system. See page for more
details.
/etc/profile/etc/profile/etc/profile
is a default startup file for Bourne-style shells. See page for
more details.
/etc/pwd.db/etc/pwd.db/etc/pwd.db
is a machine-readable form of the user database with the passwords removed. We
looked at it on page .
/etc/rc/etc/rc/etc/rc
is the main script which starts up the system. It uses the other files whose
names start with
/etc/rc
to perform specific initialization. See page for more details.
/etc/rc.i386/etc/rc.i386/etc/rc.i386
is used to initialize features specific to the Intel 386 architecture, such as
SCO and Linux emulation. You don't normally need to look at or change this
file.
/etc/rc.local/etc/rc.local/etc/rc.conf/etc/rc.local
is the configuration file which you use to include specific commands which are
not catered for in
/etc/rc.conf .
We've seen a few examples in the book; check the index for more information.
/etc/rc.pccard/etc/rc.pccard/etc/rc.pccard
sets up laptops using the PCCARD bus. We don't discuss this in this book.
/etc/rc.serial/etc/rc.serial/etc/rc.serial
sets default values for serial devices. We don't discuss this in this book.
/etc/sendmail.cf/etc/sendmail.cfsendmaildæmondæmonsendmail/etc/sendmail.cf
is the main configuration file for sendmail. We will look at it on page
.
/etc/shells/etc/shellsftpcommandcommandftp/etc/shells
is a list of valid shells, used by ftp and some other programs. See
page for more details.
/etc/spwd.db/etc/spwd.db/etc/spwd.db
is a machine-readable form of the user database with the passwords intact. We
looked at it on page .
/etc/syslog.conf/etc/syslog.confsyslogddæmondæmonsyslogd/etc/syslog.conf
is the configuration file for syslogd. We will look at it on page
.
/etc/termcap/etc/termcapterminalcapabilitycapabilityterminal/etc/termcap
(terminal capabilities) describes terminal control sequences. By
default, programs use the value of the TERM environment variable to look
up the terminal capabilities in this database. See page
for more details.
/etc/ttys/etc/ttysinitdæmondæmoninit/etc/ttys
is a file which describes terminals and pseudo-terminals to init. We've
looked at it in a number of places: check the index.
/etc/ttys
Here's an excerpt from the default
/etc/ttys :
# This entry needed for asking password when init goes to single-user mode
# If you want to be asked for password, change "secure" to "insecure" here
console none unknown off secure
/dev/ttyv0
The system console. This is not a real terminal: it can be moved from one
device to another. By default, it corresponds to /dev/ttyv0 (the next
entry).
ttyv0 "/usr/libexec/getty Pc" cons25 on secure
This is the first virtual terminal, the one which you get automatically at boot
time. To change to the others, press Alt-Fx, where x
is between 1 and 16. This will give you one of the others:
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" cons25 on secure
ttyv2 "/usr/libexec/getty Pc" cons25 on secure
ttyv3 "/usr/libexec/getty Pc" cons25 off secure
The default kernel supports four virtual terminals. See page
for details of how to configure more. As we saw on page , you
need to keep one off if you want to run X.
# Serial terminals
ttyd0 "/usr/libexec/getty std.9600" unknown off secure
ttyd1 "/usr/libexec/getty std.9600" unknown off secure
ttyd2 "/usr/libexec/getty std.9600" unknown off secure
ttyd3 "/usr/libexec/getty std.9600" unknown off secure
These are the serial ports on your machine. It doesn't matter if it contains
names which correspond to non-existent hardware, such as /dev/ttyd3, as
long as you don't try to enable them.
# Pseudo terminals
ttyp0 none network
ttyp1 none network
There's a whole list of these. The purpose here is to tell network programs
the properties of the terminal: in particular, they're not secure, which
means that you're not allowed to log in on them as root.
/etc/periodic/The directory /etc/periodic contains three directories used by
cron at regular intervals: daily, weekly and
monthly. The directories contain a number of files for performing
specific tasks. For example, /etc/periodic/daily contains the following
files:
-rwxr-xr-x 1 grog example 321 Apr 6 18:25 100.clean-disks
-rwxr-xr-x 1 grog example 651 Apr 6 18:25 110.clean-tmps
-rwxr-xr-x 1 grog example 231 Apr 6 18:25 120.clean-preserve
-rwxr-xr-x 1 grog example 223 Aug 18 1997 130.clean-msgs
-rwxr-xr-x 1 grog example 217 Apr 6 18:25 140.clean-rwho
-rwxr-xr-x 1 grog example 1059 May 25 1998 200.backup-passwd
-rwxr-xr-x 1 grog example 499 Aug 17 1997 210.backup-aliases
-rwxr-xr-x 1 grog example 322 Aug 18 1997 220.backup-distfile
-rwxr-xr-x 1 grog example 458 Aug 18 1997 300.calendar
-rwxr-xr-x 1 grog example 410 Aug 18 1997 310.accounting
-rwxr-xr-x 1 grog example 186 Aug 18 1997 320.rdist
-rwxr-xr-x 1 grog example 253 Aug 17 1997 330.news
-rwxr-xr-x 1 grog example 321 Jan 2 07:37 340.uucp
-rwxr-xr-x 1 grog example 184 Aug 17 1997 400.status-disks
-rwxr-xr-x 1 grog example 182 Aug 18 1997 410.status-uucp
-rwxr-xr-x 1 grog example 179 Aug 18 1997 420.status-network
-rwxr-xr-x 1 grog example 284 Oct 6 1998 430.status-rwho
-rwxr-xr-x 1 grog example 425 Apr 18 1998 440.status-mailq
-rwxr-xr-x 1 grog example 261 Aug 18 1997 450.status-security
-rwxr-xr-x 1 grog example 432 Feb 9 1998 460.status-mail-rejects
-rwxr-xr-x 1 grog example 288 Aug 17 1997 999.local
The files are executed in the order of their names, so the names consist of two
parts: a number indicating the sequence, and a name indicating the function.
This method is new with FreeBSD version 3. In older versions of FreeBSD, these
functions were performed by files with the names /etc/daily,
/etc/weekly and /etc/monthly. See page for more details
of cron.
Network configuration files/etc/rc.network/etc/network/etc/rc.conf
This section describes the network configuration files in alphabetical order.
The main script for starting the network is
/etc/rc.network ,
which in earlier BSD versions, including FreeBSD, was called
/etc/network .
You normally don't change this file: it reads all the necessary definitions from
/etc/rc.conf ,
and that's the file you should change.
/etc/exports/etc/exports/etc/exports
is a list of file systems which should be NFS exported. We will look at it on
page . See also the man page exports(5).
/etc/rc.firewall/etc/rc.firewallipfwdæmondæmonipfw/etc/rc.firewall
is used to initialize the packet filtering firewall ipfw. See page
for further details.
/etc/ftpusers/etc/ftpusersftpcommandcommandftp/etc/ftpusers
is a list of users who are not allowed to connect to this system using
ftp.
/etc/host.conf/etc/host.conf/etc/hosts/etc/host.conf
describes the order in which to perform name resolution. We have three choices:
BIND,
/etc/hosts ,
and NIS. The file simply specifies which of these options should be used, and
in which order:
# $I\&d: host.conf,v 1.2 1993/11/07 01:02:57 wollman Exp $
# Default is to use the nameserver first
bind
# If that doesn't work, then try the /etc/hosts file
hosts
# If you have YP/NIS configured, uncomment the next line
# nis
/etc/hosts/etc/hosts
For a small network, especially if you're not permanently connected to the
Internet, you have the option of placing the addresses of the systems you want
to talk to in a file called
/etc/hosts .
This file is simply a list of IP addresses and host names, for example:
# Local network host addresses
#
# loopback address for all systems
127.1 loopback local localhost
###### domain example.com.
#
223.147.37.1 freebie freebie.example.org # FreeBSD 3.0
223.147.37.2 presto.example.org presto # 66 MHz 486 (BSD UNIX)
223.147.37.3 bumble bumble.example.org # 33 MHz 486 (UNIX SVR3.2)
223.147.37.4 wait wait.example.org # 33 MHz 486 (DOS)
223.147.37.129 solo solo.example.org lxn # LXN
223.147.37.132 dinosaur dinosaur.example.org # 25 MHz 386 running DOS
223.147.37.133 andante andante.example.org # Toshiba laptop - 16 MHz 386SX
223.147.37.135 onlyyou onlyyou.example.org # Consensys Destiny machine
223.147.37.136 zaphod zaphod.example.org # 2-headed X machine
Obviously, you need to set up this file yourself, and you need it on every
machine on the network. As you can see, a system can have more than one name:
just put as many names as you want behind the IP address. This method is hard
to maintain: a better alternative is the Domain Name Service, which we discuss
in Chapter .
/etc/hosts.equiv/etc/hosts.equiv/etc/hosts.equiv
is a list of hosts whose users may use rsh to access this system without
supplying a password. We'll look at it on page .
/etc/hosts.lpd/etc/hosts.lpdlpddæmondæmonlpd/etc/hosts.lpd
is a list of hosts which can use the lpd spooler on this system.
/etc/inetd.conf/etc/inetd.confinetddæmondæmoninetd/etc/inetd.conf
is the configuration file for inetd, the Internet dægmon. It dates back
to the original implementation of TCP/IP in 4.2BSD, and the format is the same
for all versions of UNIX. We have looked at various modifications to this file
throughout the network part of the book. See the index (inetd.conf) and
the man page inetd.conf(5) for further details.
/etc/namedb/named.confnameddæmondæmonnamed/etc/named/named.conf/etc/named/named.conf is the main configuration file for named, the
Domain Name Service dægmon. We will look at it in . Previous
versions of named used a different form of configuration file which was
stored in /etc/named.boot.
/etc/networks/etc/networks/etc/networks
is a list of networks in the Internet. Although this sounds
like a good idea, it is almost useless: if you connect to the Internet, you
should use a name server, which supplants this file.
/etc/protocols/etc/protocols/etc/protocols
is a list of known protocols which run on the IP layer. This file should be
seen and not changed.
/etc/rc.network/etc/rc.network/etc/rc.network
is the main script which starts up the network. You shouldn't need to change
this file.
/etc/services/etc/services/etc/services ,
a list of the IP services which this system supports. Like
/etc/protocols ,
you should not change this file.
Obsolete configuration files/etc/sysconfig/etc/sysconfig/etc/sysconfig
was a file which contained all the site-specific configuration definitions. Its
name has been changed to
/etc/rc.conf .
/etc/netstart/etc/netstart/etc/rc/etc/rc.network/etc/netstart
was a script called by
/etc/rc
to start up the network. Its name has now been changed to
/etc/rc.network .
FreeBSD still includes a file
/etc/netstart ,
but its only purpose is to start the network in single-user mode.
Shutting down the systemshutdowncommandcommandshutdown
FreeBSD uses a number of sophisticated techniques to achieve its high
performance. In particular, when you write data to a disk, the system doesn't
put it on the disk immediately: it waits for more data to arrive, which improves
performance dramatically, since it reduces the number of disk accesses by up to
several orders of magnitude.
fsckcommandcommandfsck
The result of turning power off before the data is written is equally dramatic.
You may just lose the data, but if the data is information on a change in file
system structure, your file system will be broken. To check for this, the
system runs a program called fsck (File System Check) at startup.
fsck can repair minor damage, but it's obviously a better idea to avoid
damage by ensuring that the system is shut down in an orderly way.
Never stop your machine by just turning off the power. The results could be
devastating.
The correct way to shut a system down is with the shutdown command. To
quote the man page shutdown(8):
hacker
guru
Shutdown provides an automated shutdown procedure for super-users to nicely
notify users when the system is shutting down, saving them from system
administrators, hackers, and gurus, who would otherwise not bother with such
niceties.This command has a number of useful options:
Use the -r option to reboot the computer. You sometimes need to do
this, for example after installing a new kernel.
Use the -h option to stop the machine. This is the normal case, but it
isn't the default.
Without an option, shutdown attempts to put the machine in single user
mode. This doesn't always work as well as booting in single user mode.
Shutdown takes a time parameter which tells it when to actually perform the
shutdown. This is useful in a multi-user environment, but normally you'll want
to shutdown now, so shutdown understands the keyword now.
In the normal case, where you want to stop the machine right now so you can turn
the power off, you would type:
# shutdown -h now
Feb 4 12:38:36 freebie shutdown: halt by grog:
Feb 4 12:38:39 freebie syslogd: exiting on signal 15
syncing disks... done
The operating system has halted.
Please press any key to reboot.
Be sure to wait for this message before you turn off the power.
RebootingTo reboot the machine, enter
# shutdown -r nowor
# reboot orCTRL-ALT-DEL
\" This file is in -*- nroff-fill -*- mode
File systemsfilesystem
One of the most far-reaching concepts of the UNIX operating system was its
file system, the way in which it stores data. Although most other
operating systems have copied it since then, including Microsoft's platforms,
none have come close to the elegance with which it is implemented. In this
chapter, we'll look at what that means to you.
File systemsfilesystemsdirectoriesfilesdirectories
Both UNIX and Microsoft environments store disk data in files, which in
turn are placed in directories. A file may be a directory: that is, it
may contain other files.
File namesfilenamesfilename extension
The differences between UNIX and Microsoft start with file names.
Traditional Microsoft file names are rigid: a file name consists of eight
characters, possibly followed by a period and another three characters (the
so-called file name extension). There are significant restrictions on
which characters may be used to form a file name, and upper and lower case
letters have the same meaning (internally, Microsoft converts the names to UPPER
CASE). Directory members are selected with a backslash (\e), which
conflicts with other meanings in the C programming language—see page
for more details.
By comparison, UNIX file names are much more flexible. They may contain any
character except a slash (/), which is used to indicate a directory
component, and they may be up to 255 characters long.
In some older versions of UNIX and early versions of Linux, file names were
restricted to 14 characters.
Upper and lower case letters have different meanings, so in UNIX the names
foo, FOO, and Foo are three different names.
Permissionsfilepermissionspermissionsfile
Since a UNIX system may potentially be used by many people, it includes a method
of protecting data from access by unauthorized persons. Every file has three
items of information associated with it which describes who can access it in
what manner:
fileowner
The file owner, the user ID of the person who owns the file.
filegroup
The file group, the group ID of the group which ``owns'' the file.
A list of what the owner, the group and other people can do with the file. The
possible actions are reading, writing or executing.
For example, you might have a program which accesses private data, and you want
to be sure that only you may execute it. You do this by setting the permissions
so that only the owner may execute it. Or you might have a text document in
development, and you want to be sure that you are the only person who can change
it. On the other hand, the people who work with you have a need to be able to
refer to the document. You set the permissions so that only the owner may write
it, that the owner and group may read it, and, since it's not ready for
publication yet, you don't allow anybody else to access it.
Traditionally, the permissions are represented by three groups of rwx:
r stands for read permission, w stands for write
permission, and x stands for execute permission. The three
groups represent the permissions for the owner, the group and others
respectively. If the permission is not granted, it is represented by a hyphen
(-).
Thus, the permissions for the program I discussed above would be
r-x------ (I can read and execute the program, and nobody else can do
anything with it). The permissions for the draft document would be
rw-r----- (I can read and write, the group can read, and others can't
access it).
~/.rhosts
Typical FreeBSD file access permissions are rwxr-xr-x for programs and
rw-r--r-- for other system files. In some cases, however, you'll find
that other permissions are required. For example, the file
~/.rhosts, which is used by some network programs for user validation, may
contain the user's password in legible form. To help ensure that other people
don't read it, the network programs will refuse to read it unless its
permissions are rw-------. The vast majority of system problems in UNIX
can be traced to incorrect permissions, so you should pay particular attention
to them.
permissionsetuidpermissionsetgidsetuidsetuser IDsetgidsetgroup
Apart from these access permissions, executables can also have two bits set to
specify the access permissions of the process when it is run. If the
setuid (set user ID) bit is set, the process will always run as
if it had been started by its owner. If the setgid (set group
ID) bit is set, it will run as if it had been started by its group. This is
frequently used to start system programs which need to access resources which
the user may not access directly. We'll see an example of this with the
ps command on page . ls represents the
setuid bit by setting the third letter of the permissions string to
s instead of x; similarly, it represents the setgid bit
by setting the sixth letter of the permissions string to s instead of
x.
In addition to this access information, the permissions contain a character
which describes what kind of file it represents. The first letter may be a
- (hyphen), which designates a regular file, the letter d for
directory, or the letters b or c for a device node. We'll look
at device nodes in , page
There are also a number of other letters which are less used. See the man page
ls(1) for a full list.
lscommandcommandls
To list files and show the permissions, use the ls command with the
-l option:
$ ls -l
total 2429
-rw-rw-r-- 1 grog wheel 28204 Jan 4 14:17 %backup%~
drwxrwxr-x 3 grog wheel 512 Oct 11 15:26 2.1.0-951005-SNAP
drwx------ 4 grog wheel 512 Nov 25 17:23 Mail
-rw-rw-r-- 1 grog wheel 149 Dec 4 14:18 Makefile
-rw-rw-r-- 1 grog wheel 108 Dec 4 12:36 Makefile.bak
-rw-rw-r-- 1 grog wheel 108 Dec 4 12:36 Makefile~
-rw-rw-r-- 1 grog wheel 0 Dec 4 12:36 depend
-rw-rw-r-- 1 root wheel 1474560 Dec 14 17:03 deppert.floppy
-rwxr-xr-x 1 grog wheel 100 Dec 19 15:24 doio
-rwxrwxr-x 1 grog wheel 204 Dec 19 15:25 doiovm
-rwxrwxr-x 1 grog wheel 204 Dec 19 15:16 doiovm~
-rwxr-xr-x 1 grog wheel 115 Dec 26 08:42 dovm
-rwxr-xr-x 1 grog wheel 114 Dec 19 15:30 dovm~
drwxr-xr-x 2 grog wheel 512 Oct 16 1994 emacs
drwxrwxrwx 2 grog wheel 512 Jan 3 14:07 letters
This format shows the following information:
First, the permissions, which we've already looked at.
linkcount
Then, the link count. This is the number of hard links to the file.
For a regular file, this is normally 1, but directories have at least 2. We'll
look at links on page .
imagefloppyfloppyimagedeppert
LinckeRoland
Next come the names of the owner and the group, and the size of the file in
bytes. You'll notice that the file deppert.floppy belongs to
root. This was probably an accident, and it could lead to problems.
Incidentally, looking at the name of the file and its size, it's fairly obvious
that this is an image of a 3\(12" floppy, that is to say, a
literal copy of the complete floppy.
The date is normally the date that the file was last modified. With the
-u option to ls, you can list the last time the file was
accessed.
Finally comes the name of the file. As you can see from this example, the names
can be quite varied.
A couple of the permissions are of interest. The directories all have the
x (execute) permission bit set. This is necessary in order to be able
to access the files in the directory—that's the way the term execute
is defined for a directory. If I reset the execute permission, I can still list
the names of the files, but I can't access them.
I am the only person who can access the directory Mail. This is the
normal permission for a mail directory.
Changing file permissions and ownersOften enough, you may want to change file permissions or owners. UNIX supplies
three programs to do this:
chowncommandcommandchowndeppert.floppy
To change the file owner, use chown. For example, to change the ownership
of the file deppert.floppy, which in the list above belongs to
root, root would enter:
# chown grog deppert.floppyNote that this operation must be performed by root.
chgrpcommandcommandchgrp
To change the file group, use chgrp, which works in the same way as
chown. To change the group ownership to lemis, you would enter:
# chgrp lemis deppert.floppychown can also change both the owner and the group. Instead of the two
previous examples, you could enter:
# chown grog.lemis deppert.floppyThis would change the owner to grog, as before, and also change the
group to lemis.
chmodcommandcommandchmod
To change the permissions, use the chmod program. chmod has a
number of different formats, but unfortunately the 9-character representation
isn't one of them. Read the man page chmod(1) for the full story, but
you can achieve just about anything you want with one of the formats shown in
table
chmod permission codes
box, center,tab(#) ;
lfCWp9 | lw63 .
\s10Specification#Effect
=
go-w Deny write permission to group and others
=rw,+X Set the read and write permissions to the usual defaults, but retain any execute permissions that are currently set
+X Make a directory or file searchable/executable by everyone if it is already searchable/executable by anyone
u=rwx,go=rx Make a file readable/executable by everyone and writable by the owner only
go= Clear all mode bits for group and others
g=u-w Set the group bits equal to the user bits, but clear the group write bit
Permissions for new filesumaskUsermask
None of this tells us what the permissions for new files are going to be. The
wrong choice could be disastrous. For example, if files were automatically
created with the permissions rwxrwxrwx, anybody could access them in any
way. On the other hand, creating them with r-------- could result in a
lot of work setting them to what you really want them to be. UNIX solves this
problem with a thing called umask (User mask). This is a
default non-permission: it specifies which permission bits not to allow.
As if this weren't confusing enough, it's specified in the octal number system,
in which the valid digits are 0 to 7. Each octal digit
represents 3 bits. By contrast, the more common hexadecimal system uses 16
digits, 0 to 9 and a to f. The original
versions of UNIX ran on machines which used the octal number system, and since
the permissions come in threes, it made sense to leave the umask value
in octal.
An example: by default, you want to create files which anybody can read, but
only you can write. You set the mask to 022. This corresponds to the
binary bit pattern 000010010.
The leading 0 is needed to specify that the number is in octal, not to
make up three digits. If you want to set the permissions so that by default
nobody can read, you'd set it to 0222. Some shells automatically assume
that the number is octal, so you may be able to omit the 0, but
it's not good practice.
The permissions are allowed where the corresponding bit is 0:
rwxrwxrwx Possible permissions
000010010 umask
rwxr-xr-x resultant permissionsBy default, files are created without the x bits, whereas directories
are created with the allowed x bits, so with this umask, a file
would be created with the permissions rw-r--r--.
umask is a shell command. To set it, just enter:
$ umask 022It's preferable to set this in your shell initialization file—see page
for further details.
Beware of creating a too restrictive umask. For example, you will get into a
lot of trouble with a umask like 377, which creates files which you can
only read, and which nobody else can access. If you disallow the x
(executable) bit, you will not be able to access directories you create, and you
won't be able to run programs you compile.
Making a program executable
File permissions enable one problem that occurs so often that it's worth drawing
attention to it. Many operating systems require that an executable program have
a special naming convention, such as COMMAND.COM or FOO.BAT, which
in MS-DOS denotes a specific kind of binary executable and a script file,
respectively. In UNIX, you don't need a special suffix in order to be able to
execute a program, but it must have the x bit set. Sometimes this bit
gets reset (turned off), for example if you copy it across the net with
ftp. The result looks like this:
$ ps
bash: ps: Permission denied
$ ls -l /bin/ps
-r--r--r-- 1 bin kmem 163840 May 6 06:02 /bin/ps
$ suyou need to be super user to set ps permission
Password: password doesn't echo
# chmod +x /bin/psmake it executable
# psnow it works
PID TT STAT TIME COMMAND
226 p2 S 0:00.56 su (bash)
239 p2 R+ 0:00.02 ps
146 v1 Is+ 0:00.06 /usr/libexec/getty Pc ttyv1
147 v2 Is+ 0:00.05 /usr/libexec/getty Pc ttyv2
# ^Dexit su
$ ps
ps: /dev/mem: Permission denied hey! it's stopped workingHuh? It only worked under su, and stopped working when I became a mere
mortal again? What's going on here?
pscommandcommandps/dev/memsetuid
There's a second problem with privileged programs like ps: they need to
be able to access special files, in this case /dev/mem, a special file
which addresses the system memory. In order to do this, we need to set the
setuid bit, s. To do this, we become superuser again:
$ suyou need to be super user to set ps permission
Password: password doesn't echo
# chmod g+s /bin/psset the setgid bit
# ls -l /bin/pssee what it looks like
-r-xr-sr-x 1 bin kmem 163840 May 6 06:02 /bin/ps
# ^Dexit su
$ psnow it still works
PID TT STAT TIME COMMAND
226 p2 S 0:00.56 su (bash)
239 p2 R+ 0:00.02 ps
146 v1 Is+ 0:00.06 /usr/libexec/getty Pc ttyv1
147 v2 Is+ 0:00.05 /usr/libexec/getty Pc ttyv2
In this example, the permissions in the final result really are the correct
permissions for ps. It's impossible to go through the permissions for
every standard program. If you suspect that you have the permissions set
incorrectly, use the permissions of the files on the Live Filesystem CD-ROM as a
guideline.
Linkshardlinklinkhardhardlinklinkhard
Files may have more than one name. There are two methods: one, called a
link, or sometimes hard link, really gives the same file two
different names. There is a requirement that files be on the same file system
as the directory, so this method restricts the names to the same file system.
symboliclinksoftlinklinksymboliclinksoft
Alternatively, symbolic links, sometimes called soft links, are
not restricted to the same file system (not even to the same system!), and they
refer to another file name, not to the file itself. The difference is most
evident if you delete a file: if the file has been hard linked, the other names
still exist and you can access the file by them. If you delete a file name
which has a symbolic link pointing to it, the file will go away and the symbolic
link will not be able to find it any more.
It's not easy to decide which kind of link to use—see UNIX Power Tools
for more details.
Directory structure
Although Microsoft platforms have a hierarchical directory structure, there is
little standardization of the directory names: it's difficult to know where a
particular program or data file might be. UNIX systems have a standard
directory hierarchy, though every vendor loves to change it just a little bit to
ensure that they're not absolutely compatible. In the course of its evolution,
UNIX has changed its directory structure several times. Still, it's much better
than the almost complete lack of standardization in the Microsoft world. The
most recent, and probably most far-reaching changes, occurred with System V.4
and 4.4BSD, both of which made almost identical changes.
rootfile systemfilesystemfsckcommandcommandfsckfsdbcommandcommandfsdb/usrdirectory/usr/directory/
Nearly every version of UNIX prefers to have at least two file systems,
/ (the root file system) and /usr, even if they only have
a single disk. This arrangement is more reliable than a single file system:
it's possible for a file system to crash so badly that it can't be mounted any
more, and you need to read in a tape backup, or use programs like fsck
or fsdb to piece them together. If you have only one file system, you
may need to completely reinstall the system under these circumstances. If,
however, you have a small root file system with only enough on it to get the
machine running in single user mode, you can subsequently recover the
/usr file system relatively easily. If you also almost never write to
your root file system, the chances of damaging it are remote.
For these reasons, BSD systems like to have as small a root file system as
possible. They store much of the data that System V stores in its root file
system in /usr. You should never need a root file system with more than
40 MB, and I get by quite happily with 30 MB.
/tmpdirectory/tmp
One problem with this method is the /tmp file system, which is normally
located on the root file system. As its name implies, it is used to store
temporary files. This creates two problems for this method:
If you create temporary files, you want to write to them, and we don't want to
write to the root file system if we can avoid it.
The files may become large and fill up the file system.
/tmpdirectory/tmp/usr/tmpdirectory/usr/tmp/usrdirectory/usr
The standard solution for these problems is to relocate the /tmp file
system to a different directory, say /usr/tmp, and create a symbolic link
from /usr/tmp to /tmp—see page for more
details. Table gives an overview of the standard FreeBSD
directories.
FreeBSD directory hierarchy
box,tab(#) ;
| lfI | lw62 | .
Directory
Name#Usage
=
/directory/ / Root file system. Contains the kernel, the bootstrap, and mount points for other file systems. It should not contain anything else.
/bindirectory/bin /bin Executable programs of general use which are needed at system startup time. The name was originally an abbreviation for binary, but many of the files in here are shell scripts.
/cdromdirectory/cdrom /cdrom A mount point for CD-ROM drives
/compat
directory/compat /compat A directory containing code for emulated systems, such as Linux.
/devdirectory/dev /dev Directory of device nodes. The name is an abbreviation for devices. We'll look at the contents of this directory in more detail on page
/etcdirectory/etc/sbindirectory/sbin/etcdirectory/etc /etc Files used at system startup. Unlike System V, /etc does not contain kernel build files, which are not needed at system startup. Unlike earlier UNIX versions, it also does not contain executables—they have been moved to /sbin.
/procdirectory/procprocessdirectorydirectoryprocess/stand/sysinstall/libdirectory/lib/vardirectory/var/mntdirectory/mnt /mnt A mount point for floppies and other temporary file systems
kernelloadable module/modulesdirectory/modules /modules Directory containing kernel loadable modules, parts of the kernel which can be started at run time.
/procdirectory/proc /procprocessfile systemfilesystem The process file system. This directory contains pseudo-files which refer to the virtual memory of currently active processes.
/rootdirectory/root /root The home directory of the user root. In traditional UNIX file systems, root's home directory was /, but this is messy.
/sbindirectory/sbin/sbin System executables needed at system startup time. These are typically system administration files that used to be stored in /etc.
/standdirectory/stand /stand Directory with standalone programs. In fact, most of the programs are the same file, /stand/sysinstall, which we discussed in great detail in .
/usrdirectory/usr /usr The ``second file system''. See the discussion above.
/usr/X11R6directory/usr/X11R6 /usr/X11R6 The X11 windowing system
/usr/X11R6/bindirectory/usr/X11R6/bin /usr/X11R6/bin Executable X11 programs
/usr/X11R6/includedirectory/usr/X11R6/include /usr/X11R6/include Header files for X11 programming
/usr/X11R6/libdirectory/usr/X11R6/lib /usr/X11R6/lib Library files for X11
/usr/X11R6/mandirectory/usr/X11R6/man /usr/X11R6/man Man pages for X11
/usr/bindirectory/usr/bin /usr/bin Standard executable programs that are not needed at system start. Most programs you use will be stored here.
/usr/gamesdirectory/usr/games /usr/games Games
/usr/includedirectory/usr/include /usr/include Header files for programmers
/usr/libdirectory/usr/lib/libdirectory/lib /usr/lib Library files for programmers. FreeBSD does not have a directory /lib.
/usr/libexecdirectory/usr/libexec /usr/libexec Executable files which are not started directly by the user, for example the phases of the C compiler (which are started by /usr/bin/gcc) or the
/usr/bin/gccgetty program, which is started by init.
/usr/localdirectory/usr/local /usr/local Additional programs which are not part of the operating system. It parallels the /usr directory in having subdirectories bin, include, lib, man, sbin, and share. This is where you can put programs which you get from other sources.
/usr/sbindirectory/usr/sbin /usr/sbin System administration programs which are not needed at system startup.
/usr/sharedirectory/usr/share /usr/share Miscellaneous read-only files, mainly informative. Subdirectories include doc, the FreeBSD documentation, games, info, the GNU info documentation, locale, internationization information, and man, the man pages.
/vardirectory/var /var A file system for data which changes frequently, such as mail, news, and log files. If /var is not a separate file system, you should create a directory on another file system and symlink /var to it—see page ).
/var/logdirectory/var/log /var/log Directory with system log files
/var/maildirectory/var/mail /var/mail Incoming mail for users on this system
/var/spooldirectory/var/spool/var/spool/lpd/var/spool/mqueue/var/spool/uucp/var/spool/ftp /var/spool Spool data, such as data waiting to be printed (/var/spool/lpd), /var/spool/mqueue (outgoing mail), UUCP data (/var/spool/uucp), and /var/spool/ftp (anonymous FTP).
/var/tmpdirectory/var/tmp /var/tmp Temporary files. See the discussion above.
FreeBSD devicesmajornumberminornumberblockdevicecharacterdevice
Like all traditional UNIX systems, FreeBSD refers to devices by a major
number and a minor number. The major number is in fact an index into a
list of drivers, and the minor number is a number which the driver uses to
distinguish the individual device and how it should treat it. FreeBSD also
distinguishes between block devices, on which you can store a file system,
and character devices, which do not. Block devices have a corresponding
raw device which is used for some purposes, such as file system consistency
checks. You can see this information in an ls -l listing:
$ ls -l /dev/rfd0 /dev/rft0 /dev/ft0 /dev/fd0
brw-r----- 9 root operator 2, 0 Nov 12 13:32 /dev/fd0
brw-r----- 2 root operator 2, 32 Nov 12 13:33 /dev/ft0
crw-r----- 9 root operator 9, 0 Nov 12 13:32 /dev/rfd0
crw-r----- 2 root operator 9, 32 Oct 31 19:59 /dev/rft0
fd0devicedevicefd0
The letter at the beginning of the permissions shows that /dev/fd0 and
/dev/ft0 are block devices, and /dev/rfd0 and /dev/rft0
are character devices. The major number of the character devices is 9,
and the major number of the block devices is 2. In each case, they are
separated from the minor number by a comma.
floppytape
If you find a strange device which isn't listed here, you might get an idea from
the company it keeps: here, for example, we know that /dev/fd0 is a
floppy disk, and since the same driver also handles /dev/ft0, it's
reasonable to assume that it has something to do with a floppy disk. In fact,
/dev/ft0 is the floppy tape driver, which handles tape drives
connected to the floppy disk controller.
Long minor numbersTraditionally, major and minor numbers are stored in the same machine word.
Originally, the word was 16 bits long, and the major and minor numbers were each
8 bit quantities, which limited their maximum values to 255. Then System V.4
increased the word size to 32 bits, and gave 14 bits to the major numbers and 18
bits to the minor numbers, giving maximum values of 16383 and 262143
respectively. 4.4BSD also introduced 32 bit device numbers, but left the major
number in the same place, and left it 8 bits long. The minor number takes up
the rest of the word, and is thus 24 bits long with a hole in the middle.
Here's a overview:
h = .2i
dh = .02i
dw = .8i
move.25i
[
Caps: [
boxht = h; boxwid = dw
box invis "Byte"
A: box invis "\s100\s0"
B: box invis "\s101\s0"
C: box invis "\s102\s0"
D: box invis "\s103\s0"
]
Trad: [
boxht = h; boxwid = dw
box invis "traditional"
box invis
box invis
A: box "major"
B: box "minor"
] at Caps.s - (0, h)
SVR4: [
boxht = h; boxwid = dw
boxht = h;
box invis "System V.4"
box wid dw * 1.75 "major (14 bits)"
box wid dw * 2.25 "minor (18 bits)"
] at Trad.s - (0, h)
BSD44: [
boxht = h; boxwid = dw
box invis "FreeBSD"
box wid dw * 2 "more minor"
box "major"
box "minor"
] at SVR4.s - (0, h)
]
Major and minor numbers
FreeBSD uses the high-order minor for very special devices, such as control
ports for disks. Normally, you'll never see them, but if you do find a
minor number in the millions, it's not a bug, it's a feature.
Creating new device nodesmknodcommandcommandmknod/dev/MAKEDEVMAKEDEVscriptscriptMAKEDEVifconfigcommandcommandifconfig
Just because the system supports a device doesn't mean that it automatically has
a name. The name is an entry in the /dev directory, and needs to be
added manually. If you boot a different kernel, you may have a mismatch between
your /dev directory and your kernel—either you have names for devices
which aren't included in the kernel, or you don't have names for devices which
are included in the kernel. In addition, some devices don't have device nodes,
for example Ethernet interfaces: they are treated differently by the
ifconfig program.
mknodcommandcommandmknod
As a result, you may have to create device nodes in order to access the devices.
For example, the system supports any combination of SCSI devices on a
controller, up to seven of them, but by default only one tape and four disks are
configured. If you add a second tape drive or a fifth SCSI disk, you will need
to add device nodes to be able to talk to them. You can do this the hard way or
the easy way. The hard way uses the mknod command (see the man page
mknod(8)).
/dev/MAKEDEV
The easy way uses the script /dev/MAKEDEV. For example, by default
FreeBSD only supplies definitions for four SCSI disks. If you add a
fifth SCSI disk, enter:
# cd /dev
# ./MAKEDEV da4 create the device
# ./MAKEDEV da4s0a create the slice entries tooMAKEDEV assumes that you are in the /dev directory, as indicated
in this example.
The names that MAKEDEV chooses aren't the most intuitive. You may have
difficulty deciding how to tell it to build the devices you want. Here's an
overview:
Parameters for MAKEDEV
box,center,tab(#) ;
lfCWp9 | lw67 .
\s10Parameter#Function
_
all Make all known devices, with a standard number of units. Beware of this option: it first removes any device nodes in /dev. std Makes ``standard'' devices local Configuration specific devices mach-4 Devices for Mach's XFree86 distribution. See http://www.cs.hut.fi/lites.html for more info on LITES.
wt* QIC-02 interfaced cartridge tape. Don't use this for SCSI tape. sa* SCSI tape drives. ft* QIC-40/QIC-80 cartridge tapes interfaced via the floppy disk controller.
wd* ST506, IDE, ESDI, RLL and similar disk drives. fd* Floppy disk drives, both 3\(12" and 5\(14" da* SCSI disks cd* SCSI CD-ROM drives mcd* Mitsumi CD-ROM drives scd* Sony CD-ROM drives matcd* Matsushita and Panasonic CD-ROM drives wcd* IDE (ATAPI) CD-ROM drives vn* ``vnode'' virtual disks. od* Optical disks
vty* Virtual console devices for syscons and pcvt mse* Logitech and ATI Inport bus mouse psm* PS/2 mouse sysmouse Mousesystems mouse emulator for syscons refclock-* Serial ports used by xntpd parse refclocks.
tty* General purpose serial ports cua* Dialout serial ports ttyA* Specialix SI/XIO dialin ports cuaA* Specialix SI/XIO dialout ports ttyD* Digiboard - 16 dialin ports cuaD* Digiboard - 16 dialout ports pty* Set of 32 master and slave pseudo terminals vty* Virtual terminals using syscons and pcvt console drivers.
lpt* Standard parallel printer.
uk* ``unknown'' SCSI device (supports ioctl calls only). worm* WORM driver. pt* SCSI processor type (scanners, for example) PC-CARD PC-CARD (previously called PCMCIA) support card* PC-CARD slots
apm Advanced Power Management BIOS bpf* Berkeley packet filter speaker PC speaker tw* xten power controller snd* various sound cards pcaudio PCM audio driver socksys iBCS2 socket system driver vat VAT compatibility audio driver (requires snd*) gsc Genius GS-4500 hand scanner joy PC joystick tun* Tunneling IP device snp* tty snoop devices spigot Video Spigot video acquisition card ctx* Cortex-I video acquisition card meteor* Matrox Meteor video acquisition card (PCI) bktr* Bt848 based video acquisition card (PCI) qcam* Connectix QuickCam\(tm parallel port camera isdn* ISDN devices labpc* National Instrument's Lab-PC and LAB-PC+ perfmon CPU performance-monitoring counters pci PCI configuration-space access from user mode
The asterisk (*) after some names indicates that you should specify the
number of devices to create. Be careful here: the number of devices is not the
number of the last device. If you specify, say, tty8, MAKEDEV
will create the devices /dev/tty0 to /dev/tty7: it will not
create a /dev/tty8.
Also be careful of ./MAKEDEV all: it first removes existing entries. If
this happens to you, you can remake them again with a more specific application,
such as in the example above.
File system types
FreeBSD supports a number of file system types. The most important are:
ufsUNIXFile Systemufs is the UNIX File System. All native disk files are of this
type.
cd9660file systemRockRidge Extensionscd9660 is the ISO 9660 CD-ROM format with the so-called Rock Ridge
Extensions which enable UNIX-like file names to be used. Use this file
system type for all CD-ROMs, even if they don't have the Rock Ridge Extensions.
nfsNetworkFile Systemnfs is the Network File System, a means of sharing file systems
across a network. We'll look at it in .
msdosfile systemfilesystemmount_msdoscommandcommandmount_msdos
You can access Microsoft files with the msdos and ntfs file
systems. See the man page mount_msdos(8) and page mount_ntfs(8)
for further details.
Mounting file systemsmountcommandcommandmount/cdromfilesystem/cd0filesystemfilesystemrootfile systemmountingCD-ROMmounting
Microsoft platforms identify partitions by letters which are assigned at boot
time. There is no obvious relation between the partitions, and you have little
control over the way the system assigns them. By contrast, all UNIX partitions
have a specific relation to the root file system, which is called simply
/. This flexibility has one problem: you have the choice of where in the
overall file system structure you put your individual file systems. You specify
the location with the mount command. For example, you would typically
mount a CD-ROM in the directory /cdrom, but if you have three CD-ROM
drives attached to your SCSI controller, you might prefer to mount them in the
directories /cd0, /cd1, and /cd2.
This numbering is in keeping with the UNIX tradition of numbering starting from
0. There's nothing to stop you choosing some other name, of course.
In order to mount a file system, you need to specify the device to be mounted,
where it is to be mounted, and the type of file system (unless it is ufs). The
mount point, (the directory where it is to be mounted) must already exist.
To mount your second CD-ROM on /cd1, you would enter:
# mkdir /cd1 only if it doesn't exist
# mount -t cd9660 -o ro /dev/cd1a /cd1/etc/rc/etc/fstab
When the system boots, it calls the startup script /etc/rc, which amongst
other things automatically mounts the file systems. All you need to do is to
supply the information: what is to be mounted, and where? This is in the file
/etc/fstab. If you come from a System V environment, you'll notice
significant difference in format—see the man page fstab(5) for the
full story. A typical /etc/fstab might look like:
/dev/wd0a / ufs rw 1 1 root file system
/dev/wd0s1b none swap sw 0 0 swap
/dev/wd0s1e /usr ufs rw 2 2 /usr file system
/dev/sd1e /src ufs rw 2 2 additional file system
proc /proc procfs rw 0 0 proc pseudo-file system
/dev/cd0a /cdrom cd9660 ro 0 0 CD-ROM
presto:/ /presto/root nfs rw 0 0 NFS file systems on other systems
presto:/usr /presto/usr nfs rw 0 0
presto:/home /presto/home nfs rw 0 0
presto:/S /S nfs rw 0 0
radio:/C /C nfs rw 0 0
The format of the file is reasonably intelligible:
The first column gives the name of the device (if it's a real file system), or
the name of the remote file system for NFS mounts.
The second column specifies the mount point.
The third column specifies the type of file system. Local file systems on hard
disk are always ufs, and file systems on CD-ROM are cd9660. Remote
file systems are always nfs. Specify swap partitions with swap,
and the proc file system with proc.
The fourth column contains rw for file systems which can be read or
written, ro for file systems (like CD-ROM) which can only be written,
and sw for swap partitions.
The fifth and sixth columns are used by the dump and fsck
programs. You won't normally need to change them. Enter 1 for a root
file system, 2 for other ufs file systems, and 0 for everything else.
Unmounting file systemsWhen you mount a file system, the system assumes it is going to stay there, and
in the interests of efficiency it delays writing data back to the file system.
This is the same effect we discussed on page . As a result, if you
want to stop using a file system, you need to tell the system about it. You do
this with the umount command. Note the spelling—there's no n
in the command name.
You need to do this even with read-only media such as CD-ROMs: the system
assumes it can access the data from a mounted file system, and it gets quite
unhappy if it can't. Where possible, it locks removable media so that you can't
remove them from the device until you unmount them.
Using umount is straightforward: just tell it what to unmount, either
the device name or the directory name. For example, to unmount the CD-ROM we
mounted in the example above, you could enter one of these commands:
# umount /dev/cd1a
# umount /cd1Before unmounting a file system, umount checks that nobody is using it.
If somebody is using it, it will refuse to unmount it with a message like
umount: /cd1: Device busy. This message often occurs because you have
changed your directory to a directory on the file system you want to remove.
For example (which also shows the usefulness of having directory names in the
prompt):
=== root@freebie (/dev/ttyp2) /cd1 16 -> umount /cd1
umount: /cd1: Device busy
=== root@freebie (/dev/ttyp2) /cd1 17 -> cd
=== root@freebie (/dev/ttyp2) ~ 18 -> umount /cd1
=== root@freebie (/dev/ttyp2) ~ 19 ->
Overview of FreeBSD devices
Every UNIX system has its own peculiarities when it comes to device names and
usage. Even if you're used to UNIX, you'll find the following table useful.
devicesoverview
FreeBSD device names
box,tab(#) ;
| lfCWp9 | lw68 | .
\s10Device#Description
=
fd/0devicedevicefd/0fd0adevicedevicefd0afd0cdevicedevicefd0cbpf0devicedevicebpf0 bpf0 Berkeley packet filter—see the description of bpfilter on page cd0adevicedevicecd0a cd0a First SCSI CD-ROM drive
ch0devicedevicech0 ch0 SCSI CD-ROM changer (juke box)
consoledevicedeviceconsole console System console, the device which receives console messages. Initially it is /dev/ttyv0, but it can be changed
cuaa0devicedevicecuaa0 cuaa0 First serial port in callout mode
cuaia0devicedevicecuaia0 cuaia0 First serial port in callout mode, initial state. Note the letter i for initial.
cuala0devicedevicecuala0 cuala0 First serial port in callout mode, lock state. Note the letter l for lock.
da0devicedeviceda0 da0 First SCSI disk drive, block device. See , page , for a complete list of disk drive names.
drumdevicedevicedrum drum System paging device (i.e. swap partition). The name reminds of the days when the system really did page to a magnetic drum.
ersa0devicedeviceersa0 ersa0 First SCSI tape drive, eject on close mode
fddevicedevicefd fd File descriptor pseudo-devices: a directory containing pseudo-devices which, when opened, return a duplicate of the file descriptor with the same number. For example, if you open /dev/fd/0, you will get another handle on your stdin stream (file descriptor 0).
fd0devicedevicefd0 fd0 The first floppy disk drive, accessed as a file system
fd0.1200devicedevicefd0.1200 fd0.1200 The first floppy disk drive, accessed as a 5\(14" drive file system (1200 kB)
fd0.1440devicedevicefd0.1440 fd0.1440 The first floppy disk drive, accessed as a 3\(12" drive file system (1440 kB)
fd0adevicedevicefd0a fd0a The first floppy disk drive, accessed as a file system. Floppy disks are not partitioned in the same way as hard disks, and the names fd0a, fd0b, fd0c, fd0d, fd0e, fd0f, fd0g, and fd0h all refer to the same device.
ft0devicedeviceft0 ft0 ``Floppy tape'': A device for QIC-40 and QIC-80 tape devices. These devices are not fully supported as tape drives—see the man page on the system for more details.
kmemdevicedevicekmem kmem Kernel virtual memory pseudo-device
bitbucketlpctl0devicedevicelpctl0 lpctl0 Control port of first parallel printer
lpt0devicedevicelpt0 lpt0 First parallel printer
matcd0adevicedevicematcd0a matcd0a Matsushita CD-ROM
matcd0ladevicedevicematcd0la matcd0la Matsushita CD-ROM with tray locking: the CD-ROM cannot be removed from the drive until it is unmounted
mcd0adevicedevicemcd0a mcd0a Mitsumi CD-ROM
memdevicedevicemem mem Physical virtual memory pseudo-device
mse0 Bus mouse
nrsa0devicedevicenrsa0 nrsa0 First SCSI tape drive, no-rewind mode
nrwt0devicedevicenrwt0 nrwt0 First QIC-36 tape drive, no-rewind mode
nulldevicedevicenull null The ``bit bucket''. Write data to this device if you never want to see it again.
ptyp0devicedeviceptyp0 ptyp0 First master pseudo-terminal. Master pseudo-terminals are named ptyp0 through ptypv, ptyq0 through ptyqv, ptyr0 through ptyrv, ptys0 through ptysv, ptyP0 through ptyPv, ptyQ0 through ptyQv, ptyR0 through ptyRv and ptyS0 through ptySv.
rcd0adevicedevicercd0a rcd0a First SCSI CD-ROM drive, raw access
rch0.ctldevicedevicerch0.ctl rch0.ctl SCSI CD-ROM changer (juke box)
rda0devicedevicerda0 rda0 First SCSI disk drive, raw mode. See , page , for a complete list of disk drive names.
rfd0devicedevicerfd0 rfd0 The first floppy disk drive, raw mode
rft0devicedevicerft0 rft0 ``Floppy tape'', raw mode
rmatcd0adevicedevicermatcd0a rmatcd0a Matsushita CD-ROM, raw mode
rmatcd0ladevicedevicermatcd0la rmatcd0la Matsushita CD-ROM with tray locking, raw mode
rmcd0cdevicedevicermcd0c rmcd0c Mitsumi CD-ROM, raw mode for playing audio
rsa0devicedevicersa0 rsa0 First SCSI tape drive, rewind on close mode
rscd0cdevicedevicerscd0c rscd0c Sony CD-ROM with proprietary interface, raw mode for playing audio
rwd0devicedevicerwd0 rwd0 First IDE or similar disk drive, raw mode. See , page , for a complete list of disk drive names.
rwt0devicedevicerwt0 rwt0 First QIC-36 tape drive, rewind mode
scd0adevicedevicescd0a scd0a Sony CD-ROM with proprietary interface
speakerdevicedevicespeaker speaker PC speaker device
ttydevicedevicetty tty Current controlling terminal
ttyd0devicedevicettyd0 ttyd0 First serial port in callin mode
ttyid0devicedevicettyid0 ttyid0 First serial port in callin mode, initial state
ttyld0devicedevicettyld0 ttyld0 First serial port in callin mode, lock state
ttyp0devicedevicettyp0 ttyp0 First slave pseudo-terminal. Slave pseudo-terminals are named ttyp0 through ttypv, ttyq0 through ttyqv, ttyr0 through ttyrv, ttys0 through ttysv, ttyP0 through ttyPv, ttyQ0 through ttyQv, ttyR0 through ttyRv and ttyS0 through ttySv. Some processes, such as xterm, only look at ttyp0 through ttysv.
ttyv0devicedevicettyv0/etc/ttys ttyv0 First virtual tty. This is the display with which the system starts. Up to 10 virtual ttys can be activated by adding the appropriate getty information in the file /etc/ttys. See , page , for further details.
tw0devicedevicetw0 tw0 TW-523 power line interface driver
ttyv0devicedevicettyv0 ttyv0 Console virtual terminals
wd0devicedevicewd0 wd0 First IDE or similar disk drive, block device. See , page , for a complete list of disk drive names.
zerodevicedevicezero zero Dummy device which always returns the value 0 when read
You'll note a number of different modes associated with the serial ports. See
\&, page , for more details.
Virtual terminalsvirtualterminalterminalvirtual/dev/ttyv0/etc/ttys
As we have seen, UNIX is a multitasking operating system, but a PC generally
only has one screen. FreeBSD solves this problem with virtual
terminals. When in text mode, you can change between up to 16 different
screens with the combination of the Alt key and a function key. The
devices are named /dev/ttyv0 through /dev/ttyv15, and
correspond to the keystrokes Alt-F1 through Alt-F16. By default,
three virtual terminals are active: /dev/ttyv0 through
/dev/ttyv2. The system console is the virtual terminal
/dev/ttyv0, and that's what you see when you boot the machine. To
activate additional virtual terminals, edit the file /etc/ttys. There
you will find:
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 off secure
The keywords on and off refer to the state of the terminal: to
enable one, set its state to on. To enable extra virtual terminals, add
a line with the corresponding terminal name, in the range /dev/ttyv4 to
/dev/ttyv15.
/dev/dev/MAKEDEVmknodcommandgettydæmoncommandmknoddæmongetty
In addition, you may need to create the device nodes if they don't already
exist. By default, the system contains four virtual terminal devices in the
/dev directory. If you use more than this number, you must create them,
either with MAKEDEV (see page ), or with mknod (see
page mknod(8)). When calculating how many devices you need, note that
if you intend to run X11, you need a terminal device without a getty for
the X server. For example, if you have enabled /dev/ttyv3,
/dev/ttyv4, and /dev/ttyv5, and you also want to run X, you will
need a total of 7 virtual terminals (/dev/ttyv0 through
/dev/ttyv6). With MAKEDEV, you specify how many virtual terminals
you need:
# cd /dev
# ./MAKEDEV vty7 make 7 vtysAlternatively, you can do this with mknod:
# cd /dev
# ls -l ttyv0
crw------- 1 root wheel 12, 0 Nov 28 10:25 ttyv0
# mknod ttyv3 c 12 3
# mknod ttyv4 c 12 4
# mknod ttyv5 c 12 5
# mknod ttyv6 c 12 6majordevice numbermknod
In this example, you list the entry for /dev/ttyv0 in order to check the
major device number of the virtual terminals (that's the 12, in
this example; it may change from one release to another). You need to specify
this number to mknod. For more details about major and minor device
numbers, see page .
/etc/ttys
After you have edited /etc/ttys, and possibly created the device nodes,
you need to tell the system to re-read it in order to start the terminals. Do
this as root with this command:
# kill -1 1initcommandcommandinit
Process 1 is init—see page for more details.
Pseudo-terminalsptypitypseudo-terminalmasterdevice/dev/ptyp0slavedevice/dev/ttyp0
In addition to virtual terminals, FreeBSD offers an additional class of
terminals called pseudo-terminals. They come in pairs: a master
device, also called a pty (pronounced pity) is used only by
processes which use the interface, and has a name like /dev/ptyp0. The
slave device looks like a terminal, and has a name like
/dev/ttyp0. Any process can open it without any special knowledge of the
interface. These terminals are used for network connections such as
xterm, telnet and rlogin. You don't need a getty
for pseudo-terminals.
You need one pseudo-terminal for each terminal-like connection, for example for
an xterm. It's quite easy to run out of them; if you do, you can
configure more—see page . In addition, generate the device
nodes. For example, to generate a second set of 32 pseudo-terminals, enter:
# cd /dev
# ./MAKEDEV pty1You can generate up to 256 pseudo-terminals. They are named ttyp0
through ttypv, ttyq0 through ttyqv, ttyr0 through
ttyrv, ttys0 through ttysv, ttyP0 through
ttyPv, ttyQ0 through ttyQv, ttyR0 through
ttyRv and ttyS0 through ttySv. To create each set of 32
terminals, use the number of the set: the first set is pty0, and the
eighth set is pty7. Note that some processes, such as xterm, only
look at ttyp0 through ttysv.
DisksOne of the most important parts of running any computer system is handling data
on disk. We have already looked at UNIX file handling in . In
this chapter, we'll look at two ways to add another disk to your system.
Adding a hard diskaddinghard diskdiskadding
When you installed FreeBSD, you created file systems on a first hard disk. At
the same time you had the option of creating file systems on other disks on the
system. As I said at the time, it's a good thing to do it then, because it's
much easier that way. Unfortunately, that's not always possible: you
might decide that you need more disk space, and so you buy a new hard disk. In
this section, we'll look at how to set it up to work under FreeBSD.
sysinstallcommandcommandsysinstall
The real problem with adding a second disk is that the ``easy-to-use'' programs
to set them up are not always 100% reliable, and you may need to do everything
by hand. It is possible to use sysinstall to do the job, but there are
a few nasty rough corners that you might run up against. In this section we'll
look at sysinstall, and on page we'll see how to do it
manually if sysinstall won't cooperate.
We've been through all the details of disk layout and slices and partitions in
, so I won't repeat them here. Basically, to add a new disk to
the system, you need to:
Possibly, format the disk. More and more, modern disks come pre-formatted, and
you will only need to format them if there are defects on the disk, or if it's
ancient.
If you want to share with other operating systems, create a Microsoft style
partition table on the disk. We looked at the concepts on page
Define a FreeBSD slice (which Microsoft calls a ``partition'').
Define the partitions in the FreeBSD slice.
Tell the system about the file systems and where to mount them.
Create the file systems.
These are exactly the same operations as we performed in .
Disk hardware installationinstallingdisk hardwaredisksinstalling hardware
Before you can do anything with the disk, you have to install it in the system.
To do this, you shut down the system and turn the power off. If the disk is
IDE, and you already have an IDE disk on the controller, you need to set the
second disk as ``slave'' drive. And you may have to set the first disk
as ``master'' drive: if you only have one drive, you don't set any jumpers, but
if you have two drives, some disks require you to set jumpers on both disks. If
you don't do this, the system will appear to hang during the power-on self test,
and will finally report some kind of disk error.
Adding a SCSI disk is more complicated. Up to 8 SCSI devices can be connected
to most systems (newer SCSI variants allow 16), but this number includes the
host adapter. Typically, your first SCSI disk will have the SCSI ID 0, and the
host adapter will have the SCSI ID 7. Traditionally, the IDs 4, 5, and 6 are
reserved for tape and CD-ROM drives, and the IDs 0 to 3 are reserved for disks,
though FreeBSD doesn't impose any restrictions on what goes where.
dmesgcommandcommanddmesg
Whatever kind of disk you're adding, look at the boot messages, which you can
retrieve with the dmesg command. For example, if you're planning to add
a SCSI device, you might see:
ahc0: <Adaptec 2940 SCSI adapter> rev 0x03 int a irq 11 on pci0.9.0
ahc0: aic7870 Single Channel A, SCSI Id=7, 16/255 SCBs
\&further down...
Waiting 3 seconds for SCSI devices to settle
sa0 at ahc0 bus 0 target 3 lun 0
sa0: <EXABYTE EXB-8505SMBANSH2 0793> Removable Sequential Access SCSI-2 device
sa0: 5.000MB/s transfers (5.000MHz, offset 11)
sa1 at ahc0 bus 0 target 4 lun 0
sa1: <ARCHIVE Python 28849-XXX 4.CM> Removable Sequential Access SCSI-2 device
sa1: 5.000MB/s transfers (5.000MHz, offset 15)
sa2 at ahc0 bus 0 target 5 lun 0
sa2: <TANDBERG TDC 3800 -03:> Removable Sequential Access SCSI-CCS device
sa2: 3.300MB/s transfers
pass4 at ahc0 bus 0 target 4 lun 1
pass4: <ARCHIVE Python 28849-XXX 4.CM> Removable Changer SCSI-2 device
pass4: 5.000MB/s transfers (5.000MHz, offset 15)
da0 at ahc0 bus 0 target 2 lun 0
da0: <CONNER CFP4207S 4.28GB 2847> Fixed Direct Access SCSI-2 device
da0: 3.300MB/s transfers, Tagged Queueing Enabled
da0: 4096MB (8388608 512 byte sectors: 64H 32S/T 4096C)
cd0 at ahc0 bus 0 target 6 lun 0
cd0: <NRC MBR-7 110> Removable CD-ROM SCSI-2 device
cd0: 3.300MB/s transfers
cd0: cd present [322265 x 2048 byte records]
changing root device to wd0s1a
SCSItargettargetSCSISCSIlogical unitlogicalunitLUNThis output shows three tape drives (sa0, sa1 and sa2), a
CD-ROM drive (cd0), a tape changer (pass4), and also a disk
drive da0 on target 2.
Installing an external SCSI deviceinstallingan external SCSI deviceSCSIinstalling an external devicedaisychainingSCSIterminatorterminatorSCSI
External SCSI devices are connected together by cables. Each device has two
connectors: one goes towards the host adapter, and the other towards the next
device. This method is called daisy chaining. At the end of the chain,
the spare connector is usually plugged with a terminator, a set of
resistors designed to keep noise off the bus. Some devices have internal
terminators, however. When installing an external device, you will have to do
one of the following:
If you are installing a first external device (one connected via the cable
connector on the backplane of the host adapter), you will have to ensure that
the device provides termination. Assuming you already have an internal device,
you will also have to stop the host adapter from providing termination. Modern
SCSI host adapters can decide whether they need to terminate or not, but older
host adapters have resistor packs. In the latter case, remove these resistor
packs.
If you are adding an additional external device, you have two choices: you can
remove a cable in the middle of the daisy chain and plug it into your new
device. You then connect a new cable from your device to the device from which
you removed the original cable.
Alternatively, you can add the device at the end of the chain. Remove the
terminator or turn off the termination, and plug your cable into the spare
socket. Insert the terminator in your device (or turn termination on).
Installing an internal SCSI deviceinstallingan internal SCSI deviceSCSIinstalling an internal device
Installing an internal SCSI device is much the same as installing an external
device. Instead of daisy chains, you have a flat band cable with a number of
connectors. Find one which suits you, and plug it into the device. Again, you
need to think about termination:
If you are installing the device at the end of the chain, it should have
termination enabled. You should also remove the terminators from the device
that was previously at the end of the chain.
If you are installing the device in the middle of the chain, make sure it does
not have termination enabled.
In this case, we'll install a CDC 94181 drive in the existing SCSI chain. We
could be in for a surprise: the device ID we get for the new drive depends on
what is currently on the chain. For example, we might have a chain with a
single drive on it:
da0 at ahc0 bus 0 target 2 lun 0
da0: <CONNER CFP4207S 4.28GB 2847> Fixed Direct Access SCSI-2 device
da0: 3.300MB/s transfers, Tagged Queueing Enabled
da0: 4096MB (8388608 512 byte sectors: 64H 32S/T 4096C)
This drive on target 2. If we put our new drive on target 0 and reboot, we see:
da0 at ahc0 bus 0 target 0 lun 0
da0: <CDC 94181-15 0293> Fixed Direct Access SCSI-CCS device
da0: 3.300MB/s transfers
da0: 573MB (1173930 512 byte sectors: 64H 32S/T 573C)
da1 at ahc0 bus 0 target 2 lun 0
da1: <CONNER CFP4207S 4.28GB 2847> Fixed Direct Access SCSI-2 device
da1: 3.300MB/s transfers, Tagged Queueing Enabled
da1: 4096MB (8388608 512 byte sectors: 64H 32S/T 4096C)
Since the target ID of the new disk is lower than the target ID of the old disk,
the system recognizes the new disk as da0, and our previous da0
has become da1.
This change of disk ID can be a problem. You'll have to edit /etc/fstab
in order to be able to mount any file systems which are on the disk.
Alternatively, you can wire down the device names—see page for
more details. The alternative is to change the SCSI IDs. We do that, and the
CDC drive becomes da1:
da0 at ahc0 bus 0 target 0 lun 0
da0: <CONNER CFP4207S 4.28GB 2847> Fixed Direct Access SCSI-2 device
da0: 3.300MB/s transfers, Tagged Queueing Enabled
da0: 4096MB (8388608 512 byte sectors: 64H 32S/T 4096C)
da1 at ahc0 bus 0 target 2 lun 0
da1: <CDC 94181-15 0293> Fixed Direct Access SCSI-CCS device
da1: 3.300MB/s transfers
da1: 573MB (1173930 512 byte sectors: 64H 32S/T 573C)
Formatting the diskformattingdisksdisksformattinglow-levelformatformatlow-level
Formatting is the process of rewriting every sector on the disk with a specific
data pattern, one that the electronics find most difficult to reproduce: if they
can read this pattern, they can read anything. Microsoft calls this a
low-level format. Obviously it destroys any existing data, so
If you have anything you want to keep, back it up before formatting.
Most modern disks don't need formatting unless they're damaged. In particular,
formatting will not help if you're having configuration problems, if you can't
get PPP to work, or you're running out of disk space.
Well, it will solve the disk space problem, but not in the manner you
probably desire.
If you do need to format a SCSI disk, use camcontrol. camcontrol
is a control program for SCSI devices, and it includes a lot of useful functions
which you can read about in the man page. To format a disk, use the following
syntax:
# camcontrol format da0At the time of writing, the format subcommand of camcontrol has
not been implemented. If it doesn't work for you, you can go back to basics and
issue the raw SCSI format command with this invocation:
# camcontrol cmd -n da -u 0 -v -t 7200 -c "4 0 0 0 0 0"Note that here you specify the name of the disk as the type (da) and the
unit number (-u 0). If you wanted to format /dev/da9, you would
use the option -u 9.
The other parameters are:
-v: be verbose.
-t 7200: time out after two hours (7200 seconds). On a very large disk,
you may find that two hours is not enough to format it. In this case, you'll
need to increase this value.
If the format finishes very quickly—in about 5 minutes—there's a good
chance that it is faking the FORMAT UNIT command. It doesn't support it, so it
just goes away and returns in a few minutes having done nothing.
-c "4 0 0 0 0 0" is the SCSI ``FORMAT UNIT'' command. The disk goes
away and formats itself.
Remember that low level formatting a disk destroys all data on the disk. Before
using the command, make sure that you need to do so: there are relatively few
cases that call for low-level formatting a disk. About the only reasons are if
you want to change the physical sector size of the disk, or if you are getting
``medium format corrupted'' errors from the disk in response to read and write
requests.
FreeBSD can format only floppies and SCSI disks. If you find you have to format
an IDE disk, you'll have to use the format utility in your system BIOS.
Fortunately, you almost never need to reformat a disk.
Using sysinstallsysinstallcommandcommandsysinstall
If you can, use sysinstall to partition your disk. Looking at the
dmesg output for our CDC 94181 SCSI disk, we see:
da1 at ahc0 bus 0 target 2 lun 0
da1: <CDC 94181-15 0293> Fixed Direct Access SCSI-CCS device
da1: 3.300MB/s transfers
da1: 573MB (1173930 512 byte sectors: 64H 32S/T 573C)
We start sysinstall with:
# /stand/sysinstall
You will see the standard installation screen (see , page
). Select Index, then Partition, and you
will see the following screen:
Don't be put off by the drive names sd0 and sd1. These are the
old names for the SCSI drives da0 and da1. Currently,
sysinstall shows both the old and the new names.
In this case, we want to partition /dev/da1, so we position the cursor on
da0 (as shown) and press Space (not Enter; that would just
take us back to the previous menu). At this point you may see a warning message
that the drive geometry is incorrect. If you do, it's probably a bug: we saw in
the dmesg output that the probes had no trouble with the geometry, and
geometry is not of great importance for a SCSI drive anyway: you only need it if
you want to boot from the drive. If you get this message, you press Enter
to continue.
Next, we see:
Here we see that the disk currently contains three partitions:
The first starts at offset 0, and has a length of 12. This is not
unused, no matter what the description says. It's the partition table, padded
to the length of a ``track''.
The next partition takes up the bulk of the drive and is the current FreeBSD
partition.
Finally, we have 90 sectors left over as a result of the partitioning scheme.
Sometimes this can be much larger—I have seen values as high as 35 MB. This
is the price we pay for compatibility with Microsoft partitioning.
We're using this disk for FreeBSD only, and we don't want to waste even this
much space, so we'll select the option ``use whole disk for FreeBSD'', the
so-called ``dangerously dedicated'' mode. This term comes partially from
superstition and partially because some BIOSes expect to find a partition table
on the first sector of a disk, and they can't access the disk if they don't find
one. If your BIOS has this bug, you'll find this one out pretty quickly when
you try to boot. If it doesn't fail on the first boot, it won't fail.
To use the whole disk, we first delete the current partition: we press the
cursor down key until it highlights the FreeBSD partition. Then we press
d, and the three partitions are joined into one, marked unused.
The next step is to create a new partition using the entire disk. We press
a, and get the following message:
We've already decided to use the whole disk, so we move the cursor right to
No, as shown in the figure, and press Enter. Then we press
q to exit the partition editor, get back to the function index, and
select Label. We see:
We want to create two partitions: first, a swap partition of 200 Megabytes, and
then a file system taking up the rest of the disk. We press C, and are shown a
submenu offering us all 1173930 blocks on the disk. We erase that and enter
200m, which represents 200 Megabytes. Then we press Enter, and
another submenu appears, asking us what kind of slice it is. We move the cursor
down to select A swap partition:
Next, we press c again to create a new partition. This time, we accept
the offer of the rest of the space on the disk, 764330 sectors, we select A
file system, and we are presented with yet another menu asking for the name
of the file system. We enter the name, which happens to be /S:
After pressing Enter, we see:
Finally, we press W to tell the disk label editor to perform the
function. We get an additional warning screen:
Since we're doing this on-line, that's OK. We select Yes, and
sysinstall creates the file system and mounts both it and the swap
partition. This can take quite a while. Don't try to do anything with the
drive until it's finished.
Doing it the hard way
Unfortunately, sometimes you may not be able to use the sysinstall
method. That leaves us with the old way to add disks. The only difference is
that this time, we need to use different tools. In the following sections,
we'll look at what we have to do to install an old CDC SCSI drive, even older
than the one in the previous section.
Creating a partition tablecreatinga partition tablepartitiontable
We looked at how to format the disk on page . The next step is
to create a Microsoft style partition table on the disk. We looked at the
concepts on page
fdiskcommandcommandfdisk
but this time we use different tools. As in Microsoft, the partitioning program is
called fdisk, and the man page is on page
In the following discussion, you'll find a pocket calculator useful.
Depending on what was on the disk before, fdisk could get sufficiently
confused to not work correctly. If you don't format the disk, it's a good idea
to overwrite the beginning of the disk with dd:
# dd if=/dev/zero of=/dev/rda1 count=100
100+0 records in
100+0 records out
51200 bytes transferred in 1 secs (51200 bytes/sec)
Next, we look at what's on the disk. This doesn't seem to make much sense,
since we have just overwritten the contents, but fdisk will tell us one
thing of importance: the disk geometry. We'll need this later on.
# fdisk /dev/rda1
******* Working on device /dev/rda1 *******
parameters extracted from in-core disklabel are:
cylinders=967 heads=9 sectors/track=35 (315 blks/cyl)
parameters to be used for BIOS calculations are:
cylinders=967 heads=9 sectors/track=35 (315 blks/cyl)
fdisk: Invalid fdisk partition table found
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 0 is:
<UNUSED>
The data for partition 1 is:
<UNUSED>
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 1, size 304604 (148 Meg), flag 80
beg: cyl 0/ sector 2/ head 0;
end: cyl 967/ sector 1/ head 0
You'll notice that fdisk has decided to put a FreeBSD partition in
partition 3. That's not what we want in this case: we want a Microsoft
partition as well. This is a small disk by modern standards, only 150 MB, so
we'll assign 100 MB to FreeBSD, and leave 50 MB for Microsoft. Our resulting
partition table should look like:
h = .2i
dh = .02i
dw = 1.7i
move right .5i
down
[
boxht = h; boxwid = 1.7i
box ht .15i "Master Boot Record"
box ht .15i "Partition Table"
P1: box ht .4i
P2: box ht .4i
P3: box ht .4i
P4: box ht .4i
move right 1.65i from P1.ne
boxwid = 2.2
down
C: box ht .25i "Microsoft C: drive"
move .25i
FA: box ht .2i "FreeBSD disk label and bootstrap"
box ht .2i "/dev/da1s2a"
box ht .2i "/dev/da1s2b: FreeBSD swap"
box ht .2i "/dev/da1s2d"
box ht .2i "/dev/da1s2e"
box ht .2i "/dev/da1s2f"
box ht .2i "/dev/da1s2g"
box ht .2i "/dev/da1s2h: /home file system"
arrow from P1.e to C.w
arrow from P2.e to FA.w
move up .08i from P1.c "Slice 1 - Microsoft primary"
move down .08i from P1.c "/dev/da1s1, 48 MB"
move up .08i from P2.c "Slice 2 - FreeBSD"
move down .08i from P2.c "/dev/da1s2, 100 MB"
"Slice 3 (unused)" at P3.c
"Slice 4 (unused)" at P4.c
]
Partition table on second FreeBSD diskfdiskcommandcommandfdisk
The Master Boot Record and the Partition Table take up the first sector of the
disk, and the rest can be divided between the partitions. It's easy to make a
mistake in specifying the parameters, and fdisk performs as good as no
checking. You can easily create a partition table that has absolutely no
relationship with reality, so it's a good idea to calculate them in advance.
For each partition, we need to know three things:
partitiontype
The partition type, which fdisk calls sysid. This is a
number describing what the partition is used for. FreeBSD partitions have
partition type 165, and modern (release 4 and later) Microsoft partitions have type
6.
The start sector, the first sector in the partition.
The end sector for the partition.
activepartitionpartitionactive
In addition, we need to decide which partition is the active partition,
the partition from which we want to boot. In this case, it doesn't make any
difference, since we won't be booting from the disk, but it's always a good idea
to set it anyway.
We specify the partitions we don't want by giving them a type, start sector and
end sector of 0. As we have seen, our disk has 304605 sectors, numbered 0 to
304604. Partitions should start and end on a cylinder boundary. We want the
FreeBSD partitions to be about 100 MB, or 204,800 sectors, which leaves 99,806
sectors for the Microsoft partition. We know the geometry from the fdisk
output above: cylinders=967 heads=9 sectors/track=35 (315 blks/cyl). So
our 204,800 sectors would take up 204800 / 315, or 650.1587302 cylinders. Since
we want to use this disk primarily for FreeBSD, we'll round this value up to 651
cylinders, or 205,065 sectors. This leaves 316 cylinders, less the first sector
on the disk, for Microsoft, a total of (316 * 315) - 1 or 99,539 sectors. Our
resulting information is:
If you're unlucky, fdisk will give you a completely different idea of
the disk geometry from what scsiformat did. Possibly you can decide by
examination which program is wrong, or maybe you can look at the dmesg
output for a tie-breaker. In all cases I have seen, it has been fdisk
that returned the incorrect information, and only when the disk did not have a
valid partition table. For example, this happened with a disk formatted for
BSD/OS:
# scsiformat da1
MICROP
2112-15MQ1094802
HQ48
Mode data length: 35
Medium type: 0
Device Specific Parameter: 0
Block descriptor length: 8
Density code: 0
Number of blocks: 2051615
Reserved: 0
Block length: 512
PS: 1
Reserved: 0
Page code: 4
Page length: 22
Number of Cylinders: 1760
Number of Heads: 15
Starting Cylinder-Write Precompensation: 0
Starting Cylinder-Reduced Write Current: 0
Drive Step Rate: 0
Landing Zone Cylinder: 0
Reserved: 0
RPL: 0
Rotational Offset: 0
Reserved: 0
Medium Rotation Rate: 5400
Reserved: 0
Reserved: 0
# fdisk da1
******* Working on device /dev/rda1 *******
parameters extracted from in-core disklabel are:
cylinders=160 heads=256 sectors/track=50 (12800 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=160 heads=256 sectors/track=50 (12800 blks/cyl)
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 0 is:
sysid 255,(BBT (Bad Blocks Table))
start 1023744, size 2108293151 (1029440 Meg), flag 0
beg: cyl 768/ sector 15/ head 147;
end: cyl 0/ sector 0/ head 255
The data for partition 1 is:
sysid 101,(Novell Netware 3.xx)
start 1646292846, size 1814062195 (885772 Meg), flag 0
beg: cyl 356/ sector 50/ head 0;
end: cyl 256/ sector 50/ head 114
The data for partition 2 is:
sysid 0,(unused)
start 0, size 0 (0 Meg), flag 61
beg: cyl 364/ sector 37/ head 98;
end: cyl 0/ sector 0/ head 0
The data for partition 3 is:
<UNUSED>
Looking at the output from dmesg, we see:
(aha0:1:0): "MICROP 2112-15MQ1094802 HQ48" type 0 fixed SCSI 2
da1(aha0:1:0): Direct-Access 1001MB (2051615 512 byte sectors)
da1(aha0:1:0): with 1760 cyls, 15 heads, and an average 77 sectors/track
In this case, then, you should use the parameters 1760 cylinders, 15 heads, and
77 sectors per track. What's less obvious here is the number of cylinders:
fdisk doesn't have an opinion, and scsiformat and dmesg
decided it has 2,051,615 sectors. Unfortunately, if you calculate the number
according to the formula cylinders \(mu heads \(mu
sectors, you'll come up with a different result: in this case 1760 \(mu 15
\(mu 77 = 2,032,800. How come? The disks report the total number of sectors,
including spare tracks and such, but you can't use them all. The 2,032,800 is
the correct number, and if you try to specify 2,051,615 to disklabel, it
will spit out lots of messages about partitions which go beyond the end of the
disk.
Next we run fdisk in earnest by specifying the -i option.
During this time, you will see messages on the console:
da1: invalid primary partition table: no magic
The message no magic doesn't mean that fdisk is out of purple
smoke. It refers to the fact that it didn't find the so-called magic
number, which identifies the partition table. Since we don't have a
partition table yet, this message isn't surprising. It's also completely
harmless.
fdisk prompts interactively:
# fdisk -i /dev/rda1
******* Working on device /dev/rda1 *******
parameters extracted from in-core disklabel are:
cylinders=967 heads=9 sectors/track=35 (315 blks/cyl)
parameters to be used for BIOS calculations are:
cylinders=967 heads=9 sectors/track=35 (315 blks/cyl)
Do you want to change our idea of what BIOS thinks ? [n] Enter pressed
fdisk: Invalid fdisk partition table found
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 0 is:
<UNUSED>
Do you want to change it? [n] y
Supply a decimal value for "sysid" [0] 6
Supply a decimal value for "start" [0] 1
Supply a decimal value for "size" [0] 99539
Explicitly specifiy beg/end address ? [n] Enter pressed
sysid 6,(Primary 'big' DOS (> 32MB))
start 1, size 99539 (48 Meg), flag 0
beg: cyl 0/ sector 2/ head 0;
end: cyl 315/ sector 35/ head 8
Are we happy with this entry? [n] y
The data for partition 1 is:
<UNUSED>
Do you want to change it? [n] y
Supply a decimal value for "sysid" [0] 165
Supply a decimal value for "start" [0] 99540
Supply a decimal value for "size" [0] 205065
Explicitly specifiy beg/end address ? [n] Enter pressed
sysid 165,(FreeBSD/NetBSD/386BSD)
start 99540, size 205065 (100 Meg), flag 0
beg: cyl 316/ sector 1/ head 0;
end: cyl 966/ sector 35/ head 8
Are we happy with this entry? [n] y
The data for partition 2 is:
<UNUSED>
Do you want to change it? [n] Enter pressed
The data for partition 3 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 1, size 304604 (148 Meg), flag 80
beg: cyl 0/ sector 2/ head 0;
end: cyl 967/ sector 1/ head 0
Do you want to change it? [n] y
The static data for the DOS partition 3 has been reinitialized to:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 1, size 304604 (148 Meg), flag 80
beg: cyl 0/ sector 2/ head 0;
end: cyl 967/ sector 1/ head 0
Supply a decimal value for "sysid" [165] 0
Supply a decimal value for "start" [1] 0
Supply a decimal value for "size" [304604] 0
Explicitly specifiy beg/end address ? [n] Enter pressed
sysid 0,(unused)
start 0, size 0 (0 Meg), flag 80
beg: cyl 0/ sector 0/ head 0;
end: cyl 0/ sector 0/ head 0
Are we happy with this entry? [n] y
Do you want to change the active partition? [n] y
Supply a decimal value for "active partition" [3] 1
Are you happy with this choice [n] y
We haven't changed the partition table yet. This is your last chance.
parameters extracted from in-core disklabel are:
cylinders=967 heads=9 sectors/track=35 (315 blks/cyl)
parameters to be used for BIOS calculations are:
cylinders=967 heads=9 sectors/track=35 (315 blks/cyl)
Information from DOS bootblock is:
0: sysid 6,(Primary 'big' DOS (> 32MB))
start 1, size 99539 (48 Meg), flag 0
beg: cyl 0/ sector 2/ head 0;
end: cyl 315/ sector 35/ head 8
1: sysid 165,(FreeBSD/NetBSD/386BSD)
start 99540, size 205065 (100 Meg), flag 80
beg: cyl 316/ sector 1/ head 0;
end: cyl 966/ sector 35/ head 8
2: <UNUSED>
3: <UNUSED>
Should we write new partition table? [n] yBy default, fdisk creates a FreeBSD partition in slice 3. Even though
we didn't have any space left, it created a partition there. You don't need to
delete it if you don't want to, but since it overlaps the other partitions, it
would probably confuse Microsoft utilities, so it's a good idea.
Labelling the disklabellingdisksdiskslabellingdisksliceslicedisk
Once we have a valid Microsoft partition table, we need to pay more attention to
our FreeBSD slice (slice 1, or Microsoft partition 2). It'll make life easier here
to remember a few things:
From now on, we're just looking at the slice, which we can think of as a logical
disk. Names like disk label really refer to the slice, but since many
standard terms use the word disk, we'll continue to use them.
All offsets are relative to the beginning of the slice, not the beginning of the
disk. Sizes also refer to the slice and not the disk.
/dev/rda1c/dev/da1c
Depending on the operation, we may need to take the raw disk
(/dev/rda1c)
or the block device (/dev/da1c).
Sometimes the
programs can recover if you specify the wrong device, but sometimes they produce
some really strange error messages instead.
The first thing we need is the disk label, which supplies information about the
disk geometry and the layout of the file systems. These are two different
things, of course: the overall disk geometry is determined by the kind of disk,
but you have decided (with fdisk) what part of the disk represents the
FreeBSD slice, and you also need to define what file systems you want. As we
saw in , page
a typical first disk will contain a root file system, swap space and a
/usr file system. On other disks, this arrangement may be different.
The arguments in favour of a small root file system are less powerful on other
disks. On the other hand, you may want to add swap on other disks: firstly,
it's possible that you are a bit low on swap, and secondly, spreading swap over
other disks can improve performance if you are low on memory. In our example,
let's add 20 MB of swap and make the rest of the slice a /home file
system. In addition, we need to define the c partition, which
represents the whole disk. Traditionally, data disks use the h
partition and not the a partition, so we'll stick to that tradition,
though there's nothing to stop you from using the a partition if you
prefer. For each partition, we need to know the start offset, the size and the
file system type. In summary, the FreeBSD slice we want to create looks like:
h = .2i
dh = .02i
dw = 1.7i
boxwid = 2.5i
down
[ S: box invis
FA: box ht .2i "FreeBSD disk label and bootstrap" at S+(1,0)
box ht .2i "/dev/da1a (empty)"
box ht .2i "/dev/da1s2b: FreeBSD swap, 20 MB"
box ht .2i "/dev/da1s2d (empty)"
box ht .2i "/dev/da1s2e (empty)"
box ht .2i "/dev/da1s2f (empty)"
box ht .2i "/dev/da1s2g (empty)"
box ht .2i "/dev/da1s2h: /home file system, 80 MB"
]
FreeBSD slice on second diskDisklabeldisklabelcommandcommanddisklabel/etc/disktabfilefile/etc/disktab
The program which writes the disk label is called (wait for it)
disklabel. You can tell it the geometry and file system layout
information in two different ways: you can find or create an entry in
/etc/disktab, or you can create your own prototype file. We'll look at
both ways in the following sections.
/etc/disktab
You can label the disk with a command like
# disklabel -w -r da1 disktypedisktype is a label in the file /etc/disktab, which contains
definitions of disk geometry for a number of known disks. There's a good chance
that your disk won't be in it, though. An entry in disktab looks like:
fuji2266|Fujitsu M2266S: \e
:ty=winchester:dt=SCSI:se#512:nt#15:ns#85:nc#1658:rm#3600:\e
:pc#2113950:oc#0: \e
:ph#2107704:oh#0:bh#4096:fh#512:th=4.2BSD:
termcapdisklabelcommandcommanddisklabel
The format of this file is derived from termcap, and it's a bit tough at
first sight. In fact, there isn't too much you need to understand. The first
name, up to the | symbol, is the label. This is the name you
specify to disklabel, so you don't want to make it too long. The next
name, up to the :, is a more verbose description of the disk. After the
colon come specifications consisting of a property name, followed by either a
= symbol and a string value, or a # symbol and a numeric value.
See the man page disktab(5) for further details. The values that
interest us are:
disktab values
box,tab(#) ;
| lfCWp9 | lw72 | .
Name#Meaning
=
ty Type of disk. winchester specifies a non-removable hard disk. dt Type of controller, in this case SCSI se Number of bytes per sector. For current FreeBSD systems, this must be 512 nt Number of tracks per cylinder, in this case 15. ns Number of sectors per track, in this case 85. nc Number of cylinders, in this case 1658. rm Rotational speed of the disk, by default 3600. This is not absolutely essential. bx The size of ufs file system blocks in partition x, where x is a partition letter from a to h. See the discussion of partitions in , page
for more information. ox Offset (starting sector) of partition x, where x is a partition letter from a to h. See the discussion of partitions in , page
for more information. px Size in sectors of partition x. bx The size of ufs file system blocks in partition x. fx The size of ufs file system fragments in partition x. tx The type of the partition. This can be 4.2BSD (for ufs; the name is historical) or swap for a swap partition.
newfscommandcommandnewfs
We won't look at the block and fragment sizes in this discussion. See the man
page for newfs
on page
for further details.
There's no definition in /etc/disktab for our CDC 94161-9 disk, of
course, so we'll have to write one. We need the following information on the
disk geometry, all of which we can find in the printout from fdisk:
The number of tracks or heads (nt), 9.
The number of cylinders (nc). Well, that should be 967, but don't
forget that we're looking at the slice, not the disk, and our slice only has
651 cylinders, so that's what we say.
The number of sectors per track (ns), 35.
The total number of sectors in the partition. Calculate the number from the
formula cylinders \(mu heads \(mu sectors, even if you are
using the whole disk: the output from dmesg or scsiformat is not
correct here.
OK, let's roll up our sleeves. The swap partition comes directly after the
bootstrap and the disk label, each of which take up 1 sector, so the swap
partition starts at offset 2. It's 20 MB (20,971,520 bytes or 40,960 sectors),
but it would be nice to have it end on a cylinder boundary, so we'll divide by
the number of sectors per cylinder. 40,960 / 315 = 130.031746 cylinders, so
we'll call it 130 cylinders or 40,950 sectors. Since we don't start on a
cylinder boundary (the bootstrap and disk label come first), we subtract their
length (2) and end up with 40,948 sectors, so the definitions for swap
(partition b) are: start (ob) is 2, size (pb) is 40948,
and type (tb) is swap.
Next we look at the /home file system. It starts immediately after the
swap partition (offset 40950), and takes up the rest of the space on the
partition, so the size is 205065 (the length of the partition) - 40950 (the
length of the bootstrap, disk label, and swap space) = 164115 sectors. The type
(tb) is 4.2BSD.
Finally, we define partition c. That's easy: the start (oc) is
the 0, and the size (pc) is the size of the FreeBSD partition, 205065,
and the type isn't defined, so we don't have a td parameter.
Putting all this together, we get:
cdc94161|CDC 94161-9: \e
:ty=winchester:dt=SCSI:se#512:nt#9:ns#35:nc#651:rm#3600:\e
:ob#2:pb#40948:tb=swap:\e
:oc#0:pc#205065:\e
:oh#40950:ph#164115:tb=4.2BSD:
Finally, we can label the disk:
# disklabel -w -r /dev/da1c cdc94161When you do this, expect a kernel message (in high-intensity display) saying
``Cannot find disk label''. Since there isn't any label, it can't be
found. This is another harmless chicken and egg problem.
Disk prototype filediskprototype filefiledisk prototype
Alternatively, you can create a disk prototype file just for this disk.
This has the advantage that most of the work is done for you. Start by
entering:
# disklabel /dev/rda1 >diskproto write info to file diskproto
Warning, revolutions/minute 0
boot block size 0
super block size 0
# cat diskproto look at what we got
# /dev/rda1:
type: unknown
disk:
label:
flags:
bytes/sector: 512
sectors/track: 35
tracks/cylinder: 9
sectors/cylinder: 315
cylinders: 967
sectors/unit: 304605
rpm: 0
interleave: 0
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0
3 partitions:
# size offset fstype [fsize bsize bps/cpg]
c: 304605 0 unused 0 0 # (Cyl. 0 - 966)
We have to change a number of things in this file:
The values for interleave (the number of physical sectors between
logical sectors; don't worry if you don't understand this) and prm (the
number of rotations of the disk platter per minute) are both 0, which is
invalid. FreeBSD doesn't use these values, but it still refuses to label the
disk unless you enter some plausible value. We set interleave to 1 and
rpm to 3600, which used to be a standard value for disks.
In addition, although our partition table says that the FreeBSD slice only has
651 cylinders, the value here shows the complete disk. We need to change this
value to 651.
The type field says unknown. We change it to SCSI.
disklabelcommandcommanddisklabel
For documentation purposes, we set the disk field to cdc94161,
and the label field to FreeBSD. disklabel doesn't care
what's in these fields, but it copies them to disk.
In addition, we need to add the definitions of the file system layout. We'll
look at that in the rest of this section.
The last part of the prototype file describes the partitions. In this case, we
have three lines: the number of partitions, a comment describing the format, and
a definition of the c partition. The disk prototype file here ignores
the partition table completely: it claims that partition c takes up the
whole disk. We need to fix that, and we need to add information about slices
b and h.
Since we are using partition h, we need to change the information 3
partitions at the bottom of the file to 8 partitions so that
disklabel will be able to create partition h.
We'll use the same sizes as in the previous example: We'll put the swap
partition first. Remembering that we specify our offsets relative to the start
of the FreeBSD slice, so the swap partition has offset 2, immediately after the
boot sector and the disk label. It's 20 MB (20,971,520 bytes or 40,960
sectors), but want it to finish at the end of a cylinder, so we divide by the
number of sectors per cylinder. 40,960 / 315 = 130.031746 cylinders, so we'll
call it 130 cylinders, which corresponds to 40,950 sectors. Since we don't
start on a cylinder boundary (the bootstrap and disk label come first), we
subtract their length (2) and end up with 40,948 sectors, so the definitions for
swap (partition b) are: size is 40948, offset is 2, and type is
swap.
Next we look at the /home file system. It starts immediately after the
swap partition (sector 40950 relative to the beginning of the slice), and takes
up the rest of the space on the partition, so the size is 205065 (the length of
the partition) - 40950 (the length of the swap space) = 164115 sectors.
Accordingly, the definitions for /home are: size 164430, offset 49050,
and fstype4.2BSD.
Finally, we define partition c. That's easy: the start is 0, and the
size is the size of the FreeBSD partition, 205380. We leave fstype as
unused.
With an editor, we make these changes to diskproto. The result looks
like:
# /dev/rda1c:
type: SCSI
disk: cdc94161
label: FreeBSD
flags:
bytes/sector: 512
sectors/track: 35
tracks/cylinder: 9
sectors/cylinder: 315
cylinders: 651
sectors/unit: 205065
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
b: 40948 2 swap # (Cyl. 0*- 129*)
c: 205065 0 unused 0 0 # (Cyl. 0 - 650)
h: 164115 40950 unused 0 0 # (Cyl. 130 - 650)
Finally, we label the disk:
# disklabel -R -r da1 diskprotoChecking the resultsWhichever way we label the disk, it's a good idea to check that it really did
the job. Along with some strange error messages, disklabel occasionally
forgets to tell you that it didn't do anything—for example, if the partition
table was defective. We can list the label with disklabel -r:
# disklabel -r da1
# /dev/rda1c:
type: SCSI
disk: cdc94161
label: FreeBSD
flags:
bytes/sector: 512
sectors/track: 35
tracks/cylinder: 9
sectors/cylinder: 315
cylinders: 651
sectors/unit: 205065
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
b: 40948 2 swap # (Cyl. 0*- 129*)
c: 205065 0 unused 0 0 # (Cyl. 0 - 650)
h: 164115 40950 unused 0 0 # (Cyl. 130 - 650)
Things that can go wrongTo get disklabel to do what you want, you really must stick to every
tiny detail here. If you don't, you can expect a number of strange error
messages. Here are some that you could encounter.
No disk label on disk is straightforward enough. You tried to use
disklabel to look at the label before you had a label to look at. This
happens when you use /dev/da1 instead of /dev/rda1.
Label magic number or checksum is wrong! tells you that
disklabel thinks it has a label, but it's invalid. This could be the
result of an incorrect previous attempt to label the disk. It can be difficult
to get rid of an incorrect label. The best thing to do is to repartition the
disk with the label in a different position, and then copy /dev/zero to
where the label used to be. Then you can repartition again the way you want to
have it.
Open partition would move or shrink probably means that you have
specified incorrect values in your slice definitions. Check particularly that
the c partition corresponds with the definition in the partition table.
write: Read-only file system means that you are trying to do something
invalid with a valid disk label. FreeBSD write protects the disk label, which
is why you get this message.
When labelling via /etc/disktab, you might get the message cdc94161:
unknown disk type. This could mean that you forgot to terminate the last
line in the file—add a blank line after just to be sure.
In addition, you might get kernel messages like fixlabel: raw partition
size > slice size or fixlabel: raw partitions offset != slice offset,
whose meanings should be obvious.
Creating the file systemscreatingfile systemsfilesystems
Now that we have a valid label, the next thing we need to do is to create the
file systems. In this case, there's only one file system, on /dev/da1h.
Mercifully, this is easier:
# newfs /dev/rda1h
Warning: 3822 sector(s) in last cylinder unallocated
/dev/rda1h: 164114 sectors in 41 cylinders of 1 tracks, 4096 sectors
80.1MB in 3 cyl groups (16 c/g, 32.00MB/g, 7680 i/g)
super-block backups (for fsck -b #) at:
32, 65568, 131104,
Well, that warning doesn't look nice. It looks as if we've lost nearly 2 MB of
space on a very small disk. In fact, this message is the wrong way round: there
are 3822 sectors not available for the last cylinder group, in other words, it
only has 274 sectors. This isn't really a problem, since they can be used
anyway. If you want to be tidy, you can can go back and change the division
between swap and file system if we want: we subtract 274 sectors from
partition h, which gives us the new disktab entry:
cdc94161|CDC 94161-9: \e
:ty=winchester:dt=SCSI:se#512:nt#9:ns#35:nc#651:rm#3600:\e
:ob#2:pb#41222:tb=swap:\e
:oc#0:pc#205065:\e
:oh#41224:ph#163841:tb=4.2BSD:
or the diskproto entry
# size offset fstype [fsize bsize bps/cpg]
b: 41222 2 swap # (Cyl. 0*- 130*)
c: 205065 0 unused 0 0 # (Cyl. 0 - 650)
h: 163841 41224 unused 0 0 # (Cyl. 130*- 650*)
You can then go back and re-label the disk. This time, you see:
# newfs /dev/rda1h
/dev/rda1h: 163840 sectors in 40 cylinders of 1 tracks, 4096 sectors
80.0MB in 3 cyl groups (16 c/g, 32.00MB/g, 7680 i/g)
super-block backups (for fsck -b #) at:
32, 65568, 131104,
As you can see, the partition has become smaller, but at least the error message
is gone.
Editing disk labelseditingdisk labelsdiskediting labels
If you already have a disk label, and you just want to change it, as in the
example in the previous section, you have an alternative method: you can start
disklabel in edit mode by entering
# disklabel -e da1In edit mode, disklabel creates a diskproto entry and edits it with your
favourite editor (if you have set the environment variable EDITOR) or
vi otherwise. When you leave the editor, it writes the label back to
the disk. If you use this method, be sure to remove your diskproto
file, since it will be out of date.
Mounting the file systemsmountingfile systemsfilesystems
Finally the job is done. Well, almost. You still need to mount the file
system, and to tell the system that it has more swap. But that's not much of a
problem:
# mkdir /home make sure we have a directory to mount on
# mount /dev/da1h /homeand mount it
# swapon /dev/da1b
# dfshow free capacity and mounted file systems
Filesystem 1024-blocks Used Avail Capacity Mounted on
/dev/wd0a 19966 17426 944 95% /
/dev/wd0s1e 1162062 955758 113340 89% /usr
procfs 4 4 0 100% /proc
presto:/ 15823 6734 8297 45% /presto/root
presto:/usr 912271 824927 41730 95% /presto/usr
presto:/home 1905583 1193721 521303 70% /presto/home
presto:/S 4065286 3339635 563039 86% /S
/dev/da1h 79270 1 72928 0% /home
/etc/fstab
This looks fine, but when you reboot the system, /home will be gone. To ensure
that it gets mounted every time, you need to add the following line to
/etc/fstab:
/dev/da1h /home ufs rw 0 0
mountcommandcommandmount
This will cause da1h to be mounted at system startup time—see the
description of mount
on page
and the man page on page
Recovering from disk data errorsrecoveringfrom disk data errorsdiskrecovering from data errors
Modern hard disks are a miracle in evolution. Today you can buy a 16 GB hard
disk for well under $500, and it will fit in your shirt pocket. 30 years ago, a
typical disk was the size of a washing machine and stored 20 MB. You would need
800 of them to store 16 GB.
At the same time, reliability has gone up, but disks are still relatively
unreliable devices. You can achieve maximum reliability by keeping them cool,
but sooner or later you are going to run into some kind of problem. One kind is
due to surface irregularities: the disk can't read a specific part of the
surface.
Modern disks make provisions for recovering from such errors by allocating an
alternate sector for the data. IDE drives do this automatically, but with SCSI
drives you have the option of enabling or disabling reallocation. Usually it is
turned on when you buy them, but occasionally it is not. When installing a new
disk, you should check that the parameters ARRE (Auto Read
Reallocation Enable) and AWRE (Auto Write Reallocation
Enable) are turned on. For example, to check and set the values for disk
da1, you would enter:
# scsi -f /dev/rda1c -m 1 -e -P 3This command will start up your favourite editor (either the one specified in
the EDITOR environment variable, or vi by default) with the
following data:
AWRE (Auto Write Reallocation Enbld): 0
ARRE (Auto Read Reallocation Enbld): 1
TB (Transfer Block): 0
PER (Post Error): 0
DTE (Disable Transfer on Error): 0
DCR (Disable Correction): 0
Read Retry Count: 1
Correction Span: 0
Write Retry Count: 1
The values for AWRE and ARRE should both be 1. If they aren't,
as in this case, where AWRE is 0, change the data with the editor, write
it back, and exit. The scsi program will write the data back to the
disk and enable the option.
Virtual disks: the Vinum Volume Manager
No matter what disks you have, there will always be limitations:
They can be too small.
They can be too slow.
They can be too unreliable.
VinumVolumeManagerVinum is a so-called Volume Manager, a virtual disk driver that
addresses these three problems. Let's look at them in more detail. Various
solutions to these problems have been proposed and implemented:
Disks are too smallThe ufs file system can theoretically span more than a petabyte
(2\u\s-450\s0\d or 10\u\s-415\s0\d bytes) of storage, but no current disk drive
comes close to this size. Often you'll find you want a file system that is
bigger than the disks you have available. Admittedly, this problem is not as
acute as it was ten years ago, but it still exists. Some systems have solve
this by creating an abstract device which stores its data on a number of disks.
Access bottlenecksModern systems frequently need to access data in a highly concurrent manner.
For example, ftp.FreeBSD.org maintains up to 5,000 concurrent
FTP sessions and has a 100 Mbit/s connection to the outside world,
corresponding to about 12 MB/s.
Current disk drives can transfer data sequentially at up to 30 MB/s, but this
value is of little importance in an environment where many independent processes
access a drive, where they may achieve only a fraction of these values. In such
cases it's more interesting to view the problem from the viewpoint of the disk
subsystem: the important parameter is the load that a transfer places on the
subsystem, in other words the time for which a transfer occupies the drives
involved in the transfer.
In any disk transfer, the drive must first position the heads, wait for the
first sector to pass under the read head, and then perform the transfer. These
actions can be considered to be atomic: it doesn't make any sense to interrupt
them.
Consider a typical transfer of about 10 kB: the current generation of
high-performance disks can position the heads in an average of 6 ms. The
fastest drives spin at 10,000 rpm, so the average rotational latency (half a
revolution) is 3 ms. At 30 MB/s, the transfer itself takes about 350 μs, almost
nothing compared to the positioning time. In such a case, the effective
transfer rate drops to a little over 1 MB/s and is clearly highly dependent on
the transfer size.
The traditional and obvious solution to this bottleneck is ``more spindles'':
rather than using one large disk, it uses several smaller disks with the same
aggregate storage space. Each disk is capable of positioning and transferring
independently, so the effective throughput increases by a factor close to the
number of disks used.
The exact throughput improvement is, of course, smaller than the number of disks
involved: although each drive is capable of transferring in parallel, there is
no way to ensure that the requests are evenly distributed across the drives.
Inevitably the load on one drive will be higher than on another.
concatenationVinumVinumconcatenation
The evenness of the load on the disks is strongly dependent on the way the data
is shared across the drives. In the following discussion, it's convenient to
think of the disk storage as a large number of data sectors which are
addressable by number, rather like the pages in a book. The most obvious method
is to divide the virtual disk into groups of consecutive sectors the size of the
individual physical disks and store them in this manner, rather like taking a
large book and tearing it into smaller sections. This method is called
concatenation and has the advantage that the disks do not need to have
any specific size relationships. It works well when the access to the virtual
disk is spread evenly about its address space. When access is concentrated on a
smaller area, the improvement is less marked. Figure illustrates the
sequence in which storage units are allocated in a concatenated organization.
h = .3i
dh = .02i
dw = .8i
down
[
[
boxht = h; boxwid = dw
move right 1i; down
A: box dotted ht h "0"
B: box dotted ht h "1"
C: box dotted ht h "2"
D: box dotted ht h "3"
E: box dotted ht h "4"
F: box dotted ht h "5"
box ht h * 6 at C.s
A1: box dotted at A+(dw*1.6,0) ht h "6"
B1: box dotted ht h "7"
C1: box dotted ht h "8"
D1: box dotted ht h "9"
box ht h * 4 at C1.n
A2: box dotted at A1+(dw*1.6,0) "10"
F2: box dotted ht h "11"
box ht h * 2 at A2.s
A3: box dotted at A2+(dw*1.6,0) ht h "12"
B3: box dotted ht h "13"
C3: box dotted ht h "14"
D3: box dotted ht h "15"
E3: box dotted ht h "16"
F3: box dotted ht h "17"
box ht h * 6 at C3.s
"Disk 1" at A.n+(0,.2i)
"Disk 2" at A1.n+(0,.2i)
"Disk 3" at A2.n+(0,.2i)
"Disk 4" at A3.n+(0,.2i)
]
]
Concatenated organizationstripingVinumVinumstriping
An alternative mapping is to divide the address space into smaller, even-sized
components and store them sequentially on different devices. For example, the
first 256 sectors may be stored on the first disk, the next 256 sectors on the
next disk and so on. After filling the last disk, the process repeats until the
disks are full. This mapping is called striping or RAID-0,
RAIDRedundantArray of Inexpensive DisksRAID stands for Redundant Array of Inexpensive Disks and offers
various forms of fault tolerance.
though the latter term is somewhat misleading: it provides no redundancy.
Striping requires somewhat more effort to locate the data, and it can cause
additional I/O load where a transfer is spread over multiple disks, but it can
also provide a more constant load across the disks. Figure
illustrates the sequence in which storage units are allocated in a striped
organization.
h = .3i
dh = .02i
dw = .8i
down
[
[
boxht = h; boxwid = dw
move right 1i; down
A: box ht h "0"
B: box ht h "4"
C: box ht h "8"
D: box ht h "12"
E: box ht h "16"
F: box ht h "20"
A1: box at A+(dw*1.6,0) ht h "1"
B1: box ht h "5"
C1: box ht h "9"
D1: box ht h "13"
E1: box ht h "17"
F1: box ht h "21"
A2: box at A1+(dw*1.6,0) ht h "2"
B2: box ht h "6"
C2: box ht h "10"
D2: box ht h "14"
E2: box ht h "18"
F2: box ht h "22"
A3: box at A2+(dw*1.6,0) ht h "3"
B3: box ht h "7"
C3: box ht h "11"
D3: box ht h "15"
E3: box ht h "19"
F3: box ht h "23"
"Disk 1" at A.n+(0,.2i)
"Disk 2" at A1.n+(0,.2i)
"Disk 3" at A2.n+(0,.2i)
"Disk 4" at A3.n+(0,.2i)
]
]
Striped organizationData integrityThe final problem with current disks is that they are unreliable. Although disk
drive reliability has increased tremendously over the last few years, they are
still the most likely core component of a server to fail. When they do, the
results can be catastrophic: replacing a failed disk drive and restoring data to
it can take days.
mirroringVinumVinummirroringRAIDlevel 1RAID-1
The traditional way to approach this problem has been mirroring, keeping
two copies of the data on different physical hardware. Since the advent of the
RAID levels, this technique has also been called RAID level 1 or
RAID-1. Any write to the volume writes to both locations; a read can be
satisfied from either, so if one drive fails, the data is still available on the
other drive.
Mirroring has two problems:
The price. It requires twice as much disk storage as a non-redundant solution.
The performance impact. Writes must be performed to both drives, so they take
up twice the bandwidth of a non-mirrored volume. Reads do not suffer from a
performance penalty: it even looks as if they are faster.
RAID-5
An alternative solution is parity, implemented in the RAID levels 2, 3, 4
and 5. Of these, RAID-5 is the most interesting. As implemented in Vinum, it
is a variant on a striped organization which dedicates one block of each stripe
to parity of the other blocks: As implemented by Vinum, a RAID-5 plex is
similar to a striped plex, except that it implements RAID-5 by including a
parity block in each stripe. As required by RAID-5, the location of this parity
block changes from one stripe to the next. The numbers in the data blocks
indicate the relative block numbers.
h = .3i
dh = .02i
dw = .8i
down
[
[
boxht = h; boxwid = dw
move right 1i; down
A: box ht h "0"
B: box ht h "3"
C: box ht h "6"
D: box ht h "Parity" filled 0.2
E: box ht h "12"
F: box ht h "15"
A1: box at A+(dw*1.6,0) ht h "1"
B1: box ht h "4"
C1: box ht h "Parity" filled 0.2
D1: box ht h "9"
E1: box ht h "13"
F1: box ht h "16"
A2: box at A1+(dw*1.6,0) ht h "2"
B2: box ht h "Parity" filled 0.2
C2: box ht h "7"
D2: box ht h "10"
E2: box ht h "14"
F2: box ht h "Parity" filled 0.2
A3: box at A2+(dw*1.6,0) ht h "Parity" filled 0.2
B3: box ht h "5"
C3: box ht h "8"
D3: box ht h "11"
E3: box ht h "Parity" filled 0.2
F3: box ht h "17"
"Disk 1" at A.n+(0,.2i)
"Disk 2" at A1.n+(0,.2i)
"Disk 3" at A2.n+(0,.2i)
"Disk 4" at A3.n+(0,.2i)
]
]
RAID-5 organizationCompared to mirroring, RAID-5 has the advantage of requiring significantly less
storage space. Read access is similar to that of striped organizations, but
write access is significantly slower, approximately 25% of the read performance.
If one drive fails, the array can continue to operate in degraded mode: a read
from one of the remaining accessible drives continues normally, but a read from
the failed drive is recalculated from the corresponding block from all the
remaining drives.
Vinum objectsIn order to address these problems, vinum implements a four-level hierarchy of
objects:
volumeVinumVinumvolume
The most visible object is the virtual disk, called a volume. Volumes
have essentially the same properties as a UNIX disk drive, though there are some
minor differences. They have no size limitations.
plexVinumVinumplex
Volumes are composed of plexes, each of which represent the total address
space of a volume. This level in the hierarchy thus provides redundancy.
driveVinumVinumdrivesubdiskVinumVinumsubdisk
Since Vinum exists within the UNIX disk storage framework, it would be possible
to use UNIX partitions as the building block for multi-disk plexes, but in fact
this turns out to be too inflexible: UNIX disks can have only a limited number
of partitions. Instead, Vinum subdivides a single UNIX partition (the
drive) into contiguous areas called subdisks, which it uses as
building blocks for plexes.
Subdisks reside on Vinum drives, currently UNIX partitions. Vinum drives
can contain any number of subdisks. With the exception of a small area at the
beginning of the drive, which is used for storing configuration and state
information, the entire drive is available for data storage.
The following sections describe the way these objects provide the functionality
required of Vinum.
Volume size considerationsPlexes can include multiple subdisks spread over all drives in the Vinum
configuration. As a result, the size of an individual drive does not limit the
size of a plex, and thus of a volume.
Redundant data storageVinum
implements mirroring by attaching multiple plexes to a volume. Each plex is a
representation of the data in a volume. A volume may contain between one and
eight plexes.
Although a plex represents the complete data of a volume, it is possible for
parts of the representation to be physically missing, either by design (by not
defining a subdisk for parts of the plex) or by accident (as a result of the
failure of a drive). As long as at least one plex can provide the data for the
complete address range of the volume, the volume is fully functional.
Performance issuesVinum implements both concatenation and striping at the plex level:
A concatenated plex uses the address space of each subdisk in turn.
A striped plex stripes the data across each subdisk. The subdisks must
all have the same size, and there must be at least two subdisks in order to
distinguish it from a concatenated plex.
Which plex organization?The version of Vinum supplied with FreeBSD implements two kinds of
plex:
Concatenated plexes are the most flexible: they can contain any number of
subdisks, and the subdisks may be of different length. The plex may be extended
by adding additional subdisks.
They require less CPU time than striped
plexes, though the difference in CPU overhead
is not measurable. On the other hand, they are most susceptible to hot spots,
where one disk is very active and others are idle.
The greatest advantage of striped (RAID-0) plexes is that they reduce hot spots:
by choosing an optimum sized stripe (about 256 kB), you can even out the load on
the component drives. The disadvantages of this approach are (fractionally)
more complex code and restrictions on subdisks: they must be all the same size,
and extending a plex by adding new subdisks is so complicated that Vinum
currently does not implement it. Vinum imposes an additional, trivial
restriction: a striped plex must have at least two subdisks, since otherwise it
is indistinguishable from a concatenated plex.
Table summarizes the advantages and disadvantages of each plex
organization.
box,center,tab(#) ;
l | l | l | l | lw26 .
#Minimum#can#must be
Plex type#subdisks#add#equal#application
##subdisks#size
=
concatenated#1#yes#no#T{
Large data storage with maximum placement flexibility and
moderate performance.
T}
striped#2#no#yes#T{
High performance in combination with highly concurrent access.
T}
ty Type of disk. winchester specifies a non-removable hard disk. dt Type of controller, in this case SCSI se Number of bytes per sector. For current FreeBSD systems, this must be 512 nt Number of tracks per cylinder, in this case 15. ns Number of sectors per track, in this case 85. nc Number of cylinders, in this case 1658. rm Rotational speed of the disk, by default 3600. This is not absolutely essential. bx The size of ufs file system blocks in partition x, where x is a partition letter from a to h. See the discussion of partitions in , page
for more information. ox Offset (starting sector) of partition x, where x is a partition letter from a to h. See the discussion of partitions in , page
for more information. px Size in sectors of partition x. bx The size of ufs file system blocks in partition x. fx The size of ufs file system fragments in partition x. tx The type of the partition. This can be 4.2BSD (for ufs; the name is historical) or swap for a swap partition.
Vinum plex organizationsSome examplesconfigurationdatabaseVinumconfiguration database
Vinum maintains a configuration database which describes the objects
known to an individual system. Initially, the user creates the configuration
database from one or more configuration files with the aid of the
vinum(8) utility program. Vinum stores a copy of its configuration
database on each disk slice (which Vinum calls a device) under its
control. This database is updated on each state change, so that a restart
accurately restores the state of each Vinum object.
The configuration fileThe configuration file describes individual Vinum objects. The definition of a
simple volume might be:
drive a device /dev/da3h
volume myvol
plex org concat
sd length 512m drive a
This file describes four Vinum objects:
The drive line describes a disk partition (drive) and its
location relative to the underlying hardware. It is given the symbolic name
a. This separation of the symbolic names from the device names allows
disks to be moved from one location to another without confusion.
The volume line describes a volume. The only required attribute is the
name, in this case myvol.
The plex line defines a plex. The only required parameter is the
organization, in this case concat. No name is necessary: the system
automatically generates a name from the volume name by adding the suffix
\&.px, where x is the number of the plex in the volume.
Thus this plex will be called myvol.p0.
The sd line describes a subdisk. The minimum specifications are the
name of a drive on which to store it, and the length of the subdisk. As with
plexes, no name is necessary: the system automatically assigns names derived
from the plex name by adding the suffix .sx, where x is
the number of the subdisk in the plex. Thus Vinum gives this subdisk the name
myvol.p0.s0After processing this file, vinum(8) produces the following output:
vinum -> create config1
Configuration summary
Drives: 1 (4 configured)
Volumes: 1 (4 configured)
Plexes: 1 (8 configured)
Subdisks: 1 (16 configured)
D a State: up Device /dev/da3h Avail: 2061/2573 MB (80%)
V myvol State: up Plexes: 1 Size: 512 MB
P myvol.p0 C State: up Subdisks: 1 Size: 512 MB
S myvol.p0.s0 State: up PO: 0 B Size: 512 MB
This output shows the brief listing format of vinum(8). It is represented
graphically in Figure .
move right 1i
T: ellipse ht .3i wid 4i
line from T.e down 4i
line from T.w down 4i
B: arc rad 10i to T.e+(0,-4)
P1: S1: box ht 3i wid 1i "Subdisk" above "\s-2myvol.p0.s0\s0" below with .c at T.w+(2,-1.95)
"Plex 1" at S1.s+(0,-.3)
move down .17i; "\s-2myvol.p0\s0"
"\s-2\&0 MB\s0" at S1.ne+(.5,0)
"\s-2\&512 MB\s0" at S1.se+(.5,0)
A: arrow from S1.ne+(.1,0) to S1.se+(.1,0)
"\s-2volume" ljust at A.n+(.1,-.63)
"address" ljust at A.n+(.1,-.8)
"space\s0" ljust at A.n+(.1,-.97)
A simple Vinum volumeThis figure, and the ones which follow, represent a volume, which contains the
plexes, which in turn contain the subdisks. In this trivial example, the volume
contains one plex, and the plex contains one subdisk.
This particular volume has no specific advantage over a conventional disk
partition. It contains a single plex, so it is not redundant. The plex
contains a single subdisk, so there is no difference in storage allocation from
a conventional disk partition. The following sections illustrate various more
interesting configuration methods.
Increased resilience: mirroringThe resilience of a volume can be increased
by mirroring.
When laying out a mirrored volume, it is important to ensure that the subdisks
of each plex are on different drives, so that a drive failure will not take down
both plexes. The following configuration mirrors a volume:
drive b device /dev/da4h
volume mirror
plex org concat
sd length 512m drive a
plex org concat
sd length 512m drive b
In this example, it was not necessary to specify a definition of drive a
again, since Vinum keeps track of all objects in its configuration database.
After processing this definition, the configuration looks like:
Drives: 2 (4 configured)
Volumes: 2 (4 configured)
Plexes: 3 (8 configured)
Subdisks: 3 (16 configured)
D a State: up Device /dev/da3h Avail: 1549/2573 MB (60%)
D b State: up Device /dev/da4h Avail: 2061/2573 MB (80%)
V myvol State: up Plexes: 1 Size: 512 MB
V mirror State: up Plexes: 2 Size: 512 MB
P myvol.p0 C State: up Subdisks: 1 Size: 512 MB
P mirror.p0 C State: up Subdisks: 1 Size: 512 MB
P mirror.p1 C State: initializing Subdisks: 1 Size: 512 MB
S myvol.p0.s0 State: up PO: 0 B Size: 512 MB
S mirror.p0.s0 State: up PO: 0 B Size: 512 MB
S mirror.p1.s0 State: empty PO: 0 B Size: 512 MB
Figure shows the structure graphically.
move right 1i
T: ellipse ht .3i wid 4i
line from T.e down 4i
line from T.w down 4i
B: arc rad 10i to T.e+(0,-4)
P1: S1: box ht 3i wid 1i "Subdisk 1" above "\s-2mirror.p0.s0\s0" below with .c at T.c+(-1,-2)
"Plex 1" at S1.s+(0,-.3)
move down .17i; "\s-2mirror.p0\s0"
P2: S3: box ht 3i wid 1i "Subdisk 2" above "\s-2mirror.p1.s0\s0" below with .c at T.c+(1,-2)
"Plex 2" at S3.s+(0,-.3)
move down .17i; "\s-2mirror.p1\s0"
"\s-2\&0 MB\s0" at S1.ne+(.5,0)
"\s-2\&512 MB\s0" at S1.se+(.5,0)
A: arrow from S1.ne+(.1,0) to S1.se+(.1,0)
arrow from S1.se+(.1,0) to S1.ne+(.1,0)
"\s-2volume" ljust at A.n+(.1,-.63)
"address" ljust at A.n+(.1,-.8)
"space\s0" ljust at A.n+(.1,-.97)
A mirrored Vinum volumeIn this example, each plex contains the full 512 MB of address space. As in the
previous example, each plex contains only a single subdisk.
Optimizing performanceThe mirrored volume in the previous example is more resistant to failure than an
unmirrored volume, but its performance is less: each write to the volume
requires a write to both drives, using up a greater proportion of the total disk
bandwidth. Performance considerations demand a different approach: instead of
mirroring, the data is striped across as many disk drives as possible. The
following configuration shows a volume with a plex striped across four disk
drives:
drive c device /dev/da5h
drive d device /dev/da6h
volume stripe
plex org striped 512k
sd length 128m drive a
sd length 128m drive b
sd length 128m drive c
sd length 128m drive d
As before, it is not necessary to define the drives which are already known to
Vinum. After processing this definition, the configuration looks like:
Drives: 4 (4 configured)
Volumes: 3 (4 configured)
Plexes: 4 (8 configured)
Subdisks: 7 (16 configured)
D a State: up Device /dev/da3h Avail: 1421/2573 MB (55%)
D b State: up Device /dev/da4h Avail: 1933/2573 MB (75%)
D c State: up Device /dev/da5h Avail: 2445/2573 MB (95%)
D d State: up Device /dev/da6h Avail: 2445/2573 MB (95%)
V myvol State: up Plexes: 1 Size: 512 MB
V mirror State: up Plexes: 2 Size: 512 MB
V striped State: up Plexes: 1 Size: 512 MB
P myvol.p0 C State: up Subdisks: 1 Size: 512 MB
P mirror.p0 C State: up Subdisks: 1 Size: 512 MB
P mirror.p1 C State: initializing Subdisks: 1 Size: 512 MB
P striped.p1 State: up Subdisks: 1 Size: 512 MB
S myvol.p0.s0 State: up PO: 0 B Size: 512 MB
S mirror.p0.s0 State: up PO: 0 B Size: 512 MB
S mirror.p1.s0 State: empty PO: 0 B Size: 512 MB
S striped.p0.s0 State: up PO: 0 B Size: 128 MB
S striped.p0.s1 State: up PO: 512 kB Size: 128 MB
S striped.p0.s2 State: up PO: 1024 kB Size: 128 MB
S striped.p0.s3 State: up PO: 1536 kB Size: 128 MB
move right 1i
T: ellipse ht .3i wid 4i
line from T.e down 4i
line from T.w down 4i
B: arc rad 10i to T.e+(0,-4)
P1: S1: box ht .7i wid 1i with .c at T.w+(2,-0.825)
S2: box ht .7i wid 1i
S3: box ht .7i wid 1i
S4: box ht .7i wid 1i
"Plex 1" at S4.s+(0,-.3)
move down .17i; "\s-2striped.p0\s0"
"\s-2\&0 MB\s0" at S1.ne+(.5,0)
"\s-2\&512 MB\s0" at S4.se+(.5,0)
A: arrow from S1.ne+(.1,0) to S4.se+(.1,0)
"\s-2volume" ljust at A.n+(.1,-.63)
"address" ljust at A.n+(.1,-.8)
"space\s0" ljust at A.n+(.1,-.97)
"\s-2striped.p0.s0\s0" at S1.w-(.2,0) rjust
"\s-2striped.p0.s1\s0" at S2.w-(.2,0) rjust
"\s-2striped.p0.s2\s0" at S3.w-(.2,0) rjust
"\s-2striped.p0.s3\s0" at S4.w-(.2,0) rjust
box filled .1 wid 1i ht .1i at S1.n+(0, -.05)
box filled .2 wid 1i ht .1i at S1.n+(0, -.15)
box filled .3 wid 1i ht .1i at S1.n+(0, -.25)
box filled .4 wid 1i ht .1i at S1.n+(0, -.35)
box filled .5 wid 1i ht .1i at S1.n+(0, -.45)
box filled .6 wid 1i ht .1i at S1.n+(0, -.55)
box filled .7 wid 1i ht .1i at S1.n+(0, -.65)
box filled .1 wid 1i ht .1i at S2.n+(0, -.05)
box filled .2 wid 1i ht .1i at S2.n+(0, -.15)
box filled .3 wid 1i ht .1i at S2.n+(0, -.25)
box filled .4 wid 1i ht .1i at S2.n+(0, -.35)
box filled .5 wid 1i ht .1i at S2.n+(0, -.45)
box filled .6 wid 1i ht .1i at S2.n+(0, -.55)
box filled .7 wid 1i ht .1i at S2.n+(0, -.65)
box filled .1 wid 1i ht .1i at S3.n+(0, -.05)
box filled .2 wid 1i ht .1i at S3.n+(0, -.15)
box filled .3 wid 1i ht .1i at S3.n+(0, -.25)
box filled .4 wid 1i ht .1i at S3.n+(0, -.35)
box filled .5 wid 1i ht .1i at S3.n+(0, -.45)
box filled .6 wid 1i ht .1i at S3.n+(0, -.55)
box filled .7 wid 1i ht .1i at S3.n+(0, -.65)
box filled .1 wid 1i ht .1i at S4.n+(0, -.05)
box filled .2 wid 1i ht .1i at S4.n+(0, -.15)
box filled .3 wid 1i ht .1i at S4.n+(0, -.25)
box filled .4 wid 1i ht .1i at S4.n+(0, -.35)
box filled .5 wid 1i ht .1i at S4.n+(0, -.45)
box filled .6 wid 1i ht .1i at S4.n+(0, -.55)
box filled .7 wid 1i ht .1i at S4.n+(0, -.65)
A striped Vinum volumeThis volume is represented in Figure . The darkness of the
stripes indicates the position within the plex address space: the lightest
stripes come first, the darkest last.
Resilience and performance
With sufficient hardware, it is possible to build volumes which show both
increased resilience and increased performance compared to standard UNIX
partitions.
A
typical configuration file might be:
volume raid10
plex org striped 512k
sd length 102480k drive a
sd length 102480k drive b
sd length 102480k drive c
sd length 102480k drive d
sd length 102480k drive e
plex org striped 512k
sd length 102480k drive c
sd length 102480k drive d
sd length 102480k drive e
sd length 102480k drive a
sd length 102480k drive b
The subdisks of the second plex are offset by two drives from those of the first
plex: this helps ensure that writes do not go to the same subdisks even if a
transfer goes over two drives.
Figure represents the structure of this volume.
move right 1i
T: ellipse ht .3i wid 4i
line from T.e down 4i
line from T.w down 4i
B: arc rad 10i to T.e+(0,-4)
P1: S1: box ht .6i wid 1i with .c at T.w+(1.3,-0.825)
S2: box ht .6i wid 1i
S3: box ht .6i wid 1i
S4: box ht .6i wid 1i
S5: box ht .6i wid 1i
"Plex 1" at S5.s+(0,-.3)
move down .17i; "\s-2striped.p0\s0"
P1: S11: box ht .6i wid 1i with .c at T.w+(3.3,-0.825)
S12: box ht .6i wid 1i
S13: box ht .6i wid 1i
S14: box ht .6i wid 1i
S15: box ht .6i wid 1i
"Plex 2" at S15.s+(0,-.3)
move down .17i; "\s-2striped.p1\s0"
"\s-2.p0.s0\s0" at S1.w-(.2,0) rjust
"\s-2.p0.s1\s0" at S2.w-(.2,0) rjust
"\s-2.p0.s2\s0" at S3.w-(.2,0) rjust
"\s-2.p0.s3\s0" at S4.w-(.2,0) rjust
"\s-2.p0.s4\s0" at S5.w-(.2,0) rjust
"\s-2.p1.s0\s0" at S11.w-(.2,0) rjust
"\s-2.p1.s1\s0" at S12.w-(.2,0) rjust
"\s-2.p1.s2\s0" at S13.w-(.2,0) rjust
"\s-2.p1.s3\s0" at S14.w-(.2,0) rjust
"\s-2.p1.s4\s0" at S15.w-(.2,0) rjust
box filled .1 wid 1i ht .1i at S1.n+(0, -.05)
box filled .2 wid 1i ht .1i at S1.n+(0, -.15)
box filled .3 wid 1i ht .1i at S1.n+(0, -.25)
box filled .4 wid 1i ht .1i at S1.n+(0, -.35)
box filled .5 wid 1i ht .1i at S1.n+(0, -.45)
box filled .6 wid 1i ht .1i at S1.n+(0, -.55)
box filled .1 wid 1i ht .1i at S2.n+(0, -.05)
box filled .2 wid 1i ht .1i at S2.n+(0, -.15)
box filled .3 wid 1i ht .1i at S2.n+(0, -.25)
box filled .4 wid 1i ht .1i at S2.n+(0, -.35)
box filled .5 wid 1i ht .1i at S2.n+(0, -.45)
box filled .6 wid 1i ht .1i at S2.n+(0, -.55)
box filled .1 wid 1i ht .1i at S3.n+(0, -.05)
box filled .2 wid 1i ht .1i at S3.n+(0, -.15)
box filled .3 wid 1i ht .1i at S3.n+(0, -.25)
box filled .4 wid 1i ht .1i at S3.n+(0, -.35)
box filled .5 wid 1i ht .1i at S3.n+(0, -.45)
box filled .6 wid 1i ht .1i at S3.n+(0, -.55)
box filled .1 wid 1i ht .1i at S4.n+(0, -.05)
box filled .2 wid 1i ht .1i at S4.n+(0, -.15)
box filled .3 wid 1i ht .1i at S4.n+(0, -.25)
box filled .4 wid 1i ht .1i at S4.n+(0, -.35)
box filled .5 wid 1i ht .1i at S4.n+(0, -.45)
box filled .6 wid 1i ht .1i at S4.n+(0, -.55)
box filled .1 wid 1i ht .1i at S5.n+(0, -.05)
box filled .2 wid 1i ht .1i at S5.n+(0, -.15)
box filled .3 wid 1i ht .1i at S5.n+(0, -.25)
box filled .4 wid 1i ht .1i at S5.n+(0, -.35)
box filled .5 wid 1i ht .1i at S5.n+(0, -.45)
box filled .6 wid 1i ht .1i at S5.n+(0, -.55)
box filled .1 wid 1i ht .1i at S11.n+(0, -.05)
box filled .2 wid 1i ht .1i at S11.n+(0, -.15)
box filled .3 wid 1i ht .1i at S11.n+(0, -.25)
box filled .4 wid 1i ht .1i at S11.n+(0, -.35)
box filled .5 wid 1i ht .1i at S11.n+(0, -.45)
box filled .6 wid 1i ht .1i at S11.n+(0, -.55)
box filled .1 wid 1i ht .1i at S12.n+(0, -.05)
box filled .2 wid 1i ht .1i at S12.n+(0, -.15)
box filled .3 wid 1i ht .1i at S12.n+(0, -.25)
box filled .4 wid 1i ht .1i at S12.n+(0, -.35)
box filled .5 wid 1i ht .1i at S12.n+(0, -.45)
box filled .6 wid 1i ht .1i at S12.n+(0, -.55)
box filled .1 wid 1i ht .1i at S13.n+(0, -.05)
box filled .2 wid 1i ht .1i at S13.n+(0, -.15)
box filled .3 wid 1i ht .1i at S13.n+(0, -.25)
box filled .4 wid 1i ht .1i at S13.n+(0, -.35)
box filled .5 wid 1i ht .1i at S13.n+(0, -.45)
box filled .6 wid 1i ht .1i at S13.n+(0, -.55)
box filled .1 wid 1i ht .1i at S14.n+(0, -.05)
box filled .2 wid 1i ht .1i at S14.n+(0, -.15)
box filled .3 wid 1i ht .1i at S14.n+(0, -.25)
box filled .4 wid 1i ht .1i at S14.n+(0, -.35)
box filled .5 wid 1i ht .1i at S14.n+(0, -.45)
box filled .6 wid 1i ht .1i at S14.n+(0, -.55)
box filled .1 wid 1i ht .1i at S15.n+(0, -.05)
box filled .2 wid 1i ht .1i at S15.n+(0, -.15)
box filled .3 wid 1i ht .1i at S15.n+(0, -.25)
box filled .4 wid 1i ht .1i at S15.n+(0, -.35)
box filled .5 wid 1i ht .1i at S15.n+(0, -.45)
box filled .6 wid 1i ht .1i at S15.n+(0, -.55)
A mirrored, striped Vinum volumeObject namingAs described above, Vinum assigns default names to plexes and subdisks, although
they may be overridden. Overriding the default names is not recommended:
experience with the VERITAS\(rg volume manager, which allows arbitary naming of
objects, has shown that this flexibility does not bring a significant advantage,
and it can cause confusion.
Names may contain any non-blank character, but it is recommended to restrict
them to letters, digits and the underscore characters. The names of volumes,
plexes and subdisks may be up to 64 characters long, and the names of drives may
up to 32 characters long.
/dev/vinum
Vinum objects are assigned device nodes in the hierarchy /dev/vinum. The
configuration shown above would cause Vinum to create the following device
nodes:
/dev/vinum/control
The control devices /dev/vinum/control and /dev/vinum/controld,
which are used by vinum(8) and the Vinum dæmon respectively.
Block and character device entries for each volume. These are the main devices
used by Vinum. The block device names are the name of the volume, while the
character device names follow the BSD tradition of prepending the letter
r to the name. Thus the configuration above would include the block
devices /dev/vinum/myvol, /dev/vinum/mirror,
/dev/vinum/striped, /dev/vinum/raid5 and /dev/vinum/raid10,
and the character devices /dev/vinum/rmyvol, /dev/vinum/rmirror,
/dev/vinum/rstriped, /dev/vinum/rraid5 and
/dev/vinum/rraid10. There is obviously a problem here: it is possible to
have two volumes called r and rr, but there will be a conflict
creating the device node /dev/vinum/rr: is it a character device for
volume r or a block device for volume rr? Currently Vinum does
not address this conflict: the first-defined volume will get the name.
A directory /dev/vinum/drive with entries for each drive. These entries
are in fact symbolic links to the corresponding disk nodes.
A directory /dev/vinum/volume with entries for each volume. It contains
subdirectories for each plex, which in turn contain subdirectories for their
component subdisks.
The directories /dev/vinum/plex and /dev/vinum/sd,
/dev/vinum/rsd, which contain block device nodes for each plex and block
and character device nodes respectively for subdisk.
For example, consider the following configuration file:
drive drive1 device /dev/sd1h
drive drive2 device /dev/sd2h
drive drive3 device /dev/sd3h
drive drive4 device /dev/sd4h
volume s64 setupstate
plex org striped 64k
sd length 100m drive drive1
sd length 100m drive drive2
sd length 100m drive drive3
sd length 100m drive drive4
After processing this file, vinum(8) creates the following structure in
/dev/vinum:
brwx------ 1 root wheel 25, 0x40000001 Apr 13 16:46 Control
brwx------ 1 root wheel 25, 0x40000002 Apr 13 16:46 control
brwx------ 1 root wheel 25, 0x40000000 Apr 13 16:46 controld
drwxr-xr-x 2 root wheel 512 Apr 13 16:46 drive
drwxr-xr-x 2 root wheel 512 Apr 13 16:46 plex
crwxr-xr-- 1 root wheel 91, 2 Apr 13 16:46 rs64
drwxr-xr-x 2 root wheel 512 Apr 13 16:46 rsd
drwxr-xr-x 2 root wheel 512 Apr 13 16:46 rvol
brwxr-xr-- 1 root wheel 25, 2 Apr 13 16:46 s64
drwxr-xr-x 2 root wheel 512 Apr 13 16:46 sd
drwxr-xr-x 3 root wheel 512 Apr 13 16:46 vol
/dev/vinum/drive:
total 0
lrwxr-xr-x 1 root wheel 9 Apr 13 16:46 drive1 -> /dev/sd1h
lrwxr-xr-x 1 root wheel 9 Apr 13 16:46 drive2 -> /dev/sd2h
lrwxr-xr-x 1 root wheel 9 Apr 13 16:46 drive3 -> /dev/sd3h
lrwxr-xr-x 1 root wheel 9 Apr 13 16:46 drive4 -> /dev/sd4h
/dev/vinum/plex:
total 0
brwxr-xr-- 1 root wheel 25, 0x10000002 Apr 13 16:46 s64.p0
/dev/vinum/rsd:
total 0
crwxr-xr-- 1 root wheel 91, 0x20000002 Apr 13 16:46 s64.p0.s0
crwxr-xr-- 1 root wheel 91, 0x20100002 Apr 13 16:46 s64.p0.s1
crwxr-xr-- 1 root wheel 91, 0x20200002 Apr 13 16:46 s64.p0.s2
crwxr-xr-- 1 root wheel 91, 0x20300002 Apr 13 16:46 s64.p0.s3
/dev/vinum/rvol:
total 0
crwxr-xr-- 1 root wheel 91, 2 Apr 13 16:46 s64
/dev/vinum/sd:
total 0
brwxr-xr-- 1 root wheel 25, 0x20000002 Apr 13 16:46 s64.p0.s0
brwxr-xr-- 1 root wheel 25, 0x20100002 Apr 13 16:46 s64.p0.s1
brwxr-xr-- 1 root wheel 25, 0x20200002 Apr 13 16:46 s64.p0.s2
brwxr-xr-- 1 root wheel 25, 0x20300002 Apr 13 16:46 s64.p0.s3
/dev/vinum/vol:
total 1
brwxr-xr-- 1 root wheel 25, 2 Apr 13 16:46 s64
drwxr-xr-x 3 root wheel 512 Apr 13 16:46 s64.plex
/dev/vinum/vol/s64.plex:
total 1
brwxr-xr-- 1 root wheel 25, 0x10000002 Apr 13 16:46 s64.p0
drwxr-xr-x 2 root wheel 512 Apr 13 16:46 s64.p0.sd
/dev/vinum/vol/s64.plex/s64.p0.sd:
total 0
brwxr-xr-- 1 root wheel 25, 0x20000002 Apr 13 16:46 s64.p0.s0
brwxr-xr-- 1 root wheel 25, 0x20100002 Apr 13 16:46 s64.p0.s1
brwxr-xr-- 1 root wheel 25, 0x20200002 Apr 13 16:46 s64.p0.s2
brwxr-xr-- 1 root wheel 25, 0x20300002 Apr 13 16:46 s64.p0.s3
Although it is recommended that plexes and subdisks should not be allocated
specific names, Vinum drives must be named. This makes it possible to move a
drive to a different location and still recognize it automatically. Drive names
may be up to 32 characters long.
Creating file systemsnewfs
Volumes appear to the system to be identical to disks, with one exception.
Unlike UNIX drives, Vinum does not partition volumes, which thus do not contain
a partition table. This has required modification to some disk utilities,
notably newfs, which previously tried to interpret the last letter of a
Vinum volume name as a partition identifier. For example, a disk drive may have
a name like /dev/wd0a or /dev/da2h. These names represent the
first partition (a) on the first (0) IDE disk (wd) and the eight
partition (h) on the third (2) SCSI disk (da) respectively. By
contrast, a Vinum volume might be called /dev/vinum/concat, a name which
has no relationship with a partition name.
Normally, newfs(8) interprets the name of the disk and complains if it
cannot understand it. For example:
# newfs /dev/vinum/concat
newfs: /dev/vinum/concat: can't figure out file system partition
In order to create a file system on this volume, use the -v option to
newfs(8):
# newfs -v /dev/vinum/concatConfiguring VinumThe GENERIC kernel does not contain Vinum. It's possible to build a
special kernel which includes Vinum, but this is not recommended. The standard
way to start Vinum is as a kld (see page for more details). You
don't even need to use kldload for Vinum: when you start vinum(8),
it checks whether the module has been loaded, and if it isn't, it loads it
automatically.
StartupVinum stores configuration information on the disk slices in essentially the
same form as in the configuration files. When reading from the configuration
database, Vinum recognizes a number of keywords which are not allowed in the
configuration files. For example, a disk configuration might contain the
following text:
volume myvol state up
volume bigraid state down
plex name myvol.p0 state up org concat vol myvol
plex name myvol.p1 state up org concat vol myvol
plex name myvol.p2 state init org striped 512b vol myvol
plex name bigraid.p0 state initializing org raid5 512b vol bigraid
sd name myvol.p0.s0 drive a plex myvol.p0 state up len 1048576b driveoffset 265b plexo
ffset 0b
sd name myvol.p0.s1 drive b plex myvol.p0 state up len 1048576b driveoffset 265b plexo
ffset 1048576b
sd name myvol.p1.s0 drive c plex myvol.p1 state up len 1048576b driveoffset 265b plexo
ffset 0b
sd name myvol.p1.s1 drive d plex myvol.p1 state up len 1048576b driveoffset 265b plexo
ffset 1048576b
sd name myvol.p2.s0 drive a plex myvol.p2 state init len 524288b driveoffset 1048841b
plexoffset 0b
sd name myvol.p2.s1 drive b plex myvol.p2 state init len 524288b driveoffset 1048841b
plexoffset 524288b
sd name myvol.p2.s2 drive c plex myvol.p2 state init len 524288b driveoffset 1048841b
plexoffset 1048576b
sd name myvol.p2.s3 drive d plex myvol.p2 state init len 524288b driveoffset 1048841b
plexoffset 1572864b
sd name bigraid.p0.s0 drive a plex bigraid.p0 state initializing len 4194304b driveoff
set 1573129b plexoffset 0b
sd name bigraid.p0.s1 drive b plex bigraid.p0 state initializing len 4194304b driveoff
set 1573129b plexoffset 4194304b
sd name bigraid.p0.s2 drive c plex bigraid.p0 state initializing len 4194304b driveoff
set 1573129b plexoffset 8388608b
sd name bigraid.p0.s3 drive d plex bigraid.p0 state initializing len 4194304b driveoff
set 1573129b plexoffset 12582912b
sd name bigraid.p0.s4 drive e plex bigraid.p0 state initializing len 4194304b driveoff
set 1573129b plexoffset 16777216b
The obvious differences here are the presence of explicit location information
and naming (both of which are also allowed, but discouraged, for use by the
user) and the information on the states (which are not available to the user).
Vinum does not store information about drives in the configuration information:
it finds the drives by scanning the configured disk drives for partitions with a
Vinum label. This enables Vinum to identify drives correctly even if they have
been assigned different UNIX drive IDs.
Automatic startupIn order to start Vinum automatically when you boot the system, ensure that you
have the following line in your /etc/rc.conf:
start_vinum="YES" # set to YES to start vinum
If you don't have a file /etc/rc.conf, create one with this content. This
will cause the system to load the Vinum kld at startup, and to start any objects
mentioned in the configuration. This is done before mounting file systems, so
it's possible to automatically fsck and mount file systems on Vinum
volumes.
When you start Vinum with the vinum\ start command, Vinum reads the
configuration database from one of the Vinum drives. Under normal
circumstances, each drive contains an identical copy of the configuration
database, so it does not matter which drive is read. After a crash, however,
Vinum must determine which drive was updated most recently and read the
configuration from this drive. It then updates the configuration if necessary
from progressively older drives.
Tapes, backups and floppy disksIn the last chapter, we looked at hard disks. In this chapter, we'll consider
how to guard against data loss, and how to transfer data from one location to
another. These are functions that UNIX traditionally performs with tapes, and
we'll look at them in the next sections. Because FreeBSD runs on PCs, however,
you can't completely escape floppy disks, though it would be an excellent idea.
We'll look at floppies on page .
Backing up your dataBackingup your data
No matter how reliable your system, you are never completely protected against
loss of data. The most common reasons are hardware failure and human error.
By comparison, it's very seldom that a software error causes data loss,
but this, too, can happen.
archivetarballtarcommandcommandtar
UNIX talks about archives, which are copies of disk data in a form
suitable for writing on a serial medium such as tape. You can, however, write
them to disk files as well, and that's what people do when they want to move a
source tree from one system to another. You'll also hear the term
tarball for an archive made by the tar program, which we will
discuss below.
What backup medium?Traditionally, PCs use floppy disks as a removable storage medium. We'll look
at floppies below, but you can sum the section up in one statement:
Don't use floppy disks.
Floppy disks are particularly unsuited as a backup medium for modern computers.
Consider a typical system with a 2 GB hard disk. Storing 2 GB of data on
floppies requires about 1,500 floppies, which, at $0.30 each, would cost you
$450. Copying the data to a floppy takes about 50 seconds per floppy, so the
raw backup time would be about 21 hours, plus the time it takes you to change
the floppies, which could easily take another 3 or more hours. During this time
you have to sit by the computer playing disk jockey, a total of three days' work
during which you could hardly do anything else. When you try to read in the
data again, there's a virtual certainty that one of the floppies will have a
data error, especially if you read them with a different drive.
By contrast, a QIC-525 tape cartridge will store 500 MB of data for about $20.
The media for the same operation would cost $80, and it will take about 6 hours,
during which you just need to change the tapes three times. A single DDS or
Exabyte cassette stores several gigabytes and costs about $6. The backup time
for 2 GB is about 90 minutes, and the operation can be performed completely
unattended.
You can currently get a number of relatively cheap tape drives which can connect
to your floppy controller. Don't buy them. FreeBSD does have some kind of
support for them, but it's rudimentary, and the drives themselves are unreliable
and slow. There's no point in making a backup if you can't read the data in
again when you need it.
Tape devicestapedevice/dev/nrsa0
FreeBSD tape devices have names like /dev/nrsa0 (see page ).
Each letter has a significance:
tapenon-rewindingtaperewind device/dev/rsa0n means non-rewinding. When the process which accesses the tape
closes it, the tape remains at the same position. This is inconvenient if you
want to remove the tape (before which you should rewind it), but it's the only
way if you want to handle multiple archives on the tape. The name of the
corresponding rewind device has no n (for example, the rewind
device corresponding to /dev/nrsa0 is /dev/rsa0). A rewind
device rewinds the tape when it is closed.
r stands for raw, in other words a character device. Modern tape
devices are always raw.
/dev/rwst0sa stands for serial access, and is always SCSI. You can also
have a QIC-02 interface tape, which would be called /dev/rwst0.
0 is the unit number. If you have more than one tape, the next
will be called /dev/nrsa1, and so on.
Backup softwarebackupsoftware
FreeBSD does not require special ``backup software''. The base operating system
supplies all the programs you need. The tape driver is part of the kernel, and
the system includes a number of backup programs. The most popular are:
tarcommandcommandtartapearchivertar, the tape archiver, has been around longer than anybody can
remember. It is particularly useful for data exchange, since everybody has it.
There are even versions of tar for Microsoft platforms. It's also an
adequate backup program.
cpiocommandcommandcpiocpio
is an alternative backup program. About its only advantage over
tar is that it can read cpio format archives.
paxcommandcommandpaxpax is another alternative backup program. It has the advantage that it
can also read and write tar and cpio archives.
dumpcommandcommanddumpdump is geared more towards backups than towards archiving. It can
maintain multiple levels of backup, each of which backs up only those files
which have changed since the last backup of the next higher (numerically lower)
level. It is less suited towards data exchange, since its formats are very
specific to BSD.
amandacommandcommandamandaamanda, in the Ports Collection, is another popular backup program.
Backup strategies are frequently the subject of religious wars. I personally
find that tar does everything I want, but you'll find plenty of people
who will recommend dump or amanda instead. In the following
section, we'll look at the basics of using tar. See the man page
dump(8) for more information on dump.
tartarcommandcommandtartapearchivertar, the tape archiver, performs the following functions:
archive
Creating an archive, which can be a serial device such as a tape, or a
disk file, from the contents of a number of directories.
Extracting files from an archive.
Listing the contents of an archive.
gzipcommandcommandgziptar does not compress the data. The resulting archive is slightly
larger than the sum of the files which it contains, since it also contains a
certain amount of header information. You can, however, use the gzip
program to compress a tar archive, and tar will invoke it for
you automatically. The resultant archives are typically 80% smaller than the
constituent files.
Creating a tar archivecreatinga tar archivetarcreating an archive
Create an archive with the c option. Unlike most UNIX programs,
tar does not require a hyphen (-) in front of the options. For
example, to save your complete kernel source tree, you could write:
# tar cvf source-archive.tar /usr/src/sys
tar: Removing leading / from absolute path names in the archive.
usr/src/sys/
usr/src/sys/CVS/
usr/src/sys/CVS/Root
usr/src/sys/CVS/Repository
usr/src/sys/CVS/Entries
usr/src/sys/compile/
usr/src/sys/compile/CVS/
\&(etc)The parameters have the following meaning:
cvf are the options. c stands for create an archive,
v specifies verbose operation (in this case, this causes
tar to produce the list of files being archived), and f
specifies that the next parameter is the name of the archive file.
source-archive.tar is the name of the archive. In this case, it's a
disk file.
/usr/src/sys is the name of the directory to archive. tar
archives all files in the directory, including most devices. For historical
reasons, tar can't back up devices with minor numbers greater than
65536, and changing the format would make it incompatible with other systems.
The message on the first line (Removing leading / ...) indicates that,
although the directory name was specified as /usr/src/sys, tar
treats it as usr/src/sys. This makes it possible to restore the files
into another directory at a later time.
You can back up to tape in exactly the same way:
# tar cvf /dev/nrsa0 /usr/src/sysThere is a simpler way, however: if you don't specify a file name, tar
looks for the environment variable TAPE. If it finds it, it interprets
it as the name of the tape drive. You can make things a lot easier by setting
the following line in the configuration file for your shell (.profile
for sh, .bashrc for bash, .login for csh
and tcsh):
TAPE=/dev/nrsa0 export TAPE for sh and bash
setenv TAPE /dev/nrsa0 for csh and tcshAfter this, the previous example simplifies to:
# tar cv /usr/src/sysListing an archivelistinga tar archivetarlisting an archive
To list an archive, use the option t:
# tar t from tape
usr/src/sys/
usr/src/sys/CVS/
usr/src/sys/CVS/Root
usr/src/sys/CVS/Repository
usr/src/sys/CVS/Entries
usr/src/sys/compile/
usr/src/sys/compile/CVS/
usr/src/sys/compile/CVS/Root
\&(etc)
# tar tvf source-archive.tar from disk
drwxrwxrwx root/bin 0 Oct 25 15:07 1997 usr/src/sys/
drwxrwxrwx root/bin 0 Oct 25 15:08 1997 usr/src/sys/CVS/
-rw-rw-rw- root/wheel 9 Sep 30 23:13 1996 usr/src/sys/CVS/Root
-rw-rw-rw- root/wheel 17 Sep 30 23:13 1996 usr/src/sys/CVS/Repository
-rw-rw-rw- root/bin 346 Oct 25 15:08 1997 usr/src/sys/CVS/Entries
drwxrwxrwx root/bin 0 Oct 27 17:11 1997 usr/src/sys/compile/
drwxrwxrwx root/bin 0 Jul 30 10:52 1997 usr/src/sys/compile/CVS/
\&(etc)This example shows the use of the v (verbose) option with
t. If you don't use it, tar displays only the names of the
files (first example, from tape). If you do use it, tar also displays
the permissions, ownerships, sizes and last modification date in a form
reminiscent of ls -l (second example, which is from the disk file
source-archive.tar).
Extracting filestarextracting files
To extract a file from the archive, use the x option:
# tar xv usr/src/sys/Makefile from tape
usr/src/sys/Makefile confirms that the file was extractedAs with the c option, if you don't use the v option, tar
will not list any file names. If you omit the names of the files to extract,
tar will extract the complete archive.
Compressed archivestarcompressed archivesgzipcommandcommandgziptarcommandcommandtar
You can use the gzip program in combination with tar by
specifying the z option. For example, to create the archive
source-archive.tar.gz in compressed format, write:
# tar czf source-archive.tar.gz /usr/src/sysYou must specify the z option when listing or extracting
compressed archives, and you must not do so when listing or extracting
non-compressed archives. Otherwise you will get messages like:
# tar tzvf source-archive.tar
gzip: stdin: not in gzip format
tar: child returned status 1
# tar tvf source-archive.tar.gz
tar: only read 2302 bytes from archive source-archive.tar.gz
Using floppy disks under FreeBSDfloppydisks
I don't like floppy disks. UNIX doesn't like floppy disks. Probably you don't
like floppy disks either, but we occasionally have to live with them.
FreeBSD requires floppy disks for one thing only: for initially booting the
system. This is only because this is still the only way to boot most PC which
don't have an operating system on disk. We've already seen that they're
unsuitable for archival data storage and data transfer. For this purpose,
FreeBSD uses tapes and CD-ROMs, which are much more reliable, and for the data
volumes involved in modern computers, they're cheaper and faster.
So why use floppies? The only good reasons are:
You have a floppy drive. You may not have a tape drive. Before you go out and
buy all those floppies, though, consider that it might be cheaper to buy a tape
drive and some tapes instead.
You need to exchange data with people using Microsoft platforms, or with people
who don't have the same kind of tape as you do.
In the following sections, we'll look at how to handle floppies under FreeBSD,
with particular regard to coexisting with Microsoft. Here's an overview:
Always format floppies before using them on your system for the first time, even
if they've been formatted before. We'll look at that in the next section.
Just occasionally, you need to create a UNIX file system on floppy. We'll look
at that on page
When exchanging with Microsoft users, you need to create a Microsoft file system. We'll
look at that on page .
When exchanging with other UNIX users, whether FreeBSD or not, use tar or
cpio. We'll look at how to do that on page .
Formatting a floppyformattingfloppy disksfloppydisksFORMATMS-DOS commandMS-DOScommandlow-levelformatformatlow-levelhigh-levelformatformathigh-levelfdformatcommandcommandfdformat
Even if you buy preformatted floppies, it's a good idea to reformat them. Track
alignment can vary significifantly between individual floppy drives, and the
result can be that your drive doesn't write quite on top of the pre-written
tracks. I have seen read failure rates as high as 2% on pre-formatted floppies:
in other words, after writing 100 floppies with valuable data, the chances are
that two of them will have read errors. You can reduce this problem by
reformatting the floppy in the drive in which it is to be written, but you can't
eliminate it.
FORMATMS-DOS commandMS-DOScommandlow-levelformathigh-levelformatformatlow-levelformathigh-levelfdformatcommandcommandfdformat
On Microsoft platforms, you format floppies with the FORMAT program,
which performs two different functions when invoked on floppies: it performs
both a low-level format, which re-writes the physical sector
information, and then it performs a high-level format, which writes the
information necessary for Microsoft platforms to use it as a file system. UNIX
calls the second operation creating a file system. It's not always necessary to
have a file system on the diskette—in fact, as we'll see, it can be a
disadvantage. In addition, FreeBSD offers different kinds of file system, so it
performs the two functions with different programs. In this section, we'll look
at fdformat, which performs the low-level format. We'll look at how to
create a ufs or Microsoft file system in the next section.
/dev/rfd0
To format the first floppy drive, /dev/rfd0, you would enter:
$ fdformat /dev/rfd0
Format 1440K floppy `/dev/rfd0'? (y/n): y
Processing ----------------------------------------
Each of the hyphen characters (-) represent two tracks. As the format
proceeds, they change individually to an F (Format) and then to
V (Verify) in turn, so at the end the line reads
Processing VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV done.
File systems on floppyFilesystems on floppyufs/etc/disktab
It's possible to use floppies as file systems under FreeBSD. You can create a
ufs file system on a floppy just like on a hard disk. This is not
necessarily a good idea: the ufs file system is designed for
performance, not maximum capacity. By default, it doesn't use the last 8% of
disk space, and it includes a lot of structure information which further reduces
the space available on the disk. Here's an example of creating a file system,
mounting it on the directory /A, and listing the remaining space available
on an empty 3\(12" floppy. We use the disktab approach to
labelling the disk, as we saw on page
/etc/disktab/etc/disktab does have labels for floppy disks: use fd1440 for a
3\(12" 1.44 MB floppy, and fd1200 for a 5\(14" 1.2 MB
floppy:
# disklabel -w -r /dev/rfd0 fd1440 label the floppy
# disklabel -r /dev/rfd0 and list the information
# /dev/rfd0:
type: unknown
disk: fd1440
label:
flags:
bytes/sector: 512
sectors/track: 18
tracks/cylinder: 2
sectors/cylinder: 36
cylinders: 80
sectors/unit: 2880
rpm: 300
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0
3 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 2880 0 unused 512 4096 # (Cyl. 0 - 79)
b: 2880 0 unused 512 4096 # (Cyl. 0 - 79)
c: 2880 0 unused 512 4096 # (Cyl. 0 - 79)
# newfs /dev/rfd0 create a new file system
Warning: Block size restricts cylinders per group to 6.
Warning: 1216 sector(s) in last cylinder unallocated
/dev/rfd0.1440: 2880 sectors in 1 cylinders of 1 tracks, 4096 sectors
1.4MB in 1 cyl groups (6 c/g, 12.00MB/g, 736 i/g)
super-block backups (for fsck -b #) at:
32,
# mount /dev/fd0 /A mount the floppy on /A
# df /A display the space available
Filesystem 1024-blocks Used Avail Capacity Mounted on
/dev/fd0 1319 0 1213 0% /mnt
Let's look at this in a little more detail:
disklabelcommandcommanddisklabelnewfscommandcommandnewfsufs
The first invocation of disklabel, with the -w option, writes a
disk label to the floppy, which supplies enough information for newfs to
create a ufs file system on it.
The second invocation of disklabel, just with the -r option, lists
the information written by the first invocation. This isn't necessary for
creating the file system, but it helps to check that the disk is labelled
correctly.
newfs creates the ufs file system on the floppy.
mountcommandcommandmount
We have already seen mount on page . In this case, we use it
to mount the floppy on the file system /A.
dfcommandcommanddf
The df program shows the maximum and available space on a file system.
By default, df displays usage in blocks of 512 bytes, an inconvenient
size. In this example, the environment variable BLOCKSIZE was set to
1024 to display the usage in 1 kB (1024 byte) blocks. See page
for more details of environment variables.
tunefscommandcommandtunefs
The output of df looks terrible! Our floppy only has 1213 kB left for
normal user data, even though there is nothing on it and even df claims
that it can really store 1319 kB. This is because ufs keeps a default
of 8% of the space free for performance reasons. You can change this, however,
with tunefs, the file system tune program:
To quote the man page: You can tune a file system, but you can't tune a
fish.
# umount /A first unmount the floppy
# tunefs -m 0 /dev/rfd0 and change the minimum free to 0
tunefs: minimum percentage of free space changes from 8% to 0%
tunefs: should optimize for space with minfree < 8%
# mount /dev/fd0 /A mount the file system again
# df /A and take another look
Filesystem 1024-blocks Used Avail Capacity Mounted on
/dev/fd0 1319 0 1319 0% /A
Still, this is a far cry from the claimed data storage of a Microsoft disk. In
fact, Microsoft disks can't store the full 1.4 MB either, since it also needs
space for storing directories and allocation tables. The moral of the story:
only use file systems on floppy if you don't have any alternative.
Microsoft file systemsMicrosoftfile systems
To create an MS-DOS file system, use the mkdosfs command:
$ mkdosfs -f 1440 /dev/rfd0The specification -f 1440 tells mkdosfs that this is a 1.4 MB
floppy.
mformatcommandcommandmformat
Alternatively, you can use the mformat command:
$ mformat A: You can specify the number of tracks with the -t option, and the number
of sectors with the -s option. To explicitly specify a floppy with 80
tracks and 18 sectors (a standard 3\(12" 1.44 MB floppy), you could
enter:
$ mformat -t 80 -s 18 A:
mtoolsmformat is one of the mtools \ that we will look at in the next
section.
Other uses of floppiesfrisbeetarcommandcommandtar
Well, you could take the disks out of the cover and use them as a kind of
frisbee. But there is one other useful thing you can do with floppies: as an
archive medium, they don't need a file system on them. They just need to be
low-level formatted. For example, to write the contents of the current
directory onto a floppy, you could enter:
$ tar cvfM /dev/rfd0 .
\&./
\&.xfmrc
\&.x6530modkey
\&.uwmrc
\&.twmrc
\&.rnsoft
\&.rnlast
\&.rhosts~
\&.rhosts
\&...etc
Prepare volume #2 for /dev/rfd0 and hit return:
Since we are writing to the floppy as a character device, the name is
/dev/rfd0—as with tapes, the r stands for the
raw device. Note also the solitary dot (.) at the end of the
command line. That's the name of the current directory, and that's what you're
backing up. Note also the option M, which is short for
--multi-volume. There's a very good chance that you'll run out of space
on a floppy, and this option says that you have a sufficient supply of floppies
to perform the complete backup.
tarcommandcommandtar
To extract the data again, use tar with the x option:
$ tar xvfM /dev/rfd0
\&./
\&.xfmrc
\&.x6530modkey
\&.uwmrc
\&...etcSee the man page tar(1) for other things you can do with tar.
Accessing Microsoft floppiesmtoolsATTRIBMS-DOS commandMS-DOScommandCDMS-DOS commandMS-DOScommandCOPYMS-DOS commandMS-DOScommandDELMS-DOS commandMS-DOScommandDIRMS-DOS commandMS-DOScommandFORMATMS-DOS commandMS-DOScommandLABELMS-DOS commandMS-DOScommandMDMS-DOS commandMS-DOScommandRDMS-DOS commandMS-DOScommandREADMS-DOS commandMS-DOScommandRENMS-DOS commandMS-DOScommand
Of course, most of the time you get data on a floppy, it's not in tar
format: it has a Microsoft file system on it. We've already seen the Microsoft
file system type on page , but that's a bit of overkill if you just
want to copy files from floppy. In this case, use the mtools package.
mtools is an implementation of the MS-DOS commands ATTRIB,
CD, COPY, DEL, DIR, FORMAT, LABEL, MD,
RD, READ, REN, and TYPE under UNIX. To avoid confusion
with existing utilities, the UNIX versions of these commands start with the
letter m. They are also written in lower case. For example, to list
the contents of a floppy and copy one of the files to the current (FreeBSD)
directory, you might enter:
$ mdirlist the current directory on A:
Volume in drive A is MESSED OS
Directory for A:/
IO SYS 33430 4-09-91 5:00a
MSDOS SYS 37394 4-09-91 5:00a
COMMAND COM 47845 12-23-92 5:22p
NFS <DIR> 12-24-92 11:03a
DOSEDIT COM 1728 10-07-83 7:40a
CONFIG SYS 792 10-07-94 7:31p
AUTOEXEC BAT 191 12-24-92 11:10a
MOUSE <DIR> 12-24-92 11:09a
12 File(s) 82944 bytes free
$ mcd nfsChange to directory A:\eNFS
$ mdirand list the directory
Volume in drive A is MESSED OS
Directory for A:/NFS
\&. <DIR> 12-24-92 11:03a
\&.. <DIR> 12-24-92 11:03a
HOSTS 5985 10-07-94 7:34p
NETWORK BAT 103 12-24-92 12:28p
DRIVES BAT 98 11-07-94 5:24p
\&...and many more
51 File(s) 82944 bytes free
$ mtype drives.battype the contents of DRIVES.BAT
net use c: presto:/usr/dos
c:
cd \enfs
# net use f: porsche:/dos
# net use g: porsche:/usr
$ mcopy a:hosts .copy A:HOSTS to local UNIX directory
Copying HOSTS
$ ls -l hostsand list it
-rw-rw-rw- 1 root wheel 5985 Jan 28 18:04 hosts
You must specify the drive letter to mcopy, since it uses this
indication to decide whether the file name is a UNIX file name or a Microsoft
file name. You can copy files from FreeBSD to the floppy as well, of course.
A word of warning. UNIX uses a different text data format from Microsoft: in
UNIX, lines end with a single character, called Newline, and represented
by the characters \en in the C programming language. It corresponds to
the ASCII character Line Feed (represented by ^J). Microsoft uses
two characters, a Carriage Return (^M) followed by a Line
Feed. This unfortunate difference causes a number of unexpected
compatibility problems, since both characters are usually invisible on the
screen.
In FreeBSD, you won't normally have many problems. Occasionally a program will
complain about non-printable characters in an input line. Some, like
Emacs, will show them. For example, our last file, drives.bat,
would show as:
net use c: presto:/usr/dos^M
c:^M
cd \enfs^M
# net use f: porsche:/dos^M
# net use g: porsche:/usr^M
This may seem relatively harmless, but it confuses some programs, including the
C compiler and pagers like more, which may react in confusing ways. You
can remove them with the -t option of mcopy:
$ mcopy -t a:drives.bat .Transferring files in the other direction is more likely to cause problems. For
example, you might edit this file under FreeBSD and then copy it back to the
diskette. The results depend on the editor, but assuming we changed all
occurrences of the word porsche to freedom, and then copied the
file back to the diskette, Microsoft might then find:
C:> type drives.bat
net use c: presto:/usr/dos
c:
cd \enfs
# net use f: freedom:/dos
# net use g: freedom:/usr
mcopycommandcommandmcopy
This is a typical result of removing the Carriage Return characters. The
-t option to mcopy can help here, too. If you use it when
copying to a Microsoft file system, it will reinsert the Carriage
Return characters.
Printersspoolerlprcommandcommandlprlpddæmondæmonlpd
In this chapter, we'll look at some aspects of using printers with FreeBSD.
FreeBSD users do not access printers directly. Instead, a series of processes,
collectively called the spooler, manage print data. One process,
lpr, writes user print data to disk, and another, lpd, copies the
print data to the printers. This method enables processes to write print data
even if the printers are busy and ensures optimum printer availability.
In this section, we'll look briefly at what you need to do to set up printers.
For more details, look in the online handbook section on printing, from which
this section is derived.
lpd is the central spooler process. It is responsible for a number of
things:
It controls access to attached printers and printers attached to other hosts on
the network.
It enables users to submit files to be printed. These submissions are known as
jobs.
It prevents multiple users from accessing a printer at the same time by
maintaining a queue for each printer.
It can print header pages, also known as banner or burst pages, so users can
easily find jobs they have printed in a stack of printouts.
It takes care of communications parameters for printers connected on serial
ports.
It can send jobs over the network to another spooler on another host.
It can run special filters to format jobs to be printed for various printer
languages or printer capabilities.
It can account for printer usage.
Through a configuration file, and by providing the special filter programs, you
can enable the spooler to do all or some subset of the above for a great variety
of printer hardware.
This may sound like overkill if you are the only user on the system. It
is possible to access the printer directly, but it's not a good idea:
The spooler prints jobs in the background. You don't have to wait for data to
be copied to the printer.
The spooler can conveniently run a job to be printed through filters to add
headers or convert special formats (such as PostScript) into a format the
printer will understand.
Most programs that provide a print feature expect to talk to the spooler on your
system.
Printer configurationprinterconfigurationparallelport
Nowadays, most printers are connected by the parallel port. Parallel
ports enable faster communication with the printer, up to about 100,000 bytes
per second, while serial printers seldom transmit more than 1,920 characters per
second.
Older UNIX systems frequently used serial printers, but they are no longer in
common use. Look at the handbook article for specifies of serial printers.
More modern printers may also have an Ethernet interface, which enables them to
connect to several machines at once.
It's pretty straightforward to connect a parallel printer: plug in the cable
between the printer and the computer. You don't need any adjustments. If you
have more than one parallel interface, of course, you'll have to decide which
one to use. Parallel printer devices are called /dev/lptn, where
n is the number, starting with 0. See table
on page for further
details.
You don't need to do anything special to configure the line printer driver
lpt: it's in the kernel by default. Of course, if you have previously
removed it, you'll have to replace it. See page for more
details.
Testing the printertestingprintersprintertesting
When you have connected and powered on the printer, run the manufacture's test
if one is supplied. Typically there's a function which produces a printout
describing the printer's features. After that, check the communication between
the computer and the printer.
# lptest > /dev/lpt0This will not produce any output with a pure PostScript printer, but you should
see some reaction on the status display. See the description in the online
handbook for testing PostScript printers.
Configuring /etc/printcap/etc/printcap
The next step is to configure the central configuration file,
/etc/printcap. This file is not the easiest to read, but after a while
you'll get used to it. Here are some typical entries:
lp|lj|ps|local LaserJet 6MP printer:\e
:lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:sh:mx#0:\e
:if=/usr/local/libexec/lpfilter:
rlp|sample remote printer:\e
:rm=freebie:sd=/var/spool/output/freebie:lf=/var/log/lpd-errs:
Let's look at this in detail:
All fields are delimited by a colon (:).
Continuation lines require a backslash character (\e). Note
particularly that you require a colon at the end of a continued line, and
another at the beginning of the following line.
The first line of each entry specifies a number of names separated by vertical
bar symbols |. By tradition, the last name is a more verbose
description.
The following fields have an identification followed by an optional delimiter.
If the field takes a string parameter, the delimiter is =, and if it
takes a numeric value, the delimiter is #.
The first entry defines a local printer, called lp, lj,
ps and local LaserJet 6MP printer. Why so many names?
lp is the default, so you should have it somewhere. lj is
frequently used to talk to printers which understand HP's LaserJet language (now
PCL), and ps might be used to talk to a printer which understands
PostScript. The final name is more of a description.
The entry lp tells the spooler the name of the physical device to which
the printer is connected. Remote printers don't have physical devices.
sd tells the spooler the directory in which to store jobs awaiting
printing. You must check that this directory exists.
lf specifies the name of a file into which to log errors.
lpddæmondæmonlpdsh is a flag telling lpd to omit a header page. If you don't
have that, every job will be preceded by a descriptor page. In a small
environment, this doesn't make sense, and is just a waste of paper.
The parameter mx tells lpd the maximum size of a spool job in
kilobytes. If the job is larger than this value, lpd refuses to print
it. In our case, we don't want to limit the size. We do this by setting
mx to 0.
printfilterfilterprintif tells lpd to apply a filter to the job before
printing. We'll look at this below.
In the remote printer entry, rm tells lpd the name of the system
to which to send the data. This could be a fully qualified domain name, of
course.
Spooler filtersspoolerfilterprintfilterfilterprint
Probably the least intelligible entry in the previous configuration file was the
if entry. It specifies the name of an input filter, a program
through which lpd passes the complete print data before printing.
What does it do that for? There can be a number of reasons. Maybe you have
data in a format which isn't fit to print. For example, it might be PostScript,
and your printer might not understand PostScript. Or it could be the other way
around: your printer understands only PostScript, and the input isn't
PostScript.
There's a more likely reason to require a filter, though: most printers still
emulate the old teletypes, so they require a carriage return character
(Ctrl-M or ^M) to start at the beginning of the line, and a new
line character (Ctrl-J or ^J) to advance to the next line. UNIX
uses only ^J, so if you copy data to it, you're liable to see a
staircase effect. For example, ps may tell you:
$ ps
PID TT STAT TIME COMMAND
2252 p1 Ss 0:01.35 /bin/bash
2287 p1 IW 0:04.77 e /etc/printcap
2346 p1 R+ 0:00.05 ps
When you try to print it, however, you get:
PID TT STAT TIME COMMAND
2252 p1 Ss 0:01.35 /bin/bash
2287 p1 IW 0
The rest of the page is empty: you've gone off the right margin.
There are a number of ways to solve this problem:
You may be able to configure your printer to interpret Ctrl-J as both
newline and return, and to ignore Ctrl-M. Check your printer
handbook.
You may be able to issue a control sequence to your printer to tell it to
interpret Ctrl-J as both new line and return to the beginning of the line,
and to ignore Ctrl-M. For example, HP LaserJets and compatibles will do
this if you send them the control sequence ESC&k2G.
You can write an input filter which transforms the print job into a form
which the printer understands. We'll look at this option below.
/usr/local/libexec/lpfilter
There are a couple of options for the print filter. One of them, taken from the
online handbook, sends out a LaserJet control sequence before every job. Put
the following shell script in /usr/local/libexec/lpfilter:
#!/bin/sh
printf "\e033&k2G" && cat && printf "\ef" && exit 0
exit 2
Simple print filter
This approach does not work well with some printers, such as my HP LaserJet 6MP,
which can print both PostScript and LaserJet (natural) formats at random. They
do this by recognizing the text at the beginning of the job. This particular
filter confuses them by sending a LaserJet command code, so the printer prints
the PostScript as if it were plain text.
The source file /scripts/lpfilter.c contains a filter which
replaces all Ctrl-Js with Ctrl-JCtrl-M. Compile this program
and store the executable in /usr/local/libexec/lpfilter:
# cc /scripts/lpfilter.c -o /usr/local/libexec/lpfilterThat's all you normally need to do to set up your printers. Next, you should
test them.
Starting the spoolerAs we saw above, the line printer dæmon lpd is responsible for printing
spooled jobs. By default it isn't started at boot time. If you're
root, you can start it by name:
# lpdNormally, however, you will want it to be started automatically when the system
starts up. You do this by setting the variable lpd_enable in
/etc/rc.conf:
lpd_enable="YES" # Run the line printer daemon
See page for more details of /etc/rc.conf.
Another line in /etc/rc.conf refers to the line printer dæmon:
lpd_flags="" # Flags to lpd (if enabled).
You don't normally need to change this line. See the man page for lpd
for details of the flags.
Testing the spoolertestingthe spoolerspoolertesting
To test the spooler, you can run the lptest program again. This time,
however, instead of sending it directly to the printer, you send it to the
spooler:
$ lptest 20 5 | lprThe results should look like:
!"#$%&'()*+,-./01234
"#$%&'()*+,-./012345
#$%&'()*+,-./0123456
$%&'()*+,-./01234567
%&'()*+,-./012345678
Troubleshootingtroubleshootingspoolerspoolertroubleshooting
Here's a list of the most common problems and how to solve them:
Common printer problems
box,center,tab(#) ;
| lw25 | lw53 | .
Problem#Cause
=
The printer prints, but the last page doesn't appear. The status shows that the printer still has data in the buffer. After several minutes, the last page may appear. Your output data is not ejecting the last page. The printer is configured to either wait for an explicit eject request (the ASCII Form feed character, Ctrl-L) or to eject after a certain period of time.
You have a choice as to what you do about this. Usually you can configure the printer, or you could get the print filter to print a form feed character at the end of the job. Figure already does this—that's the printf "\ef".
staircaseeffect The lines wander off to the right edge of the paper and are never seen again. This is the staircase effect that we saw on page . See there for a couple of solutions.
Individual characters or whole sections of text are missing. This problem occurs almost only on serial printers. It's a result of incorrect handshaking—see page and the online handbook for more details.
The output was completely unintelligible random characters. On a serial printer, if the characters appear slowly, and there's a predominance of the characters {|}~, this probably means that you have set up the communication parameters incorrectly. Check the online handbook for a solution. Make sure you don't confuse this problem with the following one.
The text was legible, but it bore no relationship to what you wanted to print. One possibility is that you are sending PostScript output to your printer. Look at the example on page to check if it is PostScript. If it is, your printer is not interpreting it correctly, either because it doesn't understand PostScript, or because it has been confused (see the discussion on page for one reason). We'll look at PostScript in more detail on page .
The display on the printer shows that data are arriving, but the printer doesn't print anything. You might be sending normal text to a PostScript printer which doesn't understand normal text. In this case, too, you will need a filter to convert the text to PostScript—the opposite of the previous problem.
Alternatively, your printer port may not be interrupting correctly. This will not stop the printer from printing, but it can take up to 20 minutes to print a page. You can fix this by issuing the following command, which puts the printer /dev/lpt0 into polled mode:
lptcontrol -p You get the message lpr: cannot create /var/spool/output/freebie/.seq You have forgotten to create the spool directory /var/spool/output/freebie.
Using the spoolerUsingthe spoolerlprcommandcommandlpr
Using the spooler is relatively simple. Instead of outputting data directly to
the printer, you pipe it to the spooler lpr command. For
example, here is the same print command, first printing directly to the printer,
and secondly via the spooler:
# ps waux > /dev/lpt0
# ps waux | lprjobspoolerspoolerjoblpqcommandcommandlpq
The spooler creates a job from this data. You can look at the current
print queue with the lpq program:
$ lpq
waiting for lp to become ready (offline ?)
Rank Owner Job Files Total Size
1st grog 313 (standard input) 9151 bytes
2nd grog 30 (standard input) 3319 bytes
3rd yvonne 31 (standard input) 3395 bytes
4th root 0 (standard input) 2611 bytes
lpddæmondæmonlpd
The first line is a warning that lpd can't currently print. You should
take it seriously. In this example, the printer was deliberately turned off so
that the queue did not change from one example to the next.
Normally, the job numbers increase sequentially: this particular example came
from three different machines. You can get more detail with the -l
option:
$ lpq -l
waiting for lp to become ready (offline ?)
grog: 1st [job 313freebie.example.org]
(standard input) 9151 bytes
grog: 2nd [job 030presto.example.org]
(standard input) 3319 bytes
yvonne: 3rd [job 031presto.example.org]
(standard input) 3395 bytes
root: 4th [job 000bumble.example.org]
(standard input) 2611 bytes
Removing print jobsRemovingprint jobslprmcommandcommandlprm
Sometimes you may want to delete spool output without printing it. You don't
need to do this because of a printer configuration error: just turn the printer
off, fix the configuration error, and turn the printer on again. The job should
then be printed correctly. But if you discover that the print job itself
contains garbage, you can remove it with the lprm
program. First,
though, you need to know the job number. Assuming the list we have above, we
might want to remove job 30:
# lprm 30
dfA030presto.example.org dequeued
cfA030presto.example.org dequeued
# lpq
waiting for lp to become ready (offline ?)
Rank Owner Job Files Total Size
1st grog 313 (standard input) 9151 bytes
2nd yvonne 31 (standard input) 3395 bytes
3rd root 0 (standard input) 2611 bytes
If the printer is offline, it may take some time for the lprm to
complete.
PostScriptPostScriptPageDescription Language
We've encountered the term PostScript several times already. It's a
powerful Page Description Language. With it, you can transmit detailed
documents such as this book electronically and print them out in exactly the
same form elsewhere. PostScript is a very popular format on the World-Wide Web,
and browsers like Netscape usually print in PostScript format.
escapesequences
Most other document formats describe special print features with escape
sequences, special commands which start with a special character. For
example, the HP LaserJet and PCL formats use the ASCII ESC character
(0x1b) to indicate the beginning of an escape sequence. PostScript uses
the opposite approach: unless defined otherwise, the contents of a PostScript
file are commands, and the printable data is enclosed in parentheses.
PostScript documents start with something like:
%!PS-Adobe-3.0
%%Creator: groff version 1.10
%%CreationDate: Fri Oct 31 18:36:45 1997
%%DocumentNeededResources: font Symbol
%%+ font Courier
%%+ font Times-Roman
%%DocumentSuppliedResources: file images/vipw.ps
%%Pages: 32
%%PageOrder: Ascend
%%Orientation: Portrait
%%EndComments
%%BeginProlog
prologuePostScriptPostScriptprologue
This is the prologue (the beginning) of the PostScript output for this
chapter. The prologue of such a program can be several hundred
kilobytes long if it includes embedded fonts or images. A more typical size is
about 500 lines.
You can do a number of things with PostScript:
ghostscriptcommandcommandghostscriptghostviewcommandcommandghostview
You can look at it with ghostscript or ghostview, both of which
are in the Ports Collection.
Many printers understand PostScript and print it directly. You should know
this, since it's an expensive option, but in case of doubt check your printer
manual.
If your printer doesn't understand PostScript, you can print with the aid of
ghostscript.
Installing ghostscript and ghostviewghostview is an interface to ghostscript, so you need to install
it in any case. Older versions supplied the fonts separately, but you no longer
need to worry about that: they're now part of the package.
Install the packages by first checking the names on the CD-ROM:
# cd /cdrom/packages/All
# ls gh*
ghostscript-2.6.2.tgz ghostscript-3.53.tgz ghostscript-4.03.tgz ghostview-1.5.tgz
# pkg_add ghostscript-4.03.tgz ghostview-1.5.tgzViewing with ghostviewviewingwith ghostviewghostviewviewing withghostview displayghostviewcommandcommandghostview
To view a file with ghostview, simply start it:
$ ghostview &selFileghostview window
You will get a blank display, but you can open a file window by pressing
o, after which you can select files and display them. Figure
\& shows the display of a draft version of this page with an
overlaid open window at the top left. The selFile
window contains a
field at the top into which you can type the name of a file. Alternatively, the
three columns below, with scroll bars, allow you to browse the current directory
and the parent and grandparent directories. The interface looks relatively
primitive, but it works.
The window below shows the text of the previous page (roughly) on the right hand
side. with drag scroll bars operated by the middle button. At top left are five
oval menu buttons which you can select with the left mouse button. Note
particularly the Magstep button, which sets the size of the display.
The column to the right of these buttons is a list of page numbers. You can
select a page number with the middle mouse button. You can also get an
enlargement display of the text area around the mouse cursor by pressing the
left button. Press the area marked Dismiss to remove the enlargement.
Printing with ghostscriptprintingwith ghostscriptghostscriptprinting withghostscriptcommandcommandghostscript
If your printer doesn't support PostScript, you can still print some semblance
of the intended text with the help of ghostscript. The results are very
acceptable with laser and inkjet printers, less so with matrix printers, even 24
pin versions.
driverghostscriptghostscriptdriver
To print on your particular printer, you first need to find a driver for
it in ghostscript. In this context, the term driver means some
code inside ghostscript which converts the data into something that the
printer can print. Unfortunately, the man page doesn't help much. To find out
which driver it supports, start ghostscript and enter the following in
the text window, ignoring the display window that it opens:
$ gsthat's the name of the ghostscript program
Aladdin Ghostscript 5.03 (1997-8-8)
Copyright (C) 1997 Aladdin Enterprises, Menlo Park, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>devicenames ==list device names
[/tiff24nc /ppm /pcxgray /cgm8 /sgirgb /pnm /mgr8 /bmp16m /psmono /pgnm /mgrgray8 /bmp
16 /png256 /pgm /mgrgray2 /bitcmyk /pnggray /pbm /miff24 /bit /nullpage /pkmraw /pcx24
b /jpeg /pdfwrite /tifflzw /ppmraw /pcx16 /cgm24 /tiff12nc /pnmraw /pcxmono /cgmmono /
psgray /pgnmraw /mgr4 /bmp256 /png16m /pgmraw /mgrgray4 /bmpmono /png16 /pbmraw /mgrmo
no /bitrgb /pngmono /pcxcmyk /jpeggray /pswrite /tiffpack /pkm /pcx256 /cif /t4693d8 /
paintjet /ljet3d /iwlq /declj250 /appledmp /tiffg32d /t4693d2 /oki182 /ljet2p /iwhi /c
dj850 /sxlcrt /tiffcrle /st800 /necp6 /ln03 /ibmpro /cdj500 /x11gray2 /faxg32d /r4081
/lp8000 /lbp8 /eps9high /cdjcolor /x11alpha /dfaxlow /pxlmono /lj5gray /la75 /epson /c
cr /xes /pjxl /ljetplus /la50 /djet500c /bjc600 /tek4696 /pj /ljet4 /jetp3852 /deskjet
/bj10e /tiffg4 /t4693d4 /okiibm /ljet3 /iwlo /cp50 /ap3250 /tiffg3 /stcolor /oce9050
/lj250 /imagen /cdj550 /x11mono /faxg4 /sj48 /m8510 /lips3 /epsonc /cdjmono /x11cmyk /
faxg3 /pxlcolor /lp2563 /la75plus /eps9mid /cdeskjet /x11 /dfaxhigh /pjxl300 /lj5mono
/la70 /dnj650c /bjc800 /uniprint /pjetxl /lj4dith /laserjet /djet500 /bj200 /epswrite]
GS>^D exitUnfortunately, it's very difficult to decide which of these drivers does what
without looking at the source code, or at least the Makefile, so it's
comforting to know that the most common non-PostScript printer, the
Hewlett-Packard LaserJet series, uses the driver prefix ljet. Modern
versions will all run with ljet4; if you run into trouble, try one of
the older ones. In particular, the original LaserJet requires the driver
ljet.
The following one-line script will print PostScript documents to the spooler.
It is present on the CD-ROM as /scripts/gsp.
#!/bin/sh
gs -dNOPAUSE -q -sDEVICE=ljet4 -sOutputFile=\e|lpr -- $*
Note that the output to the printer is binary data, so a filter of the kind
shown in /scripts/lpfilter.c will destroy the format and produce
nonsensical output. This shouldn't be a problem, since that filter is intended
specifically for PostScript printers, which don't need ghostscript.
Setting up your FreeBSD desktopSo far, we've looked at FreeBSD from a system administration viewpoint. You
didn't install FreeBSD in order to perform system administration: you want to do
some work with it.
desktop
Nowadays, every computer system has the concept of a desktop, a surface on
the glass of your monitor on which you do your work. For years, UNIX users have
worked with a single 80x25 character mode display. Users of Microsoft Windows
considered this old-fashioned in the extreme, but in fact the flexibility of the
UNIX system made this quite a good way to work.
Still, there's no doubt of the advantage of a system which offers the
possibility of performing multiple operations at once, and this is one of the
declared advantages of UNIX. But you normally need a terminal to interact with
each task. Under UNIX, the best way to do this is with the X window system.
FreeBSD comes with over a thousand ported software packets. One user described
putting them together as trying to do a jigsaw puzzle without the picture on the
box.
In fact, it's even worse than that: you can imagine your own picture. Depending
on your imagination and your luck, the results can be good, bad, or unusable.
In this chapter, I describe a framework for how to work with FreeBSD. Not
surprisingly, this closely resembles the environment in which I work, and it may
not be to everybody's taste. It will, however, give you a usable start from
which you can diverge when you have the time, the inclination and the
understanding.
The hardwarehardwarefor XXhardware
The desktop I describe will run on almost any hardware. That doesn't mean that
all hardware is equal, of course. Here are some considerations:
The display board and monitorX enables you to do a lot more in parallel than other windowing environments.
As a result, screen real estate is at a premium. Use as big a monitor as you
can afford, and as high a resolution as your monitor can handle. You should be
able to display a resolution of 1600x1200 on a good 21" monitor, 1280x1024 on an
average 21" monitor, and 1024x768 on a 17" monitor. If you're using a 14"
monitor, you will have to compromise: it's difficult to use 1024x768 on a
monitor of this size, but any lower resolution is just too low for reasonable
use. I use 1024x768 when I have to use a 14" monitor.
The keyboardKeyboards have not changed much since the function keys were moved to the top of
the keyboard, where you have to search for them. It's obvious that keyboard
layouts are dictated by people who can't touch-type. In my opinion, this
applies particularly to the so-called ``ergonomic'' keyboards, which require a
lot of learning to use correctly, and don't seem to give anything in return.
Your mileage may vary, but bear in mind that FreeBSD places more emphasis on the
keyboard and less on the mouse than other systems.
The mousemousedouble-clickdouble-clickmouseCTS
PC mice originally had three buttons. To be different, Microsoft introduced a
two-button mouse, and to make it work anyway, they require the use of
double-click to execute many standard functions. In my opinion, more
arm injuries are caused by double-clicking mice than anything else I know. Ask
anybody with CTSCarpaltunnel syndromeCarpal tunnel syndrome, an inflammation of the forearm caused by
repetitive strain.
what they think about double-clicking. X generally does not require a
double-click.
Get the best mouse you can. Prefer a short, light switch. It must have
three buttons. Accept no substitutes. Three-button mice are usually cheaper
than the Microsoft mice, so there's no financial incentive to buy a Microsoft
mouse. Even if you want to use Microsoft with your computer as well, you should
choose a three-button mouse. Logitech makes some nice mice which are supplied
with drivers for Microsoft products which can optionally simulate a double-click
with a press on the middle button.
Running XXrunningrunningX
There are a number of ways to start X:
startxcommandcommandstartxxinitcommandcommandxinit
You can run the programs startx or xinit from a shell prompt.
They will start X directly.
xdmcommandcommandxdmdisplaymanager
If you don't want to even see a character mode display, you can run xdm, a
display manager which makes your PC look like an X terminal: it presents
you with a login screen that runs under X. This requires some configuration,
which we'll look at in the next section.
Configuring xdmxdmcommanddisplaymanager/etc/ttys
To enable xdm,
Add the following line (in
bold face)/etc/rc.local
to /etc/rc.local:
# put your local stuff here
echo " xdm"; /usr/X11R6/bin/xdm
echo '.'
/usr/X11R6/lib/X11/xdm/Xservers
Add a line to the xdm configuration file
/usr/X11R6/lib/X11/xdm/Xservers:
:0 local /usr/X11R6/bin/X :0 vt03 you can add more options herexdmcommandcommandxdminitdæmondæmoninit/etc/ttys
This will start an xdm login window on /dev/ttyv3 when you start
the system. You must ensure that /dev/ttyv3 is disabled in
/etc/ttys. See page for more details.
You can also test the display manager manually by logging in as root on
the console and typing:
$ xdm -nodaemon &Yet another way to start the display manager automatically when the system boots
is to add a line in /etc/ttys to start it on one of the unoccupied
virtual terminals. This is a very dangerous method: if you make a mess of your
X configuration, you may no longer be able to access the system.
Running xinitxinitcommandcommandxinitstartxcommandcommandstartx
Running xinit or startx is simpler: after logging in, you just
run the program.
startx and xinit both output messages to their standard output,
which is the virtual terminal on which you started it. Sometimes they produce
copious output. If you're having trouble getting X running, you might like to
redirect the output to a file:
$ startx 2>&1 > /tmp/startx.logStopping XX stops automatically when the .xinitrc script finishes. For this
reason, you should not include an ampersand (&) after the last program
you start—we'll look at this in more detail when we look at the sample
\&.xinitrc below. Of course, this isn't the easiest way to stop X: you
have to know which process was started last, and then you have to stop it.
There's an easier way: press the key combination
CTRL-ALT-Backspace, which is deliberately chosen to resemble
the key combination CTRL-ALT-Delete used to reboot the
machine. CTRL-ALT-Backspace will stop X and return you to the
virtual terminal in which you started it.
Changing screen resolutionCTRL-ALT-Keypad-keystrokeCTRL-ALT-Keypad -CTRL-ALT-Keypad+keystrokeCTRL-ALT-Keypad +Xchanging screen resolutionscreenresolution
When you set up your XF86Config file, you may have specified more than
one resolution. For example, on page we selected the
resolutions 640x480, 800x600 and 1024x768 pixels when running at 8 bits per
pixel (bpp). When you start X, it will automatically select the first
resolution, in this case 640x480. You can change to the previous resolution
(the one to the left in the list) by pressing the CTRL-ALT-Keypad
- key, and to the following resolution (the one to the right in the list)
with CTRL-ALT-Keypad +. Keypad + and Keypad -
refer to the + and - symbols on the numeric keypad at the right of
the keyboard; you can't use the + and - symbols on the main keyboard
for this purpose. The lists wrap around: in our example, if your current
resolution is 640x480, and you press CTRL-ALT-Keypad -, the
display will change to 1024x768. It's a very good idea to keep the default
resolution at 640x480 until you have debugged your XF86Config
parameters: 640x480 almost always works, so if your display is messed up, you
can just switch back to a known good display with a single keystroke.
Selecting pixel depthOn page we also saw that you can configure most display
boards to display a different pixel depth (a different number of bits per pixel,
which translates to a different number of colours). When you start X, however,
it defaults to 8 bits per pixel (256 colours). In order to start it with a
different number, specify the number of planes. For example, to start with 16
bits per pixel (65,536 colours), enter:
$ startx -- -bpp 16This will normally limit the maximum resolution available.
Customizing XcustomizingXXcustomizing.xinitrcstartx and xinit both look for a file called .xinitrc
when they start up. This file typically contains commands for starting up X
clients such as terminal windows and a window manager If you don't have this
file, you will get a single xterm window without a frame, as in figure
.
Vanilla X displaywindowmanagerxdmwindow managerwindowmanagertwmwindow managerwindowmanagerfvwm2window managerwindowmanager
Here you have a single xterm window in the top left corner. You can't
move it, you have no menus. To make life worth living, you need at least a
window manager, a program which controls other windows on the display. If
you start X from xdm, you will get the twm window manager and a
default environment. twm is a pretty basic window manager. In this
example, I use fvwm2, which has more features than twm.
fvwm95window managerwindowmanager
A large number of window managers are available for X11. I prefer a relatively
sober looking manager, but there are many more with other features. You can get
a good overview at http://www.plig.org/xwinman/. If you like
Microsoft's ``Windows 95'' environment, you might prefer fvwm95, which is
similar. Before you do, however, consider the advantages of other window
managers: Microsoft's environment does not scale well.
You can start a window manager from a shell prompt, but it's easier to put the
invocation in the .xinitrc file. A simple .xinitrc might be:
xhost presto bumble gw allow access from other hosts
xrdb -load .Xdefaults load default settings
xmodmap -e 'keysym Alt_L = Meta_L Meta_L' remap keys for Emacs
xterm -s -sl 256 -sb -ls -j -rw -geometry 100x55 & start xterm left
xterm -s -sl 256 -sb -ls -j -rw -geometry 100x55-0+0 & and right
xearth & start a root background
emacs -name "grog emacs" -geometry 100x55-0+0 -font 6x13& and biff at the bottom
xbiff -geometry +450-0 -fg green -bg black&
fvwm2 start fvwmThis file performs the following functions:
xhostcommandcommandxhost
The xhost line allows connections from all systems in the Internet. In
the interests of security, you will probably want to limit the systems to your
local network. Check the man page xhost(1) for how to do this.
xrdbcommandcommandxrdb
The xrdb line loads your local preferences. See the man page
X(1) for more details.
xmodmapcommandcommandxmodmap
The xmodmap invocation sets the Alt key to perform the Meta
function for Emacs. If this doesn't say anything to you, don't worry.
You'll see more of it when you get to know Emacs.
The two xterm lines start two xterms, one on the left of the
screen, one on the right. The geometry keyword determines this: they
have 55 lines of 100 characters each, suitable for a standard 1024x768 display.
If your display is larger, you can expand the size of these windows to
advantage.
xearthcommandcommandxearth
The invocation of xearth starts a program which updates the root
windowThe root window is the background on which the other windows are displayed,.
screensaver
with a current view of the world. In Microsoft circles, this might be called a
screen saver.
Emacs takes a relatively long time to start, so it's a good idea to
start one when you start X, and leave it running.
xbiffcommandcommandxbiffxbiff is a little program which shows a picture of a US-style mailbox.
When mail arrives, it changes colour, beeps, and raises the flag.
fvwm2commandcommandfvwm2
Finally, we start the window manager, fvwm2. As noted above, we don't
specify an ampersand (&) at the end of this command, so that the
\&.xinitrc script does not complete. If you stop the window manager,
however, the script will complete, and the X session will stop. We'll look at
what we can do with fvwm2 in more detail below.
Typical X display with fvwm2.xinitrc
You'll find this .xinitrc file on the installation CD-ROM
/scripts/.xinitrc. On page we'll see how to
install this and the other files I describe in this chapter.
NetscapecommandcommandNetscape
Now, when you start X, you will be given a somewhat better looking screen.
After opening a Netscape window and iconifying it and one of the
xterm windows, it might look like figure . Here we see
a Netscape window on the right and four icons:
muttcommandcommandmutt
On the left are two xterm icons. The first has the name
(yvonne@presto: it has been truncated to fit the box) and a small
picture. The second has the name mutt, indicating that it is running
the mutt mail reader.
StarWritercommandcommandStarWriter
Underneath the xterm icons is a StarWriter icon. The name of
this icon has been truncated to fit.
LeheyYvonneemacscommandcommandemacs
On the right is an Emacs icon, the figure of a gnu. The name
yvonne is the name of the user, not the program.
fvwm2window managerwindowmanager
You'll notice that some of the names in the icons have been truncated. This is
because the names can get very long. The text on a Netscape
icon is the name on the title, which can be over 100 characters long. If this
text were in the icon, it would take up half the width of the screen.
fvwm2 makes a compromise: the text expands to full size when you run the
mouse cursor over the icon.
In addition, we can see a couple of nested menus. We'll look at them later.
Navigating the desktopIf you're used to Microsoft Windows, X may seem strange to you at first. On the
one hand, you can recognize parallels, but on the other hand there are enormous
differences. One of the most obvious things is the layout of the screen. The
Microsoft desktop is not really suited to a large number of objects on the
screen. As I write this, I have a total of 28 windows open on the
screens—this does not scale well with Microsoft.
icon
One similarity is that you can iconify windows: when you don't need
them, you can reduce them to a small symbol, as we saw in Figure
. One of the consequences of this is that you may want smaller
icons. Do you really need a picture of a terminal for each of 10 different
xterms? Maybe just the bar beneath would do. It's your choice, but you
have the choice.
You'll also notice that the windows have much more text in them than in a
Microsoft environment. This is not simply primitive: you can do more things
with text. Compared to Microsoft, an X environment uses the keyboard more and
the mouse less. When you do use the mouse, you'll find that there are many more
ways to use it. Although an X mouse should have at least three buttons,
X supports up to 5 mouse buttons. No, I've never seen a mouse with more than
three buttons.
many operations require the keyboard as well. In addition, the function of the
mouse depends on where the cursor is positioned at the time. We'll look at that
in the next section.
Mouse menusmenusmousemousemenusfvwmwindow managerwindowmanagerfvwm and X distinguish several places on the screen:
rootwindowwindowroot
The root window is the ``background'', the window that is left behind
when all the other ones are closed or iconified. You can't use it for much, you
can't iconify it, and you can't put it on top of other window. Typically you'll
display some pattern or picture on it. In figure we display a
map of the world on it.
icon
We've already seen an icon: it's a small symbol or picture representing
a window which is not currently being displayed.
windownetscapecommandcommandnetscapeemacscommandcommandemacs
A window is a unit of display. You might think of a window as equal to
a process, but this isn't correct. For example, Netscape and
Emacs frequently display more than one window at a time.
windowframe
Windows typically have a frame, which contains a number of elements:
windowtitlewindowbuttons
The title is at the top of the window, and typically contains a text
identifying the window and possibly some buttons which provide mouse
functions.
fvwmwindow managerwindowmanagerwindowsidesfvwm treats the sides of the frame separately from the corners.
We'll see the difference in the tables below.
Finally, an fvwm frame may have up to 10 buttons, which fvwm
numbers 0 to 9.
You can see the typical fvwm border in example . The
most important part is the title bar:
There are a total of three fields, called buttons, on the title bar: one
on the left and two on the right. If you position the mouse cursor on the left
button and press any any mouse button, you will get a menu:
Window Operations MenuThis looks familiar to Microsoft users, but in time, you will find that this
menu is less useful that it appears, since you can perform most functions
without a menu.
icon
There are two buttons on the right of the title bar. The left-hand button is
the iconify button. If you click here with any mouse button, the window
will be iconified: it will disappear and be replaced by a small symbol
or icon, such as the ones on the left and bottom of figure
. Iconification frees up screen area, but it doesn't stop or
suspend process execution. If you want to stop a program, you should either
exit the application or close the window. It's preferable to exit, since the
application is more likely to perform its housekeeping before stopping.
windowmaximize
The right-hand button is the maximize button. If you click here with
any mouse button, the window will be expanded to fill the screen. If you click
again, the window will be returned to its former size and position.
Pressing mouse buttons elsewhere performs other functions. For example, when
you move the mouse cursor to one of the corners, it changes shape to a corner
with an arrow. This cursor shape indicates that you can extend the window in
that direction by keeping the mouse button down and dragging the border.
.fvwm2rc
In most windows, the mouse keys will produce an application-specific menu. By
convention, however, combinations of the mouse key and the Alt key are
interpreted by the window manager even when the cursor is in a window. For
example, with the sample .fvwm2rc, Alt-Mouse2 (the Alt key
and the middle mouse button) iconifies the window.
In the next few sections, we'll look at all the mouse functions:
Mouse key functions on the root windowOn the root window, the mouse keys are used only to produce menus. Table
gives an overview.
Mouse key functions on the root window
center,box,tab(#) ;
| lfCWp9| lf(B)p9 | lw61 | .
\s10Mouse
\^\s10Key#\s10Keyboard#Function
=
xtermcommandcommandxterm 1 Produce a menu of xterms for the left side of the screen. This is the menu LeftHosts. 2 Produce a menu of other applications, the menu ApplicationsApplicationsmenu 3 Produce a menu of xterms for the right side of the screen. This is the menu RightHosts.
RightHostsmenu 1Shift Produce the ControlControlmenu menu. This menu includes various control functions. This is the left-hand of the menus displayed in figure . 2Shift Display a list of the active windows. Selecting a window will deiconify it if necessary and bring it to the top of the screen (in other words, no other window will cover it). 3Shift Bring up the ``Window operations'' menu on page .
It's desirable for some menus to be independent of the position on the screen.
That way, you don't have to look carefully before selecting them. To ensure
that they don't clash with anything else, select all of them with the key
combination Shift-Alt:
Position-independent mouse key functions
center, box,tab(#) ;
| lfCWp9| lf(B)p9 | lw61 | .
\s10Mouse
\^\s10Key#\s10Keyboard#Function
=
1Shift-Alt Produce the ControlControlmenu menu. This menu includes various control functions. This is the left-hand of the menus displayed in figure . 2Shift-Alt Display the ApplicationsApplicationsmenu menu. 3Shift-Alt Move the current window. This doesn't work on the root window.
Use of colourcolourin X
You'll find that your X display doesn't look as brightly coloured as, say, a
Microsoft desktop. In particular, xterm is monochrome black on pale.
If you want xterm to display in colour, you need two things:
Change the TERM environment variable from xterm to
xterm-color. This enables the control sequences which xterm
uses to display in colour.
You need applications which display in colour. The muttmuttcommandcommandmutt
mail reader will do this—see , page , for further details.
So will some programs in the Ports Collection, such as colorls,
colorlscommandcommandcolorls
a version of ls which displays different kinds of files in different
colors when you supply it the -G option.
Network windowingXin network
FreeBSD is an operating system which is designed to run in a networked
environment, so it should come as no surprise that you a system can create
windows on a display on a different system. To avoid confusion, it's a good
idea to look at some terminology before we continue:
XServer
An X Server is the display manager, so it runs on the machine with the
display. Theoretically there can be multiple X servers on one machine, though
I've never seen this implemented.
screenXXscreen
A screen is one of possibly many display board and monitor combinations
controlled by a specific X server. Some X servers, notably the server from Xi
Graphics, do support multiple screens.
XClientClientXXClient
An X Client is a program which uses an X Server to display its data.
The prototypical example is xterm.
A special notation exists to address X servers and screens:
System name:server number.screen number
When looking at X client-server interaction, remember that the server is the
software component that manages the display. This means that you're always
sitting at the server, not at the client. For example, if you want to start an
xterm client on freebie and display it on presto, you'll
be sitting at presto. To do this, you could type in, on presto,
$ rsh freebie xterm -ls -display presto:0 &~/.rhostsxhostcommandcommandxhost
The flag -ls tells xterm that this is a login shell, which
causes it to read in the startup files. It might work without this flag, but
there's a good chance that some environment variables, such as PATH, may
not be set.
In practice, the xterms menus in the window manager will perform this
function for you when you select the appropriate menu item. For this to work,
you'll need to have remote access enabled via the ~/.rhosts file (see
, page ). In addition, you'll need to tell the X server
to allow the connection. You do this with the xhost command, specifying
the names of the systems which have access:
$ xhost freebie presto bumble wait gwThis will enable access from all the systems on our reference network, including
the one on which it is run. You don't need to include your own system, which is
enabled by default, but if you do, you can use the same script on all systems on
the network.
Installing the sample desktopinstall-desktopscript
You'll find all the files described in this chapter on the first CD-ROM
(Installation CD-ROM) in the directory . Remember that you must
mount the CD-ROM before you can access the files—see page for
further details. The individual scripts are in the directory
/scripts, but you'll probably find it easier to install them with
the script install-desktop:
# /cdrom/scripts/install-desktopThe sample desktop uses a number of packages from the Ports Collection. Look at
the file /scripts/install-desktop for more details.
The shellOne of the big differences between X and Microsoft environments is that X has
not gone overboard and eliminated typing. You will find that you still spend a
considerable amount of time with the old-style shell. You don't have to: UNIX
always gives you the choice, but most users find that once you have relatively
complicated things to to, it is easier to tell the system what they want rather
than to wade through lots of menus.
bashcommandcommandbash
We looked at the bash shell in , page . When you
start up an xterm, you will automatically have a bash shell
running.
The Emacs editoremacscommandcommandemacs
Another divergence of concept between UNIX and Microsoft environments is that
UNIX gives you a choice of editors in just about anything you do. Microsoft
products frequently try to redefine the whole environment, so if you change
mailers, you may also have to change the editor you use to write mail. This has
a profound effect on the way you work. In particular, the Microsoft way makes
it uninteresting to write a really good editor, since you can't use it all the
time.
vicommandcommandvi
You may have heard of the vi editor, about which people speak with a
mixture of admiration, awe and horror. vi is one of the oldest parts of
BSD. It is a very powerful editor, but nobody would say that it is easy to
learn. There are two reasons to use vi:
If you're already an experienced vi hacker, you probably won't want to
change.
If you do a lot of work on different UNIX systems, you can rely on vi
being there. There's no other editor about which you can say the same.
If, on the other hand, you don't know vi, and you only work on systems
whose software you can control, you probably shouldn't use vi.
Emacs is much easier to learn, and it is more powerful than vi.
TheNew Hackers' Dictionary
I'm sticking my neck out here. Holy wars have been fought about the differences
between vi and Emacs, and they continue to be fought. To quote
version 4.0 of Eric Raymond's The New Hackers' Dictionary:
holy wars /n./ [from {Usenet}, but may predate it] /n./ {flame war}s over
{religious issues}. The paper by Danny Cohen that popularized the terms
{big-endian} and {little-endian} in connection with the LSB-first/MSB-first
controversy was entitled "On Holy Wars and a Plea for Peace". Other perennial
Holy Wars have included {EMACS} vs. {vi}, my personal computer vs. everyone
else's personal computer, {{ITS}} vs. {{Unix}}, {{Unix}} vs. {VMS}, {BSD} Unix
vs. {USG Unix}, {C} vs. {{Pascal}}, {C} vs. FORTRAN, etc., ad nauseam. The
characteristic that distinguishes holy wars from normal technical disputes is
that in a holy war most of the participants spend their time trying to pass off
personal value choices and cultural attachments as objective technical
evaluations. See also {theology}.
:EMACS: /ee'maks/ /n./ [from Editing MACroS] The ne plus ultra of hacker
editors, a programmable text editor with an entire LISP system inside it. It
was originally written by Richard Stallman in {TECO} under {{ITS}} at the MIT AI
lab; AI Memo 554 described it as "an advanced, self-documenting, customizable,
extensible real-time display editor". It has since been reimplemented any
number of times, by various hackers, and versions exist that run under most
major operating systems. Perhaps the most widely used version, also written by
Stallman and now called "{GNU} EMACS" or {GNUMACS}, runs principally under Unix.
It includes facilities to run compilation subprocesses and send and receive
mail; many hackers spend up to 80% of their {tube time} inside it. Other
variants include {GOSMACS}, CCA EMACS, UniPress EMACS, Montgomery EMACS, jove,
epsilon, and MicroEMACS.
Some EMACS versions running under window managers iconify as an overflowing
kitchen sink, perhaps to suggest the one feature the editor does not (yet)
include. Indeed, some hackers find EMACS too {heavyweight} and {baroque} for
their taste, and expand the name as `Escape Meta Alt Control Shift' to spoof its
heavy reliance on keystrokes decorated with {bucky bits}. Other spoof
expansions include `Eight Megabytes And Constantly Swapping', `Eventually
`malloc()'s All Computer Storage', and `EMACS Makes A Computer Slow' (see
{{recursive acronym}}). See also {vi}.
When running under X, Emacs displays its own window (vi always
uses an xterm). As a result, if you start Emacs from an
xterm, you should use the & character to start it in the
background:
$ emacs &The resulting display looks like:
Filesmenu
As you can see, the first thing that Emacs offers you is a tutorial.
You should take it. You'll also notice the menu bars at the top. Although they
look primitive compared to graphics toolbars, they offer all the functionality
of graphics-oriented menus. In addition, they will tell you the keystrokes
which you can use to invoke the same functions. Here's an example of the
Files menu:
Configuring the kernelSo far, everything we've done has been with the standard GENERIC kernel
distributed with FreeBSD. But we've seen that the GENERIC kernel has
its limitations, and you may find advantages in a custom kernel:
commandtcpdumptcpdumpcommandBerkeleyPacket Filter
As we saw in , GENERIC doesn't support everything that
FreeBSD knows about. For example, if you want to install a Yoyodyne frobulator,
you'll need to install special support for it.
In fact, the developer working on the Yoyodyne has defected to the Free Software
Foundation. See the appendix to the GNU General Public License, reprinted in
, for further details.
It will take less time to boot because it does not have to spend time probing
for hardware which you do not have.
A custom kernel often uses less memory, which is important because the kernel is
the one system component which must always be present in memory, so unused code
ties up memory which would otherwise be available to the virtual memory system.
On a system with limited RAM, you can save some memory by building a custom
kernel. Don't overestimate the savings: a minimal kernel might save 500 kB over
the GENERIC kernel supplied with the system.
Finally, there are several kernel options which you can tune to fit your needs.
KernelLoadable Modulekld
If you just need to add device support, you may be able to load a Kernel
Loadable Module, or kld. In all other cases you'll need to build a new
kernel. See page for more information on klds.
FreeBSD is distributed in source, and building a kernel primarily involves
compiling the source files needed for the kernel. To build a kernel, you
perform the following steps:
Install the system source, if you haven't already done so.
kernelconfiguration file
Define your kernel configuration in a kernel configuration file. This
file defines parameters to use during the build process. We'll look at how to
do this starting on page
commandconfigconfigcommand
Create the configuration directory with the program config. We'll discuss
this on page .
makedepend
Run make depend to create the dependency information for the kernel build.
Run make to build the kernel. We'll look at this step on page
Install the kernel, which we'll discuss on page
Configuring I/O devicesA lot of the configuration file relates to the I/O devices that you may connect
to your machine. Recall from , that in the most cases you will
need to specify some of IRQ, DMA channel, board memory, and I/O addresses for
the devices you configure. Note particularly that the config file will not
handle references to IRQ 2 correctly: you must specify them as IRQ 9.
See page for further details.
The kernel build directorykernelbuild directory/usr/src/sys/sysi386/confalpha/conf/usr/src/sys/alpha/conf/LINT
The kernel sources are kept in the directory /usr/src/sys. The symbolic
link /sys also points to this directory. There are a number of
subdirectories of /usr/src/sys which represent different parts of the
kernel, but for our purposes, the most important are the architecture dependent
directories i386/conf (for the i386 architecture) or alpha/conf
(for the Alpha architecture), where you edit your custom kernel configuration,
and compile, where you build your kernel. Notice the logical organization
of the directory tree: each supported device, file system, and option has its
own subdirectory. In the rest of this chapter, we'll look at the i386
architecture. Most of this applies to the Alpha architecture as well, but there
are differences not covered here. See /usr/src/sys/alpha/conf/LINT for
more information.
/usr/src/sys
If your system doesn't have the directory /usr/src/sys, then the kernel
source has not been installed. The sources are on the first CD-ROM in the
directory /src. To install from the CD-ROM, perform the following steps:
# mkdir -p /usr/src/sys
# ln -s /usr/src/sys /sys
# cd /
# cat /cdrom/src/ssys.[a-d]* | tar xzvf -The symbolic link /sys for /usr/src/sys is not strictly
necessary, but it's a good idea: some software uses it, and otherwise you may
end up with two different copies of the sources.
kernelGENERIC
Next, move to the directory i386/conf and copy the GENERIC
configuration file to the name you want to give your kernel. For example:
# cd /usr/src/sys/i386/conf
# cp GENERIC FREEBIEkernelFREEBIE
Traditionally, this name is in all capital letters and, if you are maintaining
multiple FreeBSD machines with different hardware, it's a good idea to name it
after your machine's hostname. In this example we call it FREEBIE.
kernelFREEBIEkernelGENERIC
Now, edit FREEBIE with your favorite text editor. Change the comment
lines at the top to reflect your configuration or the changes you've made to
differentiate it from GENERIC:
#
# FREEBIE -- My personal configuration file
#
# For more information read the handbook part System Administration ->
# Configuring the FreeBSD Kernel -> The Configuration File.
# The handbook is available in /usr/share/doc/handbook or online as
# latest version from the FreeBSD World Wide Web server
# <URL:http://www.FreeBSD.ORG/>
#
# An exhaustive list of options and more detailed explanations of the
# device lines is present in the ./LINT configuration file. If you are
# in doubt as to the purpose or necessity of a line, check first in LINT.
#
# $\&Id: FREEBIE,v 1.101 1997/10/31 22:10:02 jseger Exp $
machine "i386"
cpu "I386_CPU"
cpu "I486_CPU"
cpu "I586_CPU"
cpu "I686_CPU"
ident FREEBIE
maxusers 10
kernelGENERIC
If you've build a kernel under SunOS or some other BSD operating system, much of
this file will be very familiar to you. If you're coming from some other
operating system such as MS-DOS, on the other hand, the GENERIC configuration
file might seem overwhelming to you, so follow the descriptions in the following
section slowly and carefully.
The configuration filekernelconfiguration fileconfigurationfilekernelGENERICkernelLINT
The directory /sys/i386/conf contains a number of configuration files:
tab(#) ;
lfCWp9 lw65 .
GENERIC#T{
General-purpose configuration file
T}
LINT#T{
Complete configuration file with copious comments. This file is intended for
regression testing and documentation, not for building kernels, which would be
far too bloated.
T}
PCCARD#T{
A configuration file for laptops which use PCCARD controllers.
T}
SMP-GENERIC#T{
A generic configuration file for symmetrical multiprocessor machines.
T}
The general format of a configuration file is quite simple. Each line contains
a keyword and one or more arguments. For simplicity, most lines only contain
one argument. Anything following a # is considered a comment and
ignored. Keywords which contain numbers used as text must be enclosed in
quotation marks.
One of the results of this simplicity is that you can put in options which have
absolutely no effect. For example, you could add a line like this:
options APPLE_MAC_COMPATIBILITY
You can build a kernel with this option. It will make no difference whatsoever.
Now it's unlikely that you'll think up a non-existent option like this, but it's
much more possible that you'll misspell a valid option, especially
finger-twisters like SYSVSHM, with the result that you don't compile in
the option you wanted. The config program warns if you use unknown
options, so take these warnings seriously.
The following sections describe the keywords not in the order they are listed in
LINT: instead, related keywords have been grouped together in a single
section (such as Networking), but in LINT they might be scattered
throughout the file. Following this overview we'll look at some of the more
important ones. You can find more information from the comments in the
LINT file. Here's an overview in alphabetical order. The keywords
without a page number are not discussed in more detail.
Configuration file keywords
box,center,tab(#) ;
lfCWp9w10 | l | lw45 .
\s10Keyword#Page#Purpose
=
adv0 AdvanSys narrow SCSI host adaptor adw0 Second Generation AdvanSys controllers including the ADV940UW. aha0 Adaptec 154x SCSI host adapters ahb0 Adaptec 174x SCSI host adapters ahc0 Adaptec 274X and 284X adapters AHC_ALLOW_MEMIO enable memory mapped I/O on Adaptec 274X and 284X adapters alpha Define the alpha architecture alpm0 Acer Aladdin-IV/V/Pro2 Power Management Unit APIC_IO enable the use of the IO APIC for Symmetric I/O apm0 Laptop Advanced Power Management ar0 Arnet SYNC/570i hdlc sync 2/4 port V.35/X.21 serial driver (requires sppp) asc0 GI1904-based hand scanners, e.g. the Trust Amiscan Grey atkbd0 The keyboard controller. It controls the keyboard and the PS/2 mouse. atkbdc0 ATKBD_DFLT_KEYMAP specify the built-in keymap atm generic ATM functions ATM_CORE core ATM protocol family ATM_IP IP over ATM support ATM_SIGPVC SIGPVC signalling manager ATM_SPANS SPANS signalling manager ATM_UNI UNI signalling manager AUTO_EOI_1 Enable the automatic EOI feature for the master 8259A interrupt controller AVM_A1 AVM A1 or AVM Fritz!Card ISDN adaptor AVM_A1_PCMCIA AVM A1 or AVM Fritz!Card ISDN adaptor, PCMCIA ax0 PCI fast ethernet adapters based on the ASIX Electronics AX88140A chip, including the Alfa Inc. GFC2204. bktr0 Bt848 capture boards (http://www.freebsd.org/~fsmp/HomeAuto/Bt848.html) BOOTP Use BOOTP to obtain IP address/hostname BOOTP_COMPAT Workaround for broken bootp daemons. BOOTP_NFSROOT NFS mount root filesystem using BOOTP info BOOTP_NFSV3 Use NFS v3 to NFS mount root BOOTP_WIRED_TO Use interface fxp0 for BOOTP bpfilter Berkeley packet filter BREAK_TO_DEBUGGER A BREAK on a comconsole goes to ddb BRIDGE Enable bridging between ethernet boards. bt0 Most Buslogic SCSI host adapters card0 PCMCIA slot controller. ccd Concatenated disk driver cd0 SCSI CD-ROMs CD9660 ISO 9660 filesystem CD9660_ROOT CD-ROM usable as root device CD9660_ROOTDELAY Timeout on mounting CD-ROM root ch0 SCSI media changers CODA CODA filesystem. COMPAT_43 Implement system calls compatible with 4.3BSD COM_ESP code for Hayes ESP COM_MULTIPORT code for some serial boards with shared IRQs config Define kernel parameters CONSPEED Default speed for serial console cpu Specify the CPU chip (not the hardware) CPU_UPGRADE_HW_CACHE CRTX_S0_P cs0 IBM Etherjet and other Crystal Semi CS89x0-based Ethernet adapters. css0 Crystal Sound System (CSS 423x PnP). ctx0 Cortex-I frame grabber cx0 Cronyx/Sigma multiport sync/async (with Cisco or PPP framing) cy0 Cyclades serial driver CYRIX_CACHE_REALLY_WORKS Enables CPU cache on Cyrix 486 CPUs without cache flush at hold state, and write-back CPU cache on early-revision Cyrix 6x86 CYRIX_CACHE_WORKS Enable CPU cache on Cyrix 486 CPUs with cache flush at hold state. CY_PCI_FASTINTR Use with cy_pci unless irq is shared da0 SCSI direct access devices (aka disks) DDB Enable the kernel debugger DDB_UNATTENDED Dont drop into DDB for a panic de0 Digital Equipment DC21040 Ethernet adapter DEVFS Device filesystem DFLDSIZ Soft maximum data size dgb0 Digiboard PC/Xi and PC/Xe series driver (ALPHA QUALITY!) dgm0 DIAGNOSTIC Enable extra sanity checking of internal structures disc Discard device—discard all packets DONTPROBE_1284 Avoid boot detection of PnP parallel devices dpt0 Support for DPT RAID controllers. DRN_NGO Dr. Neuhaus Niccy Go@ ISDN board DUMMYNET Enable the ``dummynet'' bandwidth limiter DYNALINK Dynalink IS64PH ISDN board ed0 Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503 eisa0 EISA bus EISA_SLOTS Number of EISA slots to probe el0 3Com 3C501 ELSA_QS1ISA ELSA QuickStep 1000pro ISA ISDN board ELSA_QS1PCI ELSA QuickStep 1000pro PCI ISDN board en0 Efficient Networks (ENI) ENI-155 PCI midway cards and Adaptec 155Mbps PCI ATM cards (ANA-59x0) ENABLE_ALART ep0 3Com 3C509 ether Generic Ethernet support ex0 Intel EtherExpress Pro/10 and other i82595-based Ethernet adapters EXPORTMFS Allow MFS filesystems to be exported via NFS. EXT2FS Linux ext2fs file system. EXTRA_SIO number of extra sio ports to allocate FAILSAFE Be particularly conservative in various parts of the kernel and choose functionality over speed (on the widest variety of systems). FAT_CURSOR start with block cursor fd0 Floppy disk fdc0 Floppy disk controller FDC_DEBUG Enable floppy debugging FDC_YE fddi Generic FDDI support FDESC File descriptor filesystem fe0 Fujitsu MB86960A/MB86965A Ethernet fea0 DEC DEFEA EISA FDDI adapter FFS Fast filesystem FFS_ROOT FFS usable as root device fpa0 Digital DEFPA PCI FDDI adapter fxp0 Intel EtherExpress Pro/100B PCI Fast Ethernet adapters GDB_REMOTE_CHAT Use gdb protocol for remote debugging gp0 National Instruments AT-GPIB and AT-GPIB/TNT board GPL_MATH_EMULATE Alternate x87 math emulation gsc0 Genius GS-4500 hand scanner. gus0 Gravis Ultrasound - Ultrasound, Ultrasound 16, Ultrasound MAX gzip Exec gzipped a.outs hea0 Efficient ENI-155p ATM PCI hfa0 FORE PCA-200E ATM PCI HW_WDOG i386 Define the i386 architecture I386_CPU Intel i386 processor I486_CPU Intel i486 processor i4b ISDN subsystem I586_CPU Intel Pentium processor I686_CPU Intel Pentium Pro and Pentium 2 processors IBCS2 SCO UNIX binary emulation. ic0 Philips i2c bus support. ident Identify the kernel configuration IDE_DELAY Specify probe delay for IDE devices ie0 AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210 iicbus0 Philips i2c bus support. INCLUDE_CONFIG_FILE Store this configuration file into the kernel binary itself INET Internet communications protocols intpm0 INTRO_USERCONFIG imply -c and show intro screen INVARIANTS Enable extra sanity checking of internal structures. IPDIVERT Divert sockets IPFILTER kernel ipfilter support IPFIREWALL Firewall IPSTEALTH support for stealth forwarding IPX Include IPX/SPX communications protocols IPXIP Include IPX in IP encapsulation isa0 ISA bus joy0 joystick KERNFS Kernel filesystem KTRACE Enable kernel tracing labpc0 National Instruments Lab-PC and Lab-PC+ le0 Digital Equipment EtherWorks 2 and EtherWorks 3 (DEPCA, DE100, DE101, DE200, DE201, DE202, DE203, DE204, DE205, DE422) lnc0 Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL) LOCKF_DEBUG loop Network loopback device support lpt0 Printer port LPT_DEBUG Printer driver debug matcd0 Matsushita/Panasonic CD-ROM MATH_EMULATE Support for x87 emulation MAXCONS Number of virtual consoles for syscons MAXDSIZ Maximum data size MAXMEM Specify explicit memory size maxusers Set kernel parameters based on the number of expected users. This parameter doesn't limit the number of users mcd0 Mitsumi CD-ROM MD5 Include an MD5 encryption routine in the kernel meteor0 Matrox Meteor video capture board meteor0 PCI video capture board MFS Memory File System MFS_ROOT MFS root file system mpu0 Roland MPU-401 stand-alone card MROUTING Multicast routing MSDOSFS MS DOS File System mse0 Logitech and ATI InPort bus mouse ports MSGBUF_SIZE Set size of kernel internal message buffer. mss0 Microsoft Sound System mx0 Fast ethernet adapters based on the Macronix 98713, 987615 ans 98725 series chips. NAPIC Set number of IO APICs on SMP NATM Native ATM NBUS Set number of busses on SMP NCPU Set number of CPUs on SMP ncr0 NCR 53C810 and 53C825 SCSI host adapters NDGBPORTS Defaults to 16*NDGB NETATALK Appletalk communications protocols NFS Network File System NINTR Set number of INTs on SMP npx0 Numeric Processing eXtension driver, for machines with math co-processor NSFBUFS Number of virtual buffers to map file VM pages for sendfile(2). NSWAPDEV Allow this many swap-devices. NTFS Microsoft NT File System NULLFS NULL filesystem opl0 Yamaha OPL-2 and OPL-3 FM - SB, SB Pro, SB 16, ProAudioSpectrum P1003_1B Set 1993 POSIX real time extensions. pas0 ProAudioSpectrum PCM and MIDI pass0 CAM passthrough driver pca0 PCM audio through your PC speaker pcf0 Philips PCF8584 ISA-bus controller. pci0 P