Book Freebsd
Book Freebsd
copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 by the
freebsd documentation project
welcome to freebsd! this handbook covers the installation and day to day
use of freebsd 4.5-release. this manual is a work in progress and is the
work of many individuals. many sections do not yet exist and some of those
that do exist need to be updated. if you are interested in helping with
this project, send email to the freebsd documentation project mailing list
<[email protected]>. the latest version of this document is always
available from the freebsd web site. it may also be downloaded in a
variety of formats and compression options from the freebsd ftp server or
one of the numerous mirror sites. if you would prefer to have a hard copy
of the handbook, you can purchase one at the freebsd mall. you may also
want to search the handbook.
#1. redistributions of source code (sgml docbook) must retain the above
copyright notice, this list of conditions and the following disclaimer
as the first lines of this file unmodified.
----------------------------------------------------------------------
table of contents
preface
i. getting started
1 introduction
1.1 synopsis
1.2 welcome to freebsd!
2 installing freebsd
2.1 synopsis
2.9 post-installation
2.11 troubleshooting
3 unix basics
3.1 synopsis
3.2 permissions
3.5 processes
3.7 shells
4.1 synopsis
4.2 overview of software installation
4.7 troubleshooting
5.1 synopsis
5.2 understanding x
6.1 synopsis
7.1 synopsis
7.2 the booting problem
7.3 the mbr, and boot stages one, two, and three
8.1 synopsis
8.2 introduction
8.9 groups
9.1 synopsis
10 security
10.1 synopsis
10.2 introduction
10.5 s/key
10.6 kerberos
10.7 firewalls
10.8 openssl
10.9 ipsec
10.10 openssh
11 printing
11.1 synopsis
11.2 introduction
11.7 troubleshooting
12 storage
12.1 synopsis
12.7 raid
13.1 synopsis
14 sound
14.1 synopsis
15 serial communications
15.1 synopsis
15.2 introduction
15.3 terminals
16.1 synopsis
17 advanced networking
17.1 synopsis
17.3 bridging
17.4 nfs
17.6 isdn
17.7 nis/yp
17.8 dhcp
17.9 dns
17.10 ntp
18 electronic mail
18.1 synopsis
18.4 troubleshooting
19.1 synopsis
20.1 synopsis
20.2 installation
iii. appendices
a. obtaining freebsd
b. bibliography
d. pgp keys
d.1 officers
d.3 developers
colophon
list of tables
list of figures
list of examples
a-1. checking out something from -current (ls(1)) and deleting it again:
----------------------------------------------------------------------
preface
intended audience
the freebsd newcomer will find that the first section of this book guides
the user through the freebsd installation process, and gently introduces
the concepts and conventions that underpin unix. working through this
section requires little more than the desire to explore, and the ability
to take on board new concepts as they are introduced.
once you've have travelled this far, the second, far larger, section of
the handbook is a comprehensive reference to all manner of topics of
interest to freebsd system administrators. some of these chapters may
recommend that you do some prior reading, and this is noted in the
synopsis at the beginning of each chapter.
this second edition is the culmination of over two years of work by the
dedicated members of the freebsd documentation project. the following are
the major changes in this new edition:
* the content has been logically reorganized into three parts: "getting
started", "system administration", and "appendices".
this book is split into three logically distinct sections. the first
section, getting started, covers the installation and basic usage of
freebsd. it is expected that the reader will follow these chapters in
sequence, possibly skipping chapters covering familiar topics. the second
section, system administration, covers a broad collection of subjects that
are of interest to more advanced freebsd users. each section begins with a
succinct synopsis that describes what the chapter covers and what the
reader is expected to already know. this is meant to allow the casual
reader to skip around to find chapters of interest. the third section
contains appendices of reference information.
chapter 1, introduction
chapter 2, installation
shows how to setup sound support for your system. also describes
some sample audio applications.
appendix b, bibliography
this book touches on many different subjects that may leave you
hungry for a more detailed explanation. the bibliography lists
many excellent books that are referenced in the text.
typographic conventions
italic
monospace
bold
user input
keys are rendered in bold to stand out from other text. key combinations
that are meant to be typed simultaneously are rendered with `+' between
the keys, such as:
ctrl+alt+del
keys that are meant to be typed in sequence will be separated with commas,
for example:
ctrl+x, ctrl+s
would mean that the user is expected to type the ctrl and x keys
simultaneously and then to type the ctrl and s keys simultaneously.
examples
# dd if=kern.flp of=/dev/fd0
% top
acknowledgments
the book you are holding represents the efforts of many hundreds of people
around the world. whether they sent in fixes for typos, or submitted
complete chapters, all the contributions have been useful.
i. getting started
this part of the freebsd handbook is for users and administrators who are
new to freebsd. these chapters:
table of contents
1 introduction
2 installing freebsd
3 unix basics
----------------------------------------------------------------------
chapter 1 introduction
1.1 synopsis
thank you for your interest in freebsd! the following chapter covers
various items about the freebsd project, such as its history, goals,
development model, and so on.
----------------------------------------------------------------------
----------------------------------------------------------------------
1.2.1 what can freebsd do?
* binary compatibility with many programs built for linux, sco, svr4,
bsdi and netbsd.
* source code for the entire system means you have the greatest degree
of control over your environment. why be locked into a proprietary
solution at the mercy of your vendor when you can have a truly open
system?
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; if
it can be done with a commercial unix product then it is more than likely
that you can do it with freebsd too! freebsd also benefits significantly
from the literally thousands of high quality applications developed by
research centers and universities around the world, often available at
little to 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 also be customized to an almost unheard of degree for special
applications or projects, and in ways not generally possible with
operating systems from most major commercial vendors. here is just a
sampling of some of the applications in which people are currently using
freebsd:
* ftp servers
* and more...
with freebsd, you can easily start out small with an inexpensive 386
class pc and upgrade all the way up to a quad-processor xeon with raid
storage as your enterprise grows.
* 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.
freebsd is available in both source and binary form on cdrom and via
anonymous ftp. please see appendix a for more information about obtaining
freebsd.
----------------------------------------------------------------------
* yahoo!
* apache
* be, inc.
* pair networks
* whistle communications
* microsoft
* hotmail
* sony japan
----------------------------------------------------------------------
1.3 about the freebsd project
----------------------------------------------------------------------
the freebsd project had its genesis in the early part of 1993, partially
as an outgrowth of the ``unofficial 386bsd patchkit'' by the patchkit's
last 3 coordinators: nate williams, rod grimes and myself.
386bsd was bill jolitz's operating system, which had been up to that point
suffering rather severely from almost a year's worth of neglect. as the
patchkit swelled ever more uncomfortably with each passing day, we were in
unanimous agreement that something had to be done and decided to try and
assist bill by providing this interim ``cleanup'' snapshot. those plans
came to a rude halt when bill jolitz suddenly decided to withdraw his
sanction from the project without any clear indication of what would be
done instead.
it did not take us long to decide that the goal remained worthwhile, even
without bill's support, and so we adopted the name ``freebsd'', coined by
david greenman. our initial objectives were set after consulting with the
system's current users and, once it became clear that the project was on
the road to perhaps even becoming a reality, i contacted walnut creek
cdrom with an eye towards improving freebsd's distribution channels for
those many unfortunates without easy access to the internet. walnut creek
cdrom not only supported the idea of distributing freebsd on cd but also
went so far as to provide the project with a machine to work on and a fast
internet connection. without walnut creek cdrom's almost unprecedented
degree of faith in what was, at the time, a completely unknown project, it
is quite unlikely that freebsd would have gotten as far, as fast, as it
has today.
the first cdrom (and general net-wide) distribution was freebsd 1.0,
released in december of 1993. this was based on the 4.3bsd-lite
(``net/2'') tape from u.c. berkeley, with many components also provided by
386bsd and the free software foundation. it was a fairly reasonable
success for a first offering, and we followed it with the highly
successful freebsd 1.1 release in may of 1994.
around this time, some rather unexpected storm clouds formed on the
horizon as novell and u.c. berkeley settled their long-running lawsuit
over the legal status of the berkeley net/2 tape. a condition of that
settlement was u.c. berkeley's concession that large parts of net/2 were
``encumbered'' code and the property of novell, who had in turn acquired
it from at&t some time previously. what berkeley got in return was
novell's ``blessing'' that the 4.4bsd-lite release, when it was finally
released, would be declared unencumbered and all existing net/2 users
would be strongly encouraged to switch. this included freebsd, and the
project was given until the end of july 1994 to stop shipping its own
net/2 based product. under the terms of that agreement, the project was
allowed one last release before the deadline, that release being freebsd
1.1.5.1.
freebsd then set about the arduous task of literally re-inventing itself
from a completely new and rather incomplete set of 4.4bsd-lite bits. the
``lite'' releases were light in part because berkeley's csrg had removed
large chunks of code required for actually constructing a bootable running
system (due to various legal requirements) and the fact that the intel
port of 4.4 was highly incomplete. it took the project until november of
1994 to make this transition, at which point it released freebsd 2.0 to
the net and on cdrom (in late december). despite being still more than a
little rough around the edges, the release was a significant success and
was followed by the more robust and easier to install freebsd 2.0.5
release in june of 1995.
the tree branched again on jan 20, 1999, leading to the 4.0-current and
3.x-stable branches. from 3.x-stable, 3.1 was released on february 15,
1999, 3.2 on may 15, 1999, 3.3 on september 16, 1999, 3.4 on december 20,
1999, and 3.5 on june 24, 2000, which was followed a few days later by a
minor point release update to 3.5.1, to incorporate some last-minute
security fixes to kerberos. this will be the final release in the 3.x
branch.
there was another branch on march 13, 2000, which saw the emergence of the
4.x-stable branch, now considered to be the "current -stable branch".
there have been several releases from it so far: 4.0-release came out in
march 2000, 4.1 was released in july 2000, 4.2 in november 2000, 4.3 in
april 2001, and 4.4 in september 2001. there will be more releases along
the 4.x-stable (releng_4) branch well into 2002.
----------------------------------------------------------------------
the goals of the freebsd project are to provide software that may be used
for any purpose and without strings attached. many of us have a
significant investment in the code (and project) and would certainly not
mind a little financial compensation now and then, but we are definitely
not prepared to insist on it. we believe that our first and foremost
``mission'' is to provide code to any and all comers, and for whatever
purpose, so that the code gets the widest possible use and provides the
widest possible benefit. this is, i believe, one of the most fundamental
goals of free software and one that we enthusiastically support.
that code in our source tree which falls under the gnu general public
license (gpl) or library general public license (lgpl) comes with slightly
more strings attached, though at least on the side of enforced access
rather than the usual opposite. due to the additional complexities that
can evolve in the commercial use of gpl software we do, however, prefer
software submitted under the more relaxed bsd copyright when it is a
reasonable option to do so.
----------------------------------------------------------------------
useful things to know about the freebsd project and its development
process, whether working independently or in close cooperation:
the committers are the people who have write access to the cvs
tree, and are thus authorized to make modifications to the freebsd
source (the term ``committer'' comes from the cvs(1) commit
command, which is used to bring new changes into the cvs
repository). the best way of making submissions for review by the
committers list is to use the send-pr(1) command, though if
something appears to be jammed in the system then you may also
reach them by sending mail to the freebsd committer's mailing list
<[email protected]>.
note: most members of the core team are volunteers when it comes
to freebsd development and do not benefit from the project
financially, so ``commitment'' should also not be misconstrued
as meaning ``guaranteed support.'' the ``board of directors''
analogy above is not actually very accurate, and it may be more
suitable to say that these are the people who gave up their
lives in favor of freebsd against their better judgment!
outside contributors
all we ask of those who would join us as freebsd developers is some of the
same dedication its current people have to its continued success!
----------------------------------------------------------------------
since our release of freebsd 2.0 in late 94, the performance, feature set,
and stability of freebsd has improved dramatically. the largest change is
a revamped virtual memory system with a merged vm/file buffer cache that
not only increases performance, but also reduces freebsd's memory
footprint, making a 5mb configuration a more acceptable minimum. other
enhancements include full nis client and server support, transaction tcp
support, dial-on-demand ppp, integrated dhcp support, an improved scsi
subsystem, isdn support, support for atm, fddi, fast and gigabit ethernet
(1000mbit) adapters, improved support for the latest adaptec controllers,
and many hundreds of bug fixes.
we have also taken the comments and suggestions of many of our users to
heart and have attempted to provide what we hope is a more sane and easily
understood installation process. your feedback on this (constantly
evolving) process is especially welcome!
a number of additional documents which you may find very helpful in the
process of installing and using freebsd may now also be found in the
/usr/share/doc directory on any machine running freebsd 2.1 or later. you
may view the locally installed manuals with any html capable browser using
the following urls:
/usr/share/doc/handbook/index.html
you can also view the master (and most frequently updated) copies at
http://www.freebsd.org/.
----------------------------------------------------------------------
2.1 synopsis
* the questions sysinstall will ask you, what they mean, and how to
answer them.
* read the supported hardware list that shipped with the version of
freebsd you are installing, and verify that your hardware is
supported.
----------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
if you want freebsd to use all your disk, then there is nothing more to
concern yourself with at this point -- you can skip to the next section.
however, if you need freebsd to co-exist with other operating systems then
you need to have a rough understanding of how data is laid out on the
disk, and how this affects you.
----------------------------------------------------------------------
each partition has a partition id, which is a number used to identify the
type of data on the partition. freebsd partitions have the partition id
165.
in general, each operating system that you use will identify partitions in
a particular way. for example, dos, and its descendants, like windows,
assign each primary and logical partition a drive letter, starting with
c:.
freebsd must be installed into a primary partition. freebsd can keep all
its data, including any files that you create, on this one partition.
however, if you have multiple disks, then you can create a freebsd
partition on all, or some, of them. when you install freebsd, you must
have one partition available. this might be a blank partition that you
have prepared, or it might be an existing partition that contains data
that you no longer care about.
if you are already using all the partitions on all your disks, then you
will have to free one of them for freebsd using the tools provided by the
other operating systems you use (e.g., fdisk on dos or windows).
if you have a spare partition then you can use that. however, you may need
to shrink one or more of your existing partitions first.
you can use a commercial tool such as partition magic to resize your
partitions to make space for freebsd. the tools directory on the cdrom
contains two free software tools which can carry out this task, fips and
presizer. documentation for both of these is in the same directory.
warning: incorrect use of these tools can delete the data on your disk.
be sure that you have recent, working backups before using them.
suppose that you have a computer with a single 4gb disk that already has a
version of windows installed, and you have split the disk in to two drive
letters, c: and d:, each of which is 2gb in size. you have 1gb of data on
c:, and 0.5gb of data on d:.
this means that your disk has two partitions on it, one per drive letter.
you can copy all your existing data from d: to c:, which will free up the
second partition, ready for freebsd.
suppose that you have a computer with a single 4gb disk, that already has
a version of windows installed. when you installed windows you created one
large partition, giving you a c: drive that is 4gb in size. you are
currently using 1.5gb of space, and want freebsd to have 2gb of space.
#1. backup your windows data, and then reinstall windows, asking for a 2gb
partition at install time.
#2. use one of the tools such as partition magic, described above, to
shrink your windows partition.
----------------------------------------------------------------------
you will need a dedicated disk for freebsd on the alpha. it is not
possible to share a disk with another operating system at this time.
depending on the specific alpha machine you have, this disk can either be
a scsi disk or an ide disk, as long as your machine is capable of booting
from it.
following the conventions of the digital / compaq manuals all srm input is
shown in uppercase. srm is case insensitive.
to find the names and types of disks in your machine, use the show device
command from the srm console prompt:
>>>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 is from a digital personal workstation 433au and shows three
disks attached to the machine. the first is a cdrom drive called dka0 and
the other two are disks and are called dkc0 and dkc100 respectively.
disks with names of the form dkx are scsi disks. for example dka100 refers
to a scsi with scsi target id 1 on the first scsi bus (a), whereas dkc300
refers to a scsi disk with scsi id 3 on the third scsi bus (c). devicename
pkx refers to the scsi host bus adapter. as seen in the show device output
scsi cdrom drives are treated as any other scsi hard disk drive.
ide disks have names similar to dqx, while pqx is the associated ide
controller.
----------------------------------------------------------------------
----------------------------------------------------------------------
#1. ip address.
#2. ip address of the default gateway.
#3. hostname.
if you do not know this information, then ask your system administrator or
service provider. they may say that this information is assigned
automatically, using dhcp. if so, make a note of this.
----------------------------------------------------------------------
if you dial up to an isp using a regular modem then you can still install
freebsd over the internet, it will just take a very long time.
----------------------------------------------------------------------
information about all the releases, including the errata for each release,
can be found on the release information section of the freebsd web site.
----------------------------------------------------------------------
freebsd can be installed from a number of different media; cdrom, dvd, ftp
(both anonymous and non-anonymous), nfs, tape, or an existing ms-dos
partition.
tip: if you have freebsd on cdrom or dvd, and your computer allows you
to boot from the cdrom or dvd (typically a bios option called ``boot
order'' or similar) then you can skip this section. the freebsd cdrom
and dvd images are bootable and can be used to install freebsd without
any other special preparation.
if you are not installing directly from cdrom, dvd, or ftp then you are
probably preparing your own installation media (e.g., an ms-dos
partition), which must be prepared before you install freebsd. this is a
slightly more advanced, infrequent activity, and is documented in section
2.13. this includes the scenario where you want to create your own ftp
site on your own network so that other computers can use your site as a
freebsd ftp installation site.
important: your ftp program must use binary mode to download these
disk images. some web browsers have been known to use text (or
ascii) mode, which will be apparent if you cannot boot from the
disks.
you must prepare one floppy disk per image file you had to download.
it is imperative that these disks are free from defects. the easiest
way to test this is to format the disks for yourself. do not trust
pre-formatted floppies.
the .flp files are not regular files you copy to the disk. instead,
they are images of the complete contents of the disk. this means that
you cannot use commands like dos' copy to write the files. instead,
you must use specific tools to write the images directly to the disk.
if you are using the floppies from the cdrom, and your cdrom is the e:
drive, then you would run this:
repeat this command for each .flp file, replacing the floppy disk each
time, being sure to label the disks with the name of the file that you
copied to them. adjust the command line as necessary, depending on
where you have placed the .flp files. if you do not have the cdrom,
then fdimage can be downloaded from the tools directory on the freebsd
ftp site.
# dd if=kern.flp of=/dev/fd0
----------------------------------------------------------------------
last chance: are you sure your want continue the installation?
if you're running this on a disk with data you wish to save then we
strongly encourage you to make proper backups before proceeding!
the install can be exited at any time prior to the final warning without
changing the contents of the hard drive. if you are concerned that you
have configured something incorrectly you can just turn the computer off
before this point, and no damage will be done.
----------------------------------------------------------------------
2.3.1 booting
#3. find the setting that controls which devices the system boots from.
this is commonly shown as a list of devices, such as floppy, cdrom,
first hard disk, and so on.
if you needed to prepare boot floppies, then make sure that the floppy
disk is selected. if you are booting from the cdrom then make sure
that that is selected instead. in case of doubt, you should consult
the manual that came with your computer, and/or its motherboard.
make the change, then save and exit. the computer should now restart.
if you are booting from cdrom, then you will need to turn on the
computer, and insert the cdrom at the first opportunity.
#1. the disks were not inserted early enough in the boot process.
leave them in, and try restarting your computer.
#2. the bios changes earlier did not work correctly. you should redo
that step until you get the right option.
#5. freebsd will start to boot. if you are booting from cdrom you will see
a display similar to this:
if you are booting from floppy disc, you will see a display similar to
this:
#6. irrespective of whether you booted from floppy or cdrom, the boot
process will then get to this point.
hit [enter] to boot immediately, or any other key for command prompt.
booting [kernel] in 9 seconds... _
either wait ten seconds, or press enter. this will then launch the
kernel configuration menu.
----------------------------------------------------------------------
#2. turn on the computer and wait for a boot monitor prompt.
if you are booting from cdrom, insert the cdrom into the drive and
type the following command to start the installation (substituting the
name of the appropriate cdrom drive if necessary):
#4. freebsd will start to boot. if you are booting from a floppy disc, at
some point you will see the message:
#5. irrespective of whether you booted from floppy or cdrom, the boot
process will then get to this point.
hit [enter] to boot immediately, or any other key for command prompt.
booting [kernel] in 9 seconds... _
either wait ten seconds, or press enter. this will then launch the
kernel configuration menu.
----------------------------------------------------------------------
when the kernel starts, each driver checks the system to see whether or
not the hardware it supports exists on your system. if it does, then the
driver configures the hardware and makes it available to the rest of the
kernel.
many older devices are called isa devices--as opposed to pci devices. the
isa specification requires each device to have some information hard coded
into it, typically the interrupt request line number (irq) and io port
address that the driver uses. this information is commonly set by using
physical jumpers on the card, or by using a dos based utility.
this was often a source of problems, because it was not possible to have
two devices that shared the same irq or port address.
newer devices follow the pci specification, which does not require this,
as the devices are supposed to cooperate with the bios, and be told which
irq and io port addresses to use.
if you have any isa devices in your computer then freebsd's driver for
that device will need to be configured with the irq and port address that
you have set the card to. this is why carrying out an inventory of your
hardware (see section 2.2.1) can be useful.
unfortunately, the default irqs and memory ports used by some drivers
clash. this is because some isa devices are shipped with irqs or memory
ports that clash. the defaults in freebsd's drivers are deliberately set
to mirror the manufacturer's defaults, so that, out of the box, as many
devices as possible will work.
it becomes an issue when you are installing freebsd for the first time
because the kernel used to carry out the install has to contain as many
drivers as possible, so that many different hardware configurations can be
supported. this means that some of those drivers will have conflicting
configurations. the devices are probed in a strict order, and if you own a
device that is probed late in the process, but conflicted with an earlier
probe, then your hardware might not function or be probed correctly when
you install freebsd.
because of this, the first thing you have the opportunity to do when
installing freebsd is look at the list of drivers that are configured in
to the kernel, and either disable some of them, if you do not own that
device, or confirm (and alter) the driver's configuration if you do own
the device but the defaults are wrong.
figure 2-1 shows the first kernel configuration menu. we recommend that
you choose the start kernel configuration in full-screen visual mode
option, as it presents the easiest interface for the new user.
the kernel configuration screen (figure 2-2) is then divided into four
sections.
#1. a collapsible list of all the drivers that are currently marked as
``active'', subdivided in to groups such as storage, and network. each
driver is shown as a description, its two three letter driver name,
and the irq and memory port used by that driver. in addition, if an
active driver conflicts with another active driver then conf is shown
next to the driver name. this section also shows the total number of
conflicting drivers that are currently active.
#2. drivers that have been marked inactive. they remain in the kernel, but
they will not probe for their device when the kernel starts. these are
subdivided in to groups in the same way as the active driver list.
#3. more detail about the currently selected driver, including its irq and
memory port address.
#4. information about the keystrokes that are valid at this point in time.
at this point there will always be conflicts listed. do not worry about
this, it is to be expected; all the drivers are enabled, and as has
already been explained, some of them will conflict with one another.
you now have to work through the list of drivers, resolving the conflicts.
#1. press x. this will completely expand the list of drivers, so you can
see all of them. you will need to use the arrow keys to scroll back
and forth through the active driver list.
#2. disable all the drivers for devices that you do not have. to disable a
driver, highlight it with the arrow keys and press del. the driver
will be moved to the inactive drivers list.
if you inadvertently disable a device that you need then press tab to
switch to the inactive drivers list, select the driver that you
disabled, and press enter to move it back to the active list.
important: do not disable sc0. this controls the screen, and you
will need this unless you are installing over a serial cable.
#3. if there are no conflicts listed then you can skip this step.
otherwise, the remaining conflicts need to be examined. if they do not
have the indication of an ``allowed conflict'' in the message area,
then either the irq/address for device probe will need to be changed,
or the irq/address on the hardware will need to be changed.
if you are not sure what these figures should be then you can try
using -1. some freebsd drivers can safely probe the hardware to
discover what the correct value should be, and a value of -1
configures them to do this.
the procedure for changing the address on the hardware varies from
device to device. for some devices you may need to physically remove
the card from your computer and adjust jumper settings or dip
switches. other cards may have come with a dos floppy that contains
the programs used to reconfigure the card. in any case, you should
refer to the documentation that came with the device. this will
obviously entail restarting your computer, so you will need to boot
back in to the freebsd installation routine when you have reconfigured
the card.
#4. when all the conflicts have been resolved the screen will look similar
to figure 2-4.
as you can see, the active driver list is now much smaller, with only
drivers for the hardware that actually exists being listed.
you can now save these changes, and move on to the next step of the
install. press q to quit the device configuration interface. this
message will appear.
answer y to save the parameters and the probing will start. after
displaying the probe results in white on black text sysinstall will
start and display its main menu (figure 2-5).
----------------------------------------------------------------------
2.3.3 reviewing the device probe results
the last few hundred lines that have been displayed on screen are stored
and can be reviewed.
to review the buffer, press scroll lock. this turns on scrolling in the
display. you can then use the arrow keys, or pageup and pagedown to view
the results. press scroll lock again to stop scrolling,
do this now, to review the text that scrolled off the screen when the
kernel was carrying out the device probes. you will see text similar to
figure 2-6, although the precise text will differ depending on the devices
that you have in your computer.
check the probe results carefully to make sure that freebsd found all the
devices you expected. if a device was not found, then it will not be
listed. if the device's driver required configuring with the irq and port
address then you should check that you entered them correctly.
if you need to make changes to the userconfig device probing, its easy to
exit the sysinstall program and start over again. its also a good way to
become more familiar with the process.
use the arrow keys to select exit install from the main install screen
menu. the following message will display:
[ yes ] no
the install program will start again if the cdrom is left in the drive and
[yes] is selected.
----------------------------------------------------------------------
the sysinstall menu system is controlled by the arrow keys, enter, space.
and other keys. a detailed description of these keys, and what they do, is
contained in sysinstall's usage information.
to review this information, ensure that the usage entry is highlighted and
that the [select] button is selected, as shown in figure 2-8, then press
enter.
the instructions for using the menu system will be displayed. after
reviewing them, press enter to return to the main menu.
----------------------------------------------------------------------
from the main menu, select doc with the arrow keys and press enter.
to view a document, select it with the arrow keys and press enter. when
finished reading a document, pressing enter will return to the
documentation menu.
to return to the main installation menu, select exit with the arrow keys
and press enter.
----------------------------------------------------------------------
to change the keyboard mapping, use the arrow keys to select keymap from
the menu and press enter
----------------------------------------------------------------------
the default values are usually fine for most users and do not need to be
changed.
the description of the selected item will appear at the bottom of the
screen highlighted in blue. notice that one of the options is use defaults
to reset all values to startup defaults.
----------------------------------------------------------------------
the standard installation is the option recommended for those new to unix
or freebsd. use the arrow keys to select standard and then press enter to
start the installation.
----------------------------------------------------------------------
your first task is to allocate disk space for freebsd, and label that
space so that sysinstall can prepare it. in order to do this you need to
know how freebsd expects to find information on the disk.
----------------------------------------------------------------------
more expensive systems with scsi controllers often include bios extensions
which allow the scsi drives to be re-ordered in a similar fashion for up
to seven drives.
+------------------------------------------------------------------------+
| an illustration from the files of bill and fred's exceptional |
| adventures: |
| |
| bill breaks-down an older wintel box to make another freebsd box for |
| fred. bill installs a single scsi drive as scsi unit zero and installs |
| freebsd on it. |
| |
| fred begins using the system, but after several days notices that the |
| older scsi drive is reporting numerous soft errors and reports this |
| fact to bill. |
| |
| after several more days, bill decides it is time to address the |
| situation, so he grabs an identical scsi drive from the disk drive |
| ``archive'' in the back room. an initial surface scan indicates that |
| this drive is functioning well, so bill installs this drive as scsi |
| unit four and makes an image copy from drive zero to drive four. now |
| that the new drive is installed and functioning nicely, bill decides |
| that it is a good idea to start using it, so he uses features in the |
| scsi bios to re-order the disk drives so that the system boots from |
| scsi unit four. freebsd boots and runs just fine. |
| |
| fred continues his work for several days, and soon bill and fred |
| decide that it is time for a new adventure -- time to upgrade to a |
| newer version of freebsd. bill removes scsi unit zero because it was a |
| bit flaky and replaces it with another identical disk drive from the |
| ``archive.'' bill then installs the new version of freebsd onto the |
| new scsi unit zero using fred's magic internet ftp floppies. the |
| installation goes well. |
| |
| fred uses the new version of freebsd for a few days, and certifies |
| that it is good enough for use in the engineering department...it is |
| time to copy all of his work from the old version. so fred mounts scsi |
| unit four (the latest copy of the older freebsd version). fred is |
| dismayed to find that none of his precious work is present on scsi |
| unit four. |
| |
| where did the data go? |
| |
| when bill made an image copy of the original scsi unit zero onto scsi |
| unit four, unit four became the ``new clone,'' when bill re-ordered |
| the scsi bios so that he could boot from scsi unit four, he was only |
| fooling himself. freebsd was still running on scsi unit zero. making |
| this kind of bios change will cause some or all of the boot and loader |
| code to be fetched from the selected bios drive, but when the freebsd |
| kernel drivers take-over, the bios drive numbering will be ignored, |
| and freebsd will transition back to normal drive numbering. in the |
| illustration at hand, the system continued to operate on the original |
| scsi unit zero, and all of fred's data was there, not on scsi unit |
| four. the fact that the system appeared to be running on scsi unit |
| four was simply an artifact of human expectations. |
| |
| we are delighted to mention that no data bytes were killed or harmed |
| in any way by our discovery of this phenomenon. the older scsi unit |
| zero was retrieved from the bone pile, and all of fred's work was |
| returned to him, (and now bill knows that he can count as high as |
| zero). |
| |
| although scsi drives were used in this illustration, the concepts |
| apply equally to ide drives. |
+------------------------------------------------------------------------+
----------------------------------------------------------------------
the smallest unit of organization that freebsd uses to find files is the
filename. filenames are case-sensitive, which means that readme.txt and
readme.txt are two separate files. freebsd does not use the extension
(.txt) of a file to determine whether the file is program, or a document,
or some other form of data.
files and directories are referenced by giving the file or directory name,
followed by a forward slash, /, followed by any other directory names that
are necessary. if you have directory foo, which contains directory bar,
which contains the file readme.txt, then the full name, or path to the
file is foo/bar/readme.txt.
so far this is probably similar to any other operating system you may have
used. there are a few differences; for example, dos uses \ to separate
file and directory names, while macos uses :.
freebsd does not use drive letters, or other drive names in the path. you
would not write c:/foo/bar/readme.txt on freebsd.
call a the root filesystem. if you used the ls command to view the
contents of this directory you would see two subdirectories, a1 and a2.
the directory tree looks like this.
/
|
+--- a1
|
`--- a2
/
|
+--- a1
| |
| +--- b1
| |
| `--- b2
|
`--- a2
any files that are in the b1 or b2 directories can be reached with the
path /a1/b1 or /a1/b2 as necessary. any files that were in /a1 have been
temporarily hidden. they will reappear if b is unmounted from a.
if b had been mounted on a2 then the diagram would look like this;
/
|
+--- a1
|
`--- a2
|
+--- b1
|
`--- b2
/
|
+--- a1
|
`--- a2
|
+--- b1
| |
| +--- c1
| |
| `--- c2
|
`--- b2
/
|
+--- a1
| |
| +--- c1
| |
| `--- c2
|
`--- a2
|
+--- b1
|
`--- b2
if you are familiar with dos, this is similar, although not identical, to
the join command.
it is entirely possible to have one large root filesystem, and not need to
create any others. there are some drawbacks to this approach, and one
advantage.
* freebsd's filesystems are very robust should you lose power. however,
a power loss at a critical point could still damage the structure of
the filesystem. by splitting your data over multiple filesystems it is
more likely that the system will still come up, making it easier for
you to restore from backup as necessary.
filesystems are contained in partitions. this does not have the same
meaning as the earlier usage of the term partition in this chapter,
because of freebsd's unix heritage. each partition is identified by a
letter, a through to h. each partition can only contain one filesystem,
which means that filesystems are often described by either their typical
mount point on the root filesystem, or the letter of the partition they
are contained in.
freebsd also uses disk space for swap space. swap space provides freebsd
with virtual memory. this allows your computer to behave as though it has
much more memory than it actually does. when freebsd runs out of memory it
moves some of the data that is not currently being used to the swap space,
and moves it back in (moving something else out) when it needs it.
partition convention
a normally contains the root filesystem
b normally contains swap space
c normally the same size as the enclosing slice. this allows
utilities that need to work on the entire slice (for example, a
bad block scanner) to work on the c partition. you would not
normally create a filesystem on this partition.
d partition d used to have a special meaning associated with it,
although that is now gone. to this day, some tools may operate
oddly if told to work on partition d, so sysinstall will not
normally create partition d.
finally, each disk on the system is identified. a disk name starts with a
code that indicates the type of disk, and then a number, indicating which
disk it is. unlike slices, disk numbering starts at 0. common codes that
you will see are listed in table 2-2.
when referring to a partition freebsd requires that you also name the
slice and disk that contains the partition, and when referring to a slice
you should also refer to the disk name. do this by listing the disk name,
s, the slice number, and then the partition letter. examples are shown in
example 2-3.
example 2-4 shows a conceptual model of the disk layout that should help
make things clearer.
in order to install freebsd you must first configure the disk slices, then
create partitions within the slice you will use for freebsd, and then
create a filesystem (or swap space) in each partition, and decide where
that filesystem will be mounted.
code meaning
ad atapi (ide) disk
da scsi direct access disk
acd atapi (ide) cdrom
cd scsi cdrom
fd floppy disk
name meaning
ad0s1a the first partition (a) on the first slice (s1) on the first ide
disk (ad0).
da1s2e the fifth partition (e) on the second slice (s2) on the second scsi
disk (da1).
this diagram shows freebsd's view of the first ide disk attached to the
system. assume that the disk is 4gb in size, and contains two 2gb slices
(dos partitions). the first slice contains a dos disk, c:, and the second
slice contains a freebsd installation. this example freebsd installation
has three partitions, and a swap partition.
the three partitions will each hold a filesystem. partition a will be used
for the root filesystem, e for the /var directory hierarchy, and f for the
/usr directory hierarchy.
.-----------------. --.
| | |
| dos / windows | |
: : > first slice, ad0s1
: : |
| | |
:=================: ==: --.
| | | partition a, mounted as / |
| | > referred to as ad0s2a |
| | | |
:-----------------: ==: |
| | | partition b, used as swap |
| | > referred to as ad0s2b |
| | | |
:-----------------: ==: | partition c, no
| | | partition e, used as /var > filesystem, all
| | > referred to as ad0s2e | of freebsd slice,
| | | | ad0s2c
:-----------------: ==: |
| | | |
: : | partition f, used as /usr |
: : > referred to as ad0s2f |
: : | |
| | | |
| | --' |
`-----------------' --'
----------------------------------------------------------------------
note: no changes you make at this point will be written to the disk. if
you think you have made a mistake and want to start again you can use
the menus to exit sysinstall and try again. if you get confused and can
not see how to exit you can always turn your computer off.
message
in the next menu, you will need to set up a dos-style ("fdisk")
partitioning scheme for your hard disk. if you simply wish to devote
all disk space to freebsd (overwriting anything else that might be on
the disk(s) selected) then use the (a)ll command to select the default
partitioning scheme followed by a (q)uit. if you wish to allocate only
free space to freebsd, move to a partition marked "unused" and use the
(c)reate command.
[ ok ]
press enter as instructed. you will then be shown a list of all the hard
drives that the kernel found when it carried out the device probes. figure
2-16 shows an example from a system with two ide disks. they have been
called ad0 and ad2.
you might be wondering why ad1 is not listed here. why has it been missed?
consider what would happen if you had two ide hard disks, one as the
master on the first ide controller, and one as the master on the second
ide controller. if freebsd numbered these as it found them, as ad0 and ad1
then everything would work.
but if you then added a third disk, as the slave device on the first ide
controller, it would now be ad1, and the previous ad1 would become ad2.
because device names (such as ad1s1a) are used to find filesystems, you
may suddenly discover that some of your filesystems no longer appear
correctly, and you would need to change your freebsd configuration.
to work around this, the kernel can be configured to name ide disks based
on where they are, and not the order in which they were found. with this
scheme the master disk on the second ide controller will always be ad2,
even if there are no ad0 or ad1 devices.
this configuration is the default for the freebsd kernel, which is why
this display shows ad0 and ad2. the machine on which this screenshot was
taken had ide disks on both master channels of the ide controllers, and no
disks on the slave channels.
you should select the disk on which you want to install freebsd, and then
press [ ok ]. fdisk will start, with a display similar to that shown in
figure 2-17.
the first section, covering the first two lines of the display, shows
details about the currently selected disk, including its freebsd name, the
disk geometry, and the total size of the disk.
the second section shows the slices that are currently on the disk, where
they start and end, how large they are, the name freebsd gives them, and
their description and sub-type. this example shows two small unused
slices, which are artifacts of disk layout schemes on the pc. it also
shows one large fat slice, which almost certainly appears as c: in dos /
windows, and an extended slice, which may contain other drive letters for
dos / windows.
the third section shows the commands that are available in fdisk.
what you do now will depend on how you want to slice up your disk.
if you want to use freebsd for the entire disk (which will delete all the
other data on this disk when you confirm that you want sysinstall to
continue later in the installation process) then you can press a, which
corresponds to the use entire disk option. the existing slices will be
removed, and replaced with a small area flagged as unused (again, an
artifact of pc disk layout), and then one large slice for freebsd. if you
do this then you should then select the newly created freebsd slice using
the arrow keys, and press s to mark the slice as being bootable. the
screen will then look very similar to figure 2-18. note the a in the flags
column, which indicates that this slice is active, and will be booted
from.
if you will be deleting an existing slice to make space for freebsd then
you should select the slice using the arrow keys, and then press d. you
can then press c, and be prompted for size of slice you want to create.
enter the appropriate figure and press enter.
if you have already made space for freebsd (perhaps by using a tool such
as partition magic) then you can press c to create a new slice. again, you
will be prompted for the size of slice you would like to create.
when finished, press q. your changes will be saved in sysinstall, but will
not yet be written to disk.
----------------------------------------------------------------------
you now have the option to install a boot manager. in general, you should
choose to install the freebsd boot manager if:
* you have more than one drive, and have installed freebsd onto a drive
other than the first one.
* you have installed freebsd alongside another operating system on the
same disk, and you want to choose whether to start freebsd or the
other operating system when you start the computer.
the help screen, reached by pressing f1, discusses the problems that can
be encountered when trying to share the hard disk between operating
systems.
----------------------------------------------------------------------
if there is more than one drive, it will return to the select drives
screen after the boot manager selection. if you wish to install freebsd on
to more than one disk, then you can select another disk here and repeat
the slice process using fdisk,
the tab key toggles between the last drive selected, [ ok ], and
[ cancel ].
press the tab once to toggle to the [ ok ], then press enter to continue
with the installation.
----------------------------------------------------------------------
you must now create some partitions inside each slice that you have just
created. remember that each partition is lettered, from a through to h,
and that partitions b, c, and d have conventional meanings that you should
adhere to.
this scheme features four partitions--one for swap space, and three for
filesystems.
if you will be installing freebsd on to more than one disk then you must
also create partitions in the other slices that you configured. the
easiest way to do this is to create two partitions on each disk, one for
the swap space, and one for a filesystem.
having chosen your partition layout you can now create it using
sysinstall. you will see this message.
message
now, you need to create bsd partitions inside of the fdisk
partition(s) just created. if you have a reasonable amount of disk
space (200mb or more) and don't have any special requirements, simply
use the (a)uto command to allocate space automatically. if you have
more specific needs or just don't care for the layout chosen by
(a)uto, press f1 for more information on manual layout.
[ ok ]
figure 2-21 shows the display when you first start disklabel. the display
is divided in to three sections.
the first few lines show the name of the disk you are currently working
on, and the slice that contains the partitions you are creating (at this
point disklabel calls this the partition name rather than slice name).
this display also shows the amount of free space within the slice; that
is, space that was set aside in the slice, but that has not yet been
assigned to a partition.
the middle of the display shows the partitions that have been created, the
name of the filesystem that each partition contains, their size, and some
options pertaining to the creation of the filesystem.
the bottom third of the screen shows the keystrokes that are valid in
disklabel.
disklabel can automatically create partitions for you and assign them
default sizes. try this now, by pressing a. you will see a display similar
to that shown in figure 2-22. depending on the size of the disk you are
using the defaults may or may not be appropriate. this does not matter, as
you do not have to accept the defaults.
note: beginning with freebsd 4.5, the default partitioning assigns the
/tmp directory its own partition instead of being part of the /
partition. this helps avoid filling the / partition with temporary
files.
to delete the suggested partitions, and replace them with your own, use
the arrow keys to select the first partition, and press d to delete it.
repeat this to delete all the suggested partitions.
to create the first partition (a, mounted as /), make sure the disk
information at the top of the screen is selected, and press c. a dialog
box will appear prompting you for the size of the new partition (as shown
in figure 2-23). you can enter the size as the number of disk blocks you
want to use, or, more usefully, as a number followed by either m for
megabytes, g for gigabytes, or c for cylinders.
the default size shown will create a partition that takes up the rest of
the slice. if you are using the partition sizes described earlier, then
delete the existing figure using backspace, and then type in 64m, as shown
in figure 2-24. then press [ ok ].
having chosen the partition's size you will then asked whether this
partition will contain a filesystem or swap space. the dialog box is shown
in figure 2-25. this first partition will contain a filesystem, so check
that fs is selected and then press enter.
finally, because you are creating a filesystem, you must tell disklabel
where the filesystem is to be mounted. the dialog box is shown in figure
2-26. the root filesystem's mount point is /, so type /, and then press
enter.
the display will then update to show you the newly created partition. you
should repeat this procedure for the other partitions. when you create the
swap partition you will not be prompted for the filesystem mount point, as
swap partitions are never mounted. when you create the final partition,
/usr, you can leave the suggested size as is, to use the rest of the
slice.
your final freebsd disklabel editor screen will appear similar to figure
2-27, although your values chosen may be different. press q to finish.
----------------------------------------------------------------------
press f1 for more information on the distribution set options and what
they contain. when finished reviewing the help, pressing enter will return
to the select distributions menu.
the default xfree86 version installed is the 3.x branch. you should check
to see whether your video card is supported at the xfree86 web site. if it
is only supported under the 4.x branch, then you will need to install and
configure xfree86 4.x after installation. select a distribution without x
and refer to chapter 5 for more information.
----------------------------------------------------------------------
the installation program does not check to see if you have adequate space.
select this option only if you have adequate hard disk space.
this will give you ready access to over 6,600 ported software packages,
at a cost of around 100mb of disk space when "clean" and possibly much
more than that if a lot of the distribution tarballs are loaded
(unless you have the extra cds from a freebsd cd/dvd distribution
available and can mount it on /cdrom, in which case this is far less
of a problem).
the ports collection is a very valuable resource and well worth having
on your /usr partition, so it is advisable to say yes to this option.
for more information on the ports collection & the latest ports,
visit:
http://www.freebsd.org/ports
[ yes ] no
select [ yes ] with the arrow keys to install the ports collection or [ no
] to skip this option. press enter to continue. the choose distributions
menu will redisplay.
if satisfied with the options, select exit with the arrow keys, ensure
that [ ok ] is highlighted, and press enter to continue.
----------------------------------------------------------------------
if installing from a cdrom, use the arrow keys to highlight install from a
freebsd cd/dvd. ensure that [ ok ] is highlighted, then press enter to
proceed with the installation.
press f1 to display the online help for installation media. press enter to
return to the media selection menu.
ftp installation modes: there are three ftp installation modes you can
choose from: active ftp, passive ftp, or via a http proxy.
this option will make all ftp transfers use ``active'' mode.
this will not work through firewalls, but will often work with
older ftp servers that do not support passive mode. if your
connection hangs with passive mode (the default), try active!
ftp via a http proxy, install from an ftp server through a http proxy
for a proxy ftp server, you should usually give the name of the server
you really want as a part of the username, after an ``@'' sign. the
proxy server then ``fakes'' the real server. for example, assuming you
want to install from ftp.freebsd.org, using the proxy ftp server
foo.example.com, listening on port 1024.
in this case, you go to the options menu, set the ftp username to
[email protected], and the password to your email address. as your
installation media, you specify ftp (or passive ftp, if the proxy
supports it), and the url ftp://foo.example.com:1234/pub/freebsd.
----------------------------------------------------------------------
the installation can now proceed if desired. this is also the last chance
for aborting the installation to prevent changes to the hard drive.
if you're running this on a disk with data you wish to save then we
strongly encourage you to make proper backups before proceeding!
[ yes ] no
message
if you wish to re-enter this utility after the system is up, you may
do so by typing: /stand/sysinstall .
[ ok ]
message
installation complete with some errors. you may wish to scroll
through the debugging messages on vty1 with the scroll-lock feature.
you can also choose "no" at the next prompt and go back into the
installation menus to try and retry whichever operations have failed.
[ ok ]
----------------------------------------------------------------------
2.9 post-installation
----------------------------------------------------------------------
if you previously configured ppp for an ftp install, this screen will not
display and can be configured later as described above.
[ yes ] no
select the interface to be configured with the arrow keys and press enter.
yes [ no ]
in this private local area network the current internet type protocol
(ipv4) was sufficient and [ no ] was selected with the arrow keys and
enter pressed.
if you want to try the new internet protocol (ipv6), choose [ yes ] and
press enter. it will take several seconds to scan for ra servers.
yes [ no ]
if dhcp (dynamic host configuration protocol) is not required select [ no
] with the arrow keys and press enter.
host
domain
the name of the domain that your machine is in, e.g. example.com
for this case.
ipv4 gateway
name server
ipv4 address
netmask
the address block being used for this local area network is a
class c block (192.168.0.0 - 192.168.255.255). the default netmask
is for a class c network (255.255.255.0).
choosing [ yes ] and pressing enter will bring the machine up on the
network and be ready for use after leaving leaving the installation.
----------------------------------------------------------------------
[ yes ] no
if the machine will be acting as the gateway for a local area network and
forwarding packets between other machines then select [ yes ] and press
enter. if the machine is a node on a network then select [ no ] and press
enter to continue.
----------------------------------------------------------------------
yes [ no ]
[ yes ] no
[ yes ] no
after adding the desired services, pressing esc will display a menu which
will allow exiting and saving the changes.
----------------------------------------------------------------------
yes [ no ]
----------------------------------------------------------------------
selecting the default [ no ] and pressing enter will still allow users who
have accounts with passwords to use ftp to access the machine.
----------------------------------------------------------------------
anyone can access your machine if you elect to allow anonymous ftp
connections. the security implications should be considered before
enabling this option. for more information about security see chapter 10.
to allow anonymous ftp, use the arrow keys to select [ yes ] and press
enter. the following screens (or similar) will display:
uid: the user id you wish to assign to the anonymous ftp user.
all files uploaded will be owned by this id.
group: which group you wish the anonymous ftp user to be in.
upload subdirectory:
the ftp root directory will be put in /var by default. if you do not have
enough room there for the anticipated ftp needs, the /usr directory could
be used by setting the ftp root directory to /usr/ftp.
when you are satisfied with the values, press enter to continue.
[ yes ] no
if you select [ yes ] and press enter, an editor will automatically start
allowing you to edit the message.
this is a text editor called ee. use the instructions to change the
message or change the message later using a text editor of your choice.
note the file name/location at the bottom.
press esc and a pop-up menu will default to a) leave editor. press enter
to exit and continue.
----------------------------------------------------------------------
----------------------------------------------------------------------
yes [ no ]
message
operating as an nfs server means that you must first configure an
/etc/exports file to indicate which hosts are allowed certain kinds of
access to your local file systems.
press [enter] now to invoke an editor on /etc/exports
[ ok ]
press enter to continue. a text editor will start allowing the exports
file to be created and edited.
use the instructions to add the actual exported filesystems now or later
using a text editor of your choice. note the filename/location at the
bottom of the editor screen.
press esc and a pop-up menu will default to a) leave editor. press enter
to exit and continue.
----------------------------------------------------------------------
yes [ no ]
----------------------------------------------------------------------
please note that the security profile is just a default setting. all
programs can be enabled and disabled after you have installed freebsd by
editing or adding the appropriate line(s) to /etc/rc.conf. for more
information, please see the rc.conf(5) manual page.
the following table describes what each of the security profiles does. the
columns are the choices you have for a security profile, and the rows are
the program or feature that the profile enables or disables.
+------------------------------------------------------------------------+
| | extreme | moderate |
|--------------------------+-----------------------+---------------------|
| sendmail(8) | no | yes |
|--------------------------+-----------------------+---------------------|
| sshd(8) | no | yes |
|--------------------------+-----------------------+---------------------|
| portmap(8) | no | maybe [a] |
|--------------------------+-----------------------+---------------------|
| nfs server | no | yes |
|--------------------------+-----------------------+---------------------|
| securelevel(8) | yes (2) [b] | no |
|------------------------------------------------------------------------|
| notes: |
| a. the portmapper is enabled if the machine has been configured as an |
| nfs client or server earlier in the installation. |
| b. if you choose a security profile that sets the securelevel (extreme |
| or high), you must be aware of the implications. please read the |
| init(8) manual page and pay particular attention to the meanings of |
| the security levels, or you may have significant trouble later! |
+------------------------------------------------------------------------+
[ yes ] no
use the arrow keys to choose medium unless your are sure that another
level is required for your needs. with [ ok ] highlighted, press enter.
message
[ok]
message
[ok]
warning: the security profile is not a silver bullet! even if you use
the extreme setting, you need to keep up with security issues by reading
an appropriate mailing list, using good passwords and passphrases, and
generally adhering to good security practices. it simply sets up the
desired security to convenience ratio out of the box.
----------------------------------------------------------------------
[ yes ] no
to view and configure the options, select [ yes ] and press enter.
a commonly used option is the screensaver. use the arrow keys to select
saver and then press enter.
select the desired screen saver using the arrow keys and then press enter.
the system console configuration menu will redisplay.
the default time interval is 300 seconds. to change the time interval,
select saver again. at the screensaver options menu, select timeout using
the arrow keys and press enter. a pop-up menu will appear:
the value can be changed, then select [ ok ] and press enter to return to
the system console configuration menu.
selecting exit and pressing enter will continue with the post-installation
configurations.
----------------------------------------------------------------------
[ yes ] no
yes [ no ]
the appropriate region is selected using the arrow keys and then press
enter.
select the appropriate country using the arrow keys and press enter.
the appropriate time zone is selected using the arrow keys and pressing
enter.
confirmation
does the abbreviation 'edt' look reasonable?
[ yes ] no
confirm the abbreviation for the time zone is correct. if it looks okay,
press enter to continue with the post-installation configuration.
----------------------------------------------------------------------
[ yes ] no
selecting [ yes ] and pressing enter will allow running linux software on
freebsd. the install will proceed to add the appropriate packages for
linux compatibility.
----------------------------------------------------------------------
this option will allow you to cut and paste text in the console and user
programs with a 3-button mouse. if using a 2-button mouse, refer to manual
page, moused(8), after installation for details on emulating the 3-button
style. this example depicts a non-usb mouse.
[ yes ] no
select [ yes ] for a non-usb mouse or [ no ] for a usb mouse and press
enter.
the mouse used in this example is a ps/2 type, so the default auto was
appropriate. to change protocol, use the arrow keys to select another
option. ensure that [ ok ] is highlighted and press enter to exit this
menu.
this system had a ps/2 mouse, so the default ps/2 was appropriate. to
change the port, use the arrow keys and then press enter.
the cursor moved around the screen so the mouse daemon is running:
select [ yes ] to return to the previous menu then select exit with the
arrow keys and press enter to return to continue with the
post-installation configuration.
----------------------------------------------------------------------
[ yes ] no
if you have graphics card and monitor information, select [ yes ] and
press enter to proceed with configuring the x server.
message
you have configured and been running the mouse daemon.
choose "/dev/sysmouse" as the mouse port and "sysmouse" or
"mousesystems" as the mouse protocol in the x configuration utility.
[ ok ]
this indicates that the mouse daemon previously configured has been
detected. press enter to continue.
[ ok ]
press enter to switch to the graphics mode and continue. it will not try
to switch to the graphics mode until enter is pressed. the screen will go
black and then shortly a screen with a large x in the center will appear.
be patient and wait.
after a few more moments, the xf86setup introduction will display. read
all instructions carefully. press enter to continue.
xf86setup overview
along the top of the configuration tool there are buttons indicating the
areas to be configured. you should be able to use the mouse if it was
previously configured and select each item by clicking on it. review each
area and make appropriate selections for your system.
#1. mouse
after completing your selections, click on the apply and check the
mouse actions are working properly. if further adjustment is needed,
make them and recheck the operation by clicking on apply again. when
finished, move on to the next item.
#2. keyboard
select the language layout for your keyboard. the default layout is
u.s. english. if you are not using a u.s. keyboard, you may need to
additionally select a variant.
there are other options under group shift/lock behavior and control
key position that can be selected if desired. generally the default
settings are fine.
#3. card
select the appropriate video card from the list using the scrollbar.
clicking on your card will show as ``card selected:'' above the list
box.
#4. monitor
there are two ways to proceed. one method requires that you enter the
horizontal and vertical sweep capabilities of your monitor in the text
boxes.
choosing one of the monitor options listed that the monitor is the
other method. after selecting a listed option, the horizontal and
vertical sweep rates that will be used will display. compare those to
your monitor specifications. the monitor must be capable of using
those ranges.
do not exceed the ratings of your monitor. damage could occur. if you
have doubts select abort and get the information. the remainder of the
installation process will be unaffected and configuring the x-server
can be done later using /stand/sysinstall.
#5. mode
select the video mode(s) that you want to use. you can select more
than one option. typically, useful ranges are 640x480, 800x600, and
1024x768 but those are a function of video card capability, monitor
size, and eye comfort.
next, select the default color depth you want to use. your choices are
8bpp, 16bpp, 24bpp, and 32bpp. select the highest color depth that
your video card will support.
#6. other
the default settings are reasonable values, so you probably will not
need to change anything here.
the default setting which allows the server to be killed with the
hotkey sequence ctrl+alt+backspace should be left on. this can be
executed if something is wrong with the server settings and prevent
hardware damage.
the default setting that allows video mode switching will permit
changing of the mode while running x with the hotkey sequence alt++ or
alt+-.
verify all the settings once again and select done and the following
message will display:
the screen will go blank for a short period of time and then a screen
will appear with the message ``congratulations, you've got a running
server!''
there are warnings that improper settings can damage your equipment.
heed them. if in doubt, do not do it. instead, use the monitor
controls to adjust the display for x-windows. there may be some
display differences when switching back to text mode, but it is better
than damaging equipment. xvidtune can be ran later using
/stand/sysinstall.
when you are satisfied, the configuration can now be saved. select
save the configuration and exit the configuration file will be saved
to /etc/xf86config.
[ yes ] no
[ ok ]
----------------------------------------------------------------------
there are a variety of window managers available. they range from very
basic environments to full desktop environments with a large suite of
software. some require only minimal disk space and low memory while others
with more features require much more. the best way to determine which is
most suitable for you is to try a few different ones. those are available
from the ports collection or as packages and can be added after
installation.
you can select one of the popular desktops to be installed and configured
as the default desktop. this will allow you to start it right after
installation.
use the arrow keys to select a desktop and press enter. installation of
the selected desktop will proceed.
----------------------------------------------------------------------
the packages are pre-compiled binaries and are a convenient way to install
software.
[ yes ] no
a menu will display showing all the packages available for the selection
made.
pressing the tab key will toggle between the last selected package,
[ ok ], and [ cancel ].
when you have finished marking the packages for installation, press tab
once to toggle to the [ ok ] and press enter to return to the package
selection menu.
the left and right arrow keys will also toggle between [ ok ] and
[ cancel ]. this method can also be used to select [ ok ] and press enter
to return to the package selection menu.
use the arrow keys to select [ install ] and press enter. you will then
need to confirm that you want to install the packages.
----------------------------------------------------------------------
you should add at least one user during the installation so that you can
use the system without being logged in as root. the root partition is
generally small and running applications as root can quickly fill it. a
bigger danger is noted below:
[ yes ] no
select add user with the arrow keys and press enter.
the following descriptions will appear in the lower part of the screen as
the items are selected with tab to assist with entering the required
information.
login id
uid
the numerical id for this user (leave blank for automatic choice)
group
the login group name for this user (leave blank for automatic
choice)
password
the password for this user (enter this field with care!)
full name
member groups
the groups this user belongs to (i.e. gets access rights for)
home directory
login shell
the login shell was changed from /bin/sh to /usr/local/bin/bash to use the
bash shell that was previously installed as a package. do not try to use a
shell that does not exist or you will not be able to login.
the user was also added to the group wheel to be able to become a
superuser with root privileges.
when you are satisfied, press [ ok ] and the user and group management
menu will redisplay.
groups could also be added at this time if specific needs are known.
otherwise, this may be accessed through using /stand/sysinstall after
installation is completed.
when you are finished adding users, select exit with the arrow keys and
press enter to continue the installation.
----------------------------------------------------------------------
message
now you must set the system manager's password.
this is the password you'll use to log in as "root".
[ ok ]
----------------------------------------------------------------------
yes [ no ]
selecting [ no ] with the arrow keys and pressing enter returns to the
main installation menu
select [x exit install] with the arrow keys and press enter. you will be
asked to confirm exiting the installation:
[ yes ] no
select [ yes ] and remove floppy if booting from floppy. the cdrom drive
is locked until the machine starts to reboot. the cdrom drive is then
unlocked and can be removed from drive (quickly).
the system will reboot so watch for any error messages that may appear.
----------------------------------------------------------------------
if everything went well, you will see messages scroll off the screen and
you will arrive at a login prompt. you can view the content of the
messages by pressing scroll-lock and using pgup and pgdn. pressing
scroll-lock again will return to the prompt.
the entire message may not display (buffer limitation) but it can be
viewed from the command line after logging in by typing dmesg at the
prompt.
login: rpratt
password:
generating the rsa and dsa keys may take some time on slower machines.
this happens only on the initial boot-up of a new installation. subsequent
boots will be faster.
if the x server has been configured and a default desktop chosen, it can
be started by typing startx at the command line.
----------------------------------------------------------------------
once the install procedure has finished, you will be able to start freebsd
by typing something like this to the srm prompt:
>>>boot dkc0
this instructs the firmware to boot the specified disk. to make freebsd
boot automatically in the future, use these commands:
the boot messages will be similar (but not identical) to those produced by
freebsd booting on the i386.
----------------------------------------------------------------------
it is safe to turn off the power after the shutdown command has been
issued and the message ``please press any key to reboot'' appears. if any
key is pressed instead of turning off the power switch, the system will
reboot.
you could also use the ctrl+alt+del key combination to reboot the system,
however this is not recommended during normal operation.
----------------------------------------------------------------------
freebsd currently runs on a wide variety of isa, vlb, eisa, and pci
bus-based pcs with intel, amd, cyrix, or nexgen ``x86'' processors, as
well as a number of machines based on the compaq alpha processor. support
for generic ide or esdi drive configurations, various scsi controllers,
pcmcia cards, usb devices, and network and serial cards is also provided.
freebsd also supports ibm's microchannel (mca) bus.
----------------------------------------------------------------------
2.11 troubleshooting
----------------------------------------------------------------------
check the hardware notes document for your version of freebsd to make sure
your hardware is supported.
it is also possible that a probe for a device not present will cause a
later probe for another device that is present to fail. in that case, the
probes for the conflicting driver(s) should be disabled.
warning: do not disable any drivers you will need during the
installation, such as your screen (sc0). if the installation wedges or
fails mysteriously after leaving the configuration editor, you have
probably removed or changed something you should not have. reboot and
try again.
* change device drivers for hardware that is not present in your system.
----------------------------------------------------------------------
many users wish to install freebsd on pcs inhabited by ms-dos. here are
some commonly asked questions about installing freebsd on such systems.
if your machine is already running ms-dos and has little or no free space
available for the freebsd installation, all hope is not lost! you may find
the fips utility, provided in the tools directory on the freebsd cdrom or
various freebsd ftp sites to be quite useful.
fips allows you to split an existing ms-dos partition into two pieces,
preserving the original partition and allowing you to install onto the
second free piece. you first defragment your ms-dos partition using the
windows defrag utility (go into explorer, right-click on the hard drive,
and choose to defrag your hard drive), or norton disk tools. you then must
run fips. it will prompt you for the rest of the information it needs.
afterwards, you can reboot and install freebsd on the new free slice. see
the distributions menu for an estimate of how much free space you will
need for the kind of installation you want.
yes. dos extended partitions are mapped in at the end of the other
``slices'' in freebsd, e.g., your d: drive might be /dev/da0s5, your e:
drive, /dev/da0s6, and so on. this example assumes, of course, that your
extended partition is on scsi drive 0. for ide drives, substitute ad for
da appropriately if installing 4.0-release or later, and substitute wd for
da if you are installing a version of freebsd prior to 4.0. you otherwise
mount extended partitions exactly like you would any other dos drive, for
example:
----------------------------------------------------------------------
no. freebsd, like compaq tru64 and vms, will only boot from the srm
console.
unfortunately, yes.
----------------------------------------------------------------------
----------------------------------------------------------------------
first you will need to get the right disk images so that you can boot
into the install program. the secret with using a serial console is
that you tell the boot loader to send i/o through a serial port
instead of displaying console output to the vga device and trying to
read input from a local keyboard. enough of that now, let's get back
to getting these disk images.
you will need to get kern.flp and mfsroot.flp from the floppies
directory.
the image files, such as kern.flp, are not regular files that you copy
to the disk. instead, they are images of the complete contents of the
disk.
this means that you can not use commands like dos' copy to write the
files. instead, you must use specific tools to write the images
directly to the disk.
if you are using the floppies from the cdrom, and your cdrom is the e:
drive then you would run this:
repeat this command for each .flp file, replacing the floppy disk each
time. adjust the command line as necessary, depending on where you
have placed the .flp files. if you do not have the cdrom then fdimage
can be downloaded from the tools directory on the freebsd ftp site.
# dd if=kern.flp of=/dev/fd0
if you were to boot into the floppies that you just made, freebsd
would boot into its normal install mode. we want freebsd to boot into
a serial console for our install. to do this, you have to mount the
kern.flp floppy onto your freebsd system using the mount(8) command.
now that you have the floppy mounted, you must change into the floppy
directory
# cd /mnt
here is where you must set the floppy to boot into a serial console.
you have to make a file called boot.config containing /boot/loader -h.
all this does is pass a flag to the bootloader to boot into a serial
console.
now that you have your floppy configured correctly, you must unmount
the floppy using the umount(8) command
# cd /
# umount /mnt
now you can remove the floppy from the floppy drive
you now need to connect a null modem cable between the two machines.
just connect the cable to the serial ports of the 2 machines. a normal
serial cable will not work here, you need a null modem cable because
it has some of the wires inside crossed over.
it is now time to go ahead and start the install. put the kern.flp
floppy in the floppy drive of the machine you are doing the headless
install on, and power on the machine.
# cu -l /dev/cuaa0
that's it! you should be able to control the headless machine through your
cu session now. it will ask you to put in the mfsroot.flp, and then it
will come up with a selection of what kind of terminal to use. just select
the freebsd color console and proceed with your install!
----------------------------------------------------------------------
there may be some situations in which you need to create your own freebsd
installation media and/or source. this might be physical media, such as a
tape, or a source that sysinstall can use to retrieve the files, such as a
local ftp site, or an ms-dos partition. for example:
* you have many machines connected to your local network, and one
freebsd disk. you want to create a local ftp site using the contents
of the freebsd disk, and then have your machines use this local ftp
site instead of needing to connect to the internet.
* you have a freebsd disk, freebsd does not recognize your cd/dvd drive,
but dos/windows does. you want to copy the freebsd installations files
to a dos partition on the same computer, and then install freebsd
using those files.
* the computer you want to install on does not have a cd/dvd drive, or a
network card, but you can connect a ``laplink-style'' serial or
parallel cable to a computer that does.
----------------------------------------------------------------------
freebsd disks are laid out in the same way as the ftp site. this makes it
very easy for you to create a local ftp site that can be used by other
machines on your network when installing freebsd.
#1. on the freebsd computer that will host the ftp site, ensure that the
cdrom is in the drive, and mounted on /cdrom.
# mount /cdrom
ftp:*:99:99::0:0:ftp:/cdrom:/nonexistent
anyone with network connectivity to your machine can now chose a media
type of ftp and type in ftp://your machine after picking ``other'' in the
ftp sites menu during the install.
----------------------------------------------------------------------
if you must install from floppy disk (which we suggest you do not do),
either due to unsupported hardware or simply because you insist on doing
things the hard way, you must first prepare some floppies for the
installation.
then you can mount and write to them like any other filesystem.
after you have formatted the floppies, you will need to copy the files to
them. 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
have all of the distributions you want packed up in this fashion. each
distribution should go into a subdirectory on the floppy, e.g.:
a:\bin\bin.aa, a:\bin\bin.ab, and so on.
once you come to the media screen during the install process, select
``floppy'' and you will be prompted for the rest.
----------------------------------------------------------------------
c:\> md c:\freebsd
c:\> xcopy e:\bin c:\freebsd\bin\ /s
c:\> xcopy e:\manpages c:\freebsd\manpages\ /s
assuming that c: is where you have free space and e: is where your cdrom
is mounted.
if you do not have a cdrom drive, you can download the distribution from
ftp.freebsd.org. each distribution is in its own directory; for example,
the bin distribution can be found in the 4.5/bin/ directory.
----------------------------------------------------------------------
# cd /freebsd/distdir
# tar cvf /dev/rwt0 dist1 ... dist2
when you go to do the installation, you should also make sure that you
leave enough room in some temporary directory (which you will be allowed
to choose) to accommodate the full contents of the tape you have created.
due to the non-random access nature of tapes, this method of installation
requires quite a bit of temporary storage. you should expect to require as
much temporary storage as you have stuff written on tape.
note: when starting the installation, the tape must be in the drive
before booting from the boot floppy. the installation probe may
otherwise fail to find it.
----------------------------------------------------------------------
there are three types of network installations you can do. serial port
(slip or ppp), parallel port (plip (laplink cable)), or ethernet (a
standard ethernet controller (includes some pcmcia)).
if you are using a modem, then ppp is almost certainly your only choice.
make sure that you have your service provider's information handy as you
will need to know it fairly early in the installation process.
if you use pap or chap to connect your isp (in other words, if you can
connect to the isp in windows without using a script), then all you will
need to do is type in dial at the ppp prompt. otherwise, you will need to
know how to dial your isp using the ``at commands'' specific to your
modem, as the ppp dialer provides only a very simple terminal emulator.
please refer to the user-ppp handbook and faq entries for further
information. if you have problems, logging can be directed to the screen
using the command set log local ....
you will also need to know your ip address on the network, the netmask
value for your address class, and the name of your machine. if you are
installing over a ppp connection and do not have a static ip, fear not,
the ip address can be dynamically assigned by your isp. your system
administrator can tell you which values to use for your particular network
setup. if you will be referring to other hosts by name rather than ip
address, you will also need a name server and possibly the address of a
gateway (if you are using ppp, it is your provider's ip address) to use in
talking to it. if you want to install by ftp via a http proxy (see below),
you will also need the proxy's address. if you do not know the answers to
all or most of these questions, then you should really probably talk to
your system administrator or isp before trying this type of installation.
----------------------------------------------------------------------
if you have a poor quality ethernet card which suffers from very slow
transfer rates, you may also wish to toggle the appropriate options flag.
in order for nfs installation to work, the server must support subdir
mounts, e.g., if your freebsd 3.4 distribution directory lives
on:ziggy:/usr/archive/stuff/freebsd, then ziggy will have to allow the
direct mounting of /usr/archive/stuff/freebsd, not just /usr or
/usr/archive/stuff.
----------------------------------------------------------------------
the following chapter will cover the basic commands and functionality of
the freebsd operating system. much of this material is relevant for any
unix-like operating system. feel free to skim over this chapter if you are
familiar with the material. if you are new to freebsd, then you will
definitely want to read through this chapter carefully.
* what a shell is, and how to change your default login environment.
----------------------------------------------------------------------
3.2 permissions
you can use the -l command line argument to ls(1) to view a long directory
listing that includes a column with information about a file's permissions
for the owner, group, and everyone else. here is how the first column of
ls -l is broken up:
-rw-r--r--
the first character, from left to right, is a special character that tells
if this is a regular file, a directory, a special character or block
device, a socket, or any other special pseudo-file device. the next three
characters, designated as rw- gives the permissions for the owner of the
file. the next three characters, r-- gives the permissions for the group
that the file belongs to. the final three characters, r--, gives the
permissions for the rest of the world. a dash means that the permission is
turned off. in the case of this file, the permissions are set so the owner
can read and write to the file, the group can read the file, and the rest
of the world can only read the file. according to the table above, the
permissions for this file would be 644, where each digit represents the
three parts of the file's permission.
this is all well and good, but how does the system control permissions on
devices? freebsd actually treats most hardware devices as a file that
programs can open, read, and write data to just like any other file. these
special device files are stored on the /dev directory.
directories are also treated as files. they have read, write, and execute
permissions. the executable bit for a directory has a slightly different
meaning than that of files. when a directory is marked executable, it
means it can be moved into, i.e. it is possible to ``cd'' into it. this
also means that within the directory it is possible to access files whose
names are known (subject, of course, to the permissions on the files
themselves).
there are more to permissions, but they are primarily used in special
circumstances such as setuid binaries and sticky directories. if you want
more information on file permissions and how to set them, be sure to look
at the chmod(1) man page.
----------------------------------------------------------------------
directory description
/ root directory of the filesystem.
/bin/ user utilities fundamental to both single-user and
multi-user environments.
/boot/ programs and configuration files used during operating
system bootstrap.
/boot/defaults/ default bootstrapping configuration files; see
loader.conf(5).
/dev/ device nodes; see intro(4).
/etc/ system configuration files and scripts.
/etc/defaults/ default system configuration files; see rc(8).
/etc/mail/ configuration files for mail transport agents such as
sendmail(8).
/etc/namedb/ named configuration files; see named(8).
/etc/periodic/ scripts that are run daily, weekly, and monthly, via
cron(8); see periodic(8).
/etc/ppp/ ppp configuration files; see ppp(8).
/mnt/ empty directory commonly used by system administrators as
a temporary mount point.
/proc/ process file system; see procfs(5), mount_procfs(8).
/root/ home directory for the root account.
/sbin/ system programs and administration utilities fundamental
to both single-user and multi-user environments.
/stand/ programs used in a standalone environment.
/tmp/ temporary files, usually a mfs(8) memory-based filesystem
(the contents of /tmp are usually not preserved across a
system reboot).
/usr/ the majority of user utilities and applications.
/usr/bin/ common utilities, programming tools, and applications.
/usr/include/ standard c include files.
/usr/lib/ archive libraries.
/usr/libdata/ miscellaneous utility data files.
/usr/libexec/ system daemons & system utilities (executed by other
programs).
/usr/local/ local executables, libraries, etc. also used as the
default destination for the freebsd ports framework.
within /usr/local, the general layout sketched out by
hier(7) for /usr should be used. exceptions are the man
directory is directly under /usr/local rather than under
/usr/local/share. ports documentation is in
share/doc/port.
/usr/obj/ architecture-specific target tree produced by building the
/usr/src tree.
/usr/ports the freebsd ports collection (optional).
/usr/sbin/ system daemons & system utilities (executed by users).
/usr/share/ architecture-independent files.
/usr/src/ bsd and/or local source files.
/usr/x11r6/ x11r6 distribution executables, libraries, etc (optional).
/var/ multi-purpose log, temporary, transient, and spool files.
/var/log/ miscellaneous system log files.
/var/mail/ user mailbox files.
/var/spool/ miscellaneous printer and mail system spooling
directories.
/var/tmp/ temporary files that are kept between system reboots.
/var/yp nis maps.
----------------------------------------------------------------------
----------------------------------------------------------------------
device
mount-point
fstype
options
dumpfreq
----------------------------------------------------------------------
there are plenty of options, as mentioned in the mount(8) manual page, but
the most common are:
mount options
-a
-d
-f
-r
-t fstype
-u
be verbose.
-w
nodev
noexec
nosuid
----------------------------------------------------------------------
----------------------------------------------------------------------
3.5 processes
two commands are particularly useful to see the processes on the system,
ps(1) and top(1). the ps(1) command is used to show a static list of the
currently running processes, and can show their pid, how much memory they
are using, the command line they were started with, and so on. the top(1)
command displays all the running processes, and updates the display every
few seconds, so that you can interactively see what your computer is
doing.
by default, ps(1) only shows you the commands that are running and are
owned by you. for example:
% ps
pid tt stat time command
298 p0 ss 0:01.10 tcsh
7078 p0 s 2:40.88 xemacs mdoc.xsl (xemacs-21.1.14)
37393 p0 i 0:03.11 xemacs freebsd.dsl (xemacs-21.1.14)
48630 p0 s 2:50.89 /usr/local/lib/netscape-linux/navigator-linux-
4.77.bi
48730 p0 iw 0:00.00 (dns helper) (navigator-linux-)
72210 p0 r+ 0:00.00 ps
390 p1 is 0:01.14 tcsh
7059 p2 is+ 1:36.18 /usr/local/bin/mutt -y
6688 p3 iws 0:00.00 tcsh
10735 p4 iws 0:00.00 tcsh
20256 p5 iws 0:00.00 tcsh
262 v0 iws 0:00.00 -tcsh (tcsh)
270 v0 iw+ 0:00.00 /bin/sh /usr/x11r6/bin/startx -- -bpp 16
280 v0 iw+ 0:00.00 xinit /home/nik/.xinitrc -- -bpp 16
284 v0 iw 0:00.00 /bin/sh /home/nik/.xinitrc
285 v0 s 0:38.45 /usr/x11r6/bin/sawfish
as you can see in this example, the output from ps(1) is organized in to a
number of columns. pid is the process id discussed earlier. pids are
assigned starting from 1, go up to 99999, and wrap around back to the
beginning when you run out. tt shows the tty the program is running on,
and can safely be ignored for the moment. stat shows the program's state,
and again, can be safely ignored. time is the amount of time the program
has been running on the cpu--this is not necessarily the elapsed time
since you started the program, as some programs spend a lot of time
waiting for things to happen before they need to spend time on the cpu.
finally, command is the command line that was used to run the program.
the output from top(1) is similar. a sample session looks like this:
% top
last pid: 72257; load averages: 0.13, 0.09, 0.03 up 0+13:38:33
22:39:10
47 processes: 1 running, 46 sleeping
cpu states: 12.6% user, 0.0% nice, 7.8% system, 0.0% interrupt, 79.7% idle
mem: 36m active, 5256k inact, 13m wired, 6312k cache, 15m buf, 408k free
swap: 256m total, 38m used, 217m free, 15% inuse
pid username pri nice size res state time wcpu cpu command
72257 nik 28 0 1960k 1044k run 0:00 14.86% 1.42% top
7078 nik 2 0 15280k 10960k select 2:54 0.88% 0.88% xemacs-
21.1.14
281 nik 2 0 18636k 7112k select 5:36 0.73% 0.73% xf86_svga
296 nik 2 0 3240k 1644k select 0:12 0.05% 0.05% xterm
48630 nik 2 0 29816k 9148k select 3:18 0.00% 0.00% navigator-
linu
175 root 2 0 924k 252k select 1:41 0.00% 0.00% syslogd
7059 nik 2 0 7260k 4644k poll 1:38 0.00% 0.00% mutt
...
the output is split in to two sections. the header (the first five lines)
shows the pid of the last process to run, the system load averages (which
are a measure of how busy the system is), the system uptime (time since
the last reboot) and the current time. the other figures in the header
relate to how many processes are running (47 in this case), how much
memory and swap space has been taken up, and how much time the system is
spending in different cpu states.
top(1) automatically updates this display every two seconds; this can be
changed with the s option.
----------------------------------------------------------------------
when you run an editor it is easy to control the editor, tell it to load
files, and so on. you can do this because the editor provides facilities
to do so, and because the editor is attached to a terminal. some programs
are not designed to be run with continuous user input, and so they
disconnect from the terminal at the first opportunity. for example, a web
server spends all day responding to web requests, it normally does not
need any input from you. programs that transport email from site to site
are another example of this class of application.
two signals can be used to stop a process, sigterm and sigkill. sigterm is
the polite way to kill a process; the process can catch the signal,
realize that you want it to shut down, close any log files it may have
open, and generally finish whatever it is doing at the time before
shutting down. in some cases a process may even ignore sigterm if it is in
the middle of some task that can not be interrupted.
sigkill can not be ignored by a process. this is the ``i do not care what
you are doing, stop right now'' signal. if you send sigkill to a process
then freebsd will stop that process there and then[1].
the other signals you might want to use are sighup, sigusr1, and sigusr2.
these are general purpose signals, and different applications will do
different things when they are sent.
suppose that you have changed your web server's configuration file--you
would like to tell the web server to re-read its configuration. you could
stop and restart httpd, but this would result in a brief outage period on
your web server, which may be undesirable. most daemons are written to
respond to the sighup signal by re-reading their configuration file. so
instead of killing and restarting httpd you would send it the sighup
signal. because there is no standard way to respond to these signals,
different daemons will have different behavior, so be sure and read the
documentation for the daemon in question.
signals are sent using the kill(1) command, as this example shows.
#1. find the process id of the process you want to send the signal to. do
this using ps(1) and grep(1). the grep(1) command is used to search
through output, looking for the string you specify. this command is
run as a normal user, and inetd(8) is run as root, so the ax options
must be given to ps(1).
so the inetd(8) pid is 198. in some cases the grep inetd command might
also occur in this output. this is because of the way ps(1) has to
find the list of running processes.
#2. use kill(1) to send the signal. because inetd(8) is being run by root
you must use su(1) to become root first.
% su
password:
# /bin/kill -s hup 198
in common most with unix commands, kill(1) will not print any output
if it is successful. if you try and send a signal to a process that
you do not own then you will see ``kill: pid: operation not
permitted''. if you mistype the pid you will either send the signal to
the wrong process, which could be bad, or, if you are lucky, you will
have sent the signal to a pid that is not currently in use, and you
will see ``kill: pid: no such process''.
why use /bin/kill?: many shells provide the kill command as a built
in command; that is, the shell will send the signal directly, rather
than running /bin/kill. this can be very useful, but different
shells have a different syntax for specifying the name of the signal
to send. rather than try to learn all of them, it can be simpler
just to use the /bin/kill ... command directly.
sending other signals is very similar, just substitute term or kill in the
command line as necessary.
----------------------------------------------------------------------
3.7 shells
the [beep] is the console bell, which is the shell telling me it was
unable to totally complete the filename because there is more than one
match. both foobar and foo.bar start with fo, but it was able to complete
to foo. if you type in ., then hit tab again, the shell would be able to
fill in the rest of the filename for you.
variable description
user current logged in user's name.
path colon separated list of directories to search for binaries.
display network name of the x11 display to connect to, if available.
shell the current shell.
term the name of the user's terminal. used to determine the
capabilities of the terminal.
termcap database entry of the terminal escape codes to perform various
terminal functions.
ostype type of operating system. e.g., freebsd.
machtype the cpu architecture that the system is running on.
editor the user's preferred text editor.
pager the user's preferred text pager.
manpath colon separated list of directories to search for manual pages.
% export editor="/usr/local/bin/emacs"
you can also make most shells expand the environment variable by placing a
$ character in front of it on the command line. for example, echo $term
would print out whatever $term is set to, because the shell expands $term
and passes it on to echo.
to prevent the shell from interpreting these special characters, they can
be escaped from the shell by putting a backslash (\) character in front of
them. echo $term prints whatever your terminal is set to. echo \$term
prints $term as is.
----------------------------------------------------------------------
the easiest way to change your shell is to use the chsh command. running
chsh will place you into the editor that is in your editor environment
variable; if it is not set, you will be placed in vi. change the
``shell:'' line accordingly.
you can also give chsh the -s option; this will set your shell for you,
without requiring you to enter an editor. for example, if you wanted to
change your shell to bash, the following should do the trick:
% chsh -s /usr/local/bin/bash
running chsh with no parameters and editing the shell from there would
work also.
note: the shell that you wish to use must be present in the /etc/shells
file. if you have installed a shell from the ports collection, then this
should have been done for you already. if you installed the shell by
hand, you must do this.
----------------------------------------------------------------------
the easiest and simplest editor to learn is an editor called ee, which
stands for easy editor. to start ee, one would type at the command line ee
filename where filename is the name of the file to be edited. for example,
to edit /etc/rc.conf, type in ee /etc/rc.conf. once inside of ee, all of
the commands for manipulating the editor's functions are listed at the top
of the display. the caret ^ character means the control key on the
keyboard, so ^e expands to pressing the control key plus the letter e. to
leave ee, hit the escape key, then choose leave editor. the editor will
prompt you to save any changes if the file has been modified.
freebsd also comes with more powerful text editors such as vi as part of
the base system, and emacs and vim as part of the freebsd ports
collection. these editors offer much more functionality and power at the
expense of being a little more complicated to learn. however if you plan
on doing a lot of text editing, learning a more powerful editor such as
vim or emacs will save you much more time in the long run.
----------------------------------------------------------------------
for example, acd0 is the first ide cdrom drive, while kbd0 represents the
keyboard.
----------------------------------------------------------------------
----------------------------------------------------------------------
on systems without devfs, device nodes are created using the makedev(8)
script as shown below:
# cd /dev
# sh makedev ad1
this example would make the proper device nodes for the second ide drive
when installed.
----------------------------------------------------------------------
----------------------------------------------------------------------
% man command
command is the name of the command you wish to learn about. for example,
to learn more about ls command type:
% man ls
in some cases, the same topic may appear in more than one section of the
online manual. for example, there is a chmod user command and a chmod()
system call. in this case, you can tell the man command which one you want
by specifying the section:
% man 1 chmod
this will display the manual page for the user command chmod. references
to a particular section of the online manual are traditionally placed in
parenthesis in written documentation, so chmod(1) refers to the chmod user
command and chmod(2) refers to the system call.
this is fine if you know the name of the command and simply wish to know
how to use it, but what if you cannot recall the command name? you can use
man to search for keywords in the command descriptions by using the -k
switch:
% man -k mail
with this command you will be presented with a list of commands that have
the keyword ``mail'' in their descriptions. this is actually functionally
equivalent to using the apropos command.
so, you are looking at all those fancy commands in /usr/bin but do not
have the faintest idea what most of them actually do? simply do:
% cd /usr/bin
% man -f *
or
% cd /usr/bin
% whatis *
----------------------------------------------------------------------
% info
----------------------------------------------------------------------
4.1 synopsis
----------------------------------------------------------------------
if you have used a unix system before you will know that the typical
procedure for installing third party software goes something like this:
#2. unpack the software from its distribution format (typically a tarball
compressed with either compress(1) or gzip(1)).
#4. if the software was distributed in source format, compile it. this may
involve editing a makefile, or running a configure script, and other
work.
and that is only if everything goes well. if you are installing a software
package that was not deliberately ported to freebsd you may even have to
go in and edit the code to make it work properly.
should you want to, you can continue to install software the
``traditional'' way with freebsd. however, freebsd provides two
technologies which can save you a lot of effort; packages and ports. at
the time of writing, over 6,600 third party applications have been made
available in this way.
for any given application, the freebsd package for that application is a
single file which you must download. the package contains pre-compiled
copies of all the commands for the application, as well as any
configuration files or documentation. a downloaded package file can be
manipulated with freebsd package management commands, such as pkg_add(1),
pkg_delete(1), pkg_info(1), and so on.
remember that there are a number of steps you would normally carry out if
you compiled a program yourself (unpacking, patching, compiling,
installing). the files that make up a port contain all the necessary
information to allow the system to do this for you. you run a handful of
simple commands and the source code for the application is automatically
downloaded, extracted, patched, compiled, and installed for you.
in fact, the ports system can also be used to generate packages which can
later be manipulated with pkg_add and the other package management
commands that will be introduced shortly.
both packages and ports understand dependencies. suppose you want to
install an application that depends on a specific library being installed.
both the application and the library have been made available as freebsd
ports and packages. if you use the pkg_add command or the ports system to
add the application, both will notice that the library has not been
installed, and the commands will install the library first.
given that the two technologies are quite similar, you might be wondering
why freebsd bothers with both. packages and ports both have their own
strengths, and which one you use will depend on your own preference.
package benefits
ports benefits
* some applications have compile time options relating to what they can
and cannot do. for example, apache can be configured with a wide
variety of different built-in options. by building from the port you
do not have to accept the default options, and can set them yourself.
in some cases, multiple packages will exist for the same application
to specify certain settings. for example, ghostscript is available as
a ghostscript package and a ghostscript-nox11 package, depending on
whether or not you have installed an x11 server. this sort of rough
tweaking is possible with packages, but rapidly becomes impossible if
an application has more than one or two different compile time
options.
* if you have local patches, you will need the source in order to apply
them.
* some people like having code around, so they can read it if they get
bored, hack it, borrow from it (license permitting, of course), and so
on.
to keep track of updated ports, subscribe to the freebsd ports mailing
list <[email protected]>.
the remainder of this chapter will explain how to use packages and ports
to install and manage third party software on freebsd.
----------------------------------------------------------------------
before you can install any applications you need to know what you want,
and what the application is called.
* if you do not know the name of the application you want, try using a
site like freshmeat (http://www.freshmeat.net/) to find an
application, then check back at the freebsd site to see if the
application has been ported yet.
----------------------------------------------------------------------
you can use the pkg_add(1) utility to install a freebsd software package
from a local file or from a server on the network.
# ftp -a ftp2.freebsd.org
connected to ftp2.freebsd.org.
220 ftp2.freebsd.org ftp server (version 6.00ls) ready.
331 guest login ok, send your email address as password.
230-
230- this machine is in vienna, va, usa, hosted by verio.
230- questions? e-mail [email protected].
230-
230-
230 guest login ok, access restrictions apply.
remote system type is unix.
using binary mode to transfer files.
ftp> cd /pub/freebsd/ports/packages/sysutils/
250 cwd command successful.
ftp> get lsof-4.56.4.tgz
local: lsof-4.56.4.tgz remote: lsof-4.56.4.tgz
200 port command successful.
150 opening binary mode data connection for 'lsof-4.56.4.tgz' (92375 bytes).
100% |**************************************************| 92375 00:00
eta
226 transfer complete.
92375 bytes received in 5.60 seconds (16.11 kb/s)
ftp> exit
# pkg_add lsof-4.56.4.tgz
# pkg_add -r lsof-4.56.4
the example above would download the correct package and add it without
any further user intervention.
package files are distributed in .tgz format. you can find them at
ftp://ftp.freebsd.org/pub/freebsd/ports/packages/, or on the freebsd cdrom
distribution. every cd on the freebsd 4-cd set (and powerpak, etc)
contains packages in the /packages directory. the layout of the packages
is similar to that of the /usr/ports tree. each category has its own
directory, and every package can be found within the all directory.
----------------------------------------------------------------------
# pkg_delete xchat-1.7.1
----------------------------------------------------------------------
# pkg_info
cvsup-16.1 a general network file distribution system optimized for
cv
docbook-1.2 meta-port for the different versions of the docbook dtd
...
the symbols in the second column indicate the relative age of the
installed version and the version available in the local ports tree.
symbol meaning
= the version of the installed package matches that of the one found
in the local ports tree.
< the installed version is older then the one available in the ports
tree.
> the installed version is newer than the one found in the local
ports tree. (local ports tree is probably out of date)
? the installed package cannot be found in the ports index.
* there are multiple versions of the package.
----------------------------------------------------------------------
4.4.4 miscellaneous
----------------------------------------------------------------------
----------------------------------------------------------------------
before you can install ports, you must first obtain the ports
collection--which is essentially a set of makefiles, patches, and
description files usually placed in /usr/ports.
when installing your freebsd system, sysinstall asked if you would like to
install the ports collection. if you chose no, you can follow these
instructions to obtain the ports collection.
sysinstall method
this method involves using sysinstall again to manually install the ports
collection.
# /stand/sysinstall
#6. select your desired installation media, such as cdrom, ftp, and so on.
the alternative method to obtain and keep your ports collection up to date
is by using cvsup. look at the ports cvsup file,
/usr/share/examples/cvsup/ports-supfile. see using cvsup (section a.6) for
more information on using cvsup and the mentioned file.
cvsup method
this is a quick method to getting the ports collection using cvsup. if you
want to keep your ports tree up to date, or learn more about cvsup, read
the previously mentioned sections.
#1. install the net/cvsup port. see cvsup installation (section a.6.2) for
more details.
# cvsup -g -l 2 /root/ports-supfile
#6. running this consequent times at later dates will download all the
recent changes to your ports collection.
----------------------------------------------------------------------
the first thing that should be explained when it comes to the ports
collection is what is actually meant by a ``skeleton''. in a nutshell, a
port skeleton is a minimal set of files that tell your freebsd system how
to cleanly compile and install a program. each port skeleton includes:
* a distinfo file. this file contains information about the files that
must be downloaded to build the port, and checksums, to ensure that
those files have not been corrupted during the download.
this directory may also contain other files used in building the port.
some ports have other files, such as pkg-message. the ports system uses
these files to handle special situations. if you want more details on
these files, and on ports in general, check out the freebsd porter's
handbook.
now that you have enough background information to know what the ports
collection is used for, you are ready to install your first port. there
are two ways this can be done, and each is explained below.
before we get into that however, you will need to choose a port to
install. there are a few ways to do this, with the easiest method being
the ports listing on the freebsd web site. you can browse through the
ports listed there or use the search function on the site. each port also
includes a description so you can read a bit about each port before
deciding to install it.
another method is to use the whereis command. simply type whereis file,
where file ist the program you want to install. if it is found on your
system, you will be told where it is, like so:
# whereis lsof
lsof: /usr/ports/sysutils/lsof
# cd /usr/ports
# make search name=lsof
port: lsof-4.56.4
path: /usr/ports/sysutils/lsof
info: lists information about open files (similar to fstat(1))
maint: [email protected]
index: sysutils
b-deps:
r-deps:
the part of the output you want to pay particular attention to is the
``path:'' line, since that tells you where to find it. the other
information provided is not needed in order to install the port directly,
so it will not be covered here.
for more in-depth searching you can also use make search key=string where
string is some text to search for. this searches port names, comments,
descriptions and dependencies and can be used to find ports which relate
to a particular subject if you don't know the name of the program you are
looking for.
now that you have found a port you would like to install, you are ready to
do the actual installation. the port includes instructions on how to build
source code, but no actual source code. you can get the source code from a
cdrom or from the internet. source code is distributed in whatever manner
the software author desires. frequently this is a tarred and gzipped file,
but it might be compressed with some other tool or even uncompressed. the
program source code, whatever form it comes in, is called a ``distfile''.
you can get the distfile from a cdrom or from the internet.
----------------------------------------------------------------------
place your freebsd cdrom in the drive. mount it on /cdrom. (if you use a
different mount point, the install will not work.) to begin, change to the
directory for the port you want to install:
# cd /usr/ports/sysutils/lsof
once inside the lsof directory, you will see the port skeleton. the next
step is to compile (also called build) the port. this is done by simply
typing make at the prompt. once you have done so, you should see something
like this:
# make
>> lsof_4.57d.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
>> attempting to fetch from file:/cdrom/ports/distfiles/.
===> extracting for lsof-4.57
...
[extraction output snipped]
...
>> checksum ok for lsof_4.57d.freebsd.tar.gz.
===> patching for lsof-4.57
===> applying freebsd patches for lsof-4.57
===> configuring for lsof-4.57
...
[configure output snipped]
...
===> building for lsof-4.57
...
[compilation snipped]
...
#
take notice that once the compile is complete you are returned to your
prompt. the next step is to install the port. in order to install it, you
simply need to tack one word onto the make command, and that word is
install:
# make install
===> installing for lsof-4.57
...
[install routines snipped]
...
===> generating temporary packing list
===> compressing manual pages for lsof-4.57
===> registering installation for lsof-4.57
===> security note:
this port has installed the following binaries which execute with
increased privileges.
#
once you are returned to your prompt, you should be able to run the
application you just installed. since lsof is a program that runs with
increased privileges, a security warning is shown. during the building and
installation of ports, you should take heed of any other warnings that may
appear.
note: you can save an extra step by just running make install instead of
make and make install as two separate steps.
note: please be aware that the licenses of a few ports do not allow for
inclusion on the cdrom. this could be because a registration form needs
to be filled out before downloading, redistribution is not allowed, and
so on. if you wish to install a port not included on the cdrom, you will
need to be online in order to do so (see the next section).
----------------------------------------------------------------------
as with the last section, this section makes an assumption that you have a
working internet connection. if you do not, you will need to perform the
cdrom installation.
installing a port from the internet is done exactly the same way as it
would be if you were installing from a cdrom. the only difference between
the two is that the port distfile is downloaded from the internet instead
of pulled from the cdrom.
# make install
>> lsof_4.57d.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
>> attempting to fetch from
ftp://ftp.freebsd.org/pub/freebsd/ports/distfiles/.
receiving lsof_4.57d.freebsd.tar.gz (439860 bytes): 100%
439860 bytes transferred in 18.0 seconds (23.90 kbps)
===> extracting for lsof-4.57
...
[extraction output snipped]
...
>> checksum ok for lsof_4.57d.freebsd.tar.gz.
===> patching for lsof-4.57
===> applying freebsd patches for lsof-4.57
===> configuring for lsof-4.57
...
[configure output snipped]
...
===> building for lsof-4.57
...
[compilation snipped]
...
===> installing for lsof-4.57
...
[install routines snipped]
...
===> generating temporary packing list
===> compressing manual pages for lsof-4.57
===> registering installation for lsof-4.57
===> security note:
this port has installed the following binaries which execute with
increased privileges.
#
as you can see, the only difference is the line that tells you where the
system is fetching the port from.
that about does it for installing ports onto your system. in the next
section you will learn how to remove a port from your system.
----------------------------------------------------------------------
now that you know how to install ports, you are probably wondering how to
remove them, just in case you install one and later on you decide that you
installed the wrong port. we will remove our previous example (which was
lsof for those of you not paying attention). as with installing ports, the
first thing you must do is change to the port directory,
/usr/ports/sysutils/lsof. after you change directories, you are ready to
uninstall lsof. this is done with the make deinstall command:
# cd /usr/ports/sysutils/lsof
# make deinstall
===> deinstalling for lsof-4.57
that was easy enough. you have removed lsof from your system. if you would
like to reinstall it, you can do so by running make reinstall from the
/usr/ports/sysutils/lsof directory.
the make deinstall and make reinstall sequence does not work once you have
run make clean. if you want to deinstall a port after cleaning, use
pkg_delete as discussed in the packages section of the handbook.
----------------------------------------------------------------------
after installing a new application you will normally want to read any
documentation it may have included, edit any configuration files that are
required, ensure that the application starts at boot time (if it is a
daemon), and so on.
the exact steps you need to take to configure each application will
obviously be different. however, if you have just installed a new
application and are wondering ``what now?'' these tips might help.
* use pkg_info(1) to find out which files were installed, and where they
were installed to. for example, if you have just installed foopackage
version 1.0.0, then this command
will show all the files installed by the package. pay special
attention to files in man/ directories, which will be manual pages,
etc/ directories, which will be configuration files, and doc/, which
will be more comprehensive documentation.
if you are not sure which version of the application was just
installed, a command like this
will find all the installed packages that have foopackage in the
package name. replace foopackage in your commandline as necessary.
* once you have identified where the application's manual pages have
been installed, review them using man(1). similarly, look over the
sample configuration files, and any additional documentation that may
have been provided.
# pkg_info foopackage-1.0.0
will often include a www: line with the url of the application's web
site.
----------------------------------------------------------------------
4.7 troubleshooting
the following sections cover some of the more frequently asked questions
about the ports collection and some basic troubleshooting techniques, and
what do to if a port is broken.
----------------------------------------------------------------------
4.7.1 some questions and answers
4.7.1.5. i did what you said for compiling ports from a cdrom and it
worked great until i tried to install the kermit port.
4.7.1.7. does the ports scheme only work if you have everything in
/usr/ports? my system administrator says i must put everything under
/u/people/guests/wurzburger, but it does not seem to work.
4.7.1.8. i do not have a freebsd cdrom, but i would like to have all the
tarballs handy on my system so i do not have to wait for a download every
time i install a port. is there any way to get them all at once?
4.7.1.10. i want to know what files make is going to need before it tries
to pull them down.
4.7.1.11. is there any way to stop the port from compiling? i want to do
some hacking on the source before i install it, but it is a bit tiresome
to watch it and hit ctrl+c every time.
4.7.1.13. i have heard that some compiler options can cause bugs. is this
true? how can i make sure that i compile ports with the right settings?
4.7.1.14. there are so many ports it is hard to find the one i want. is
there a list anywhere of what ports are available?
4.7.1.15. i went to install the foo port but the system suddenly stopped
compiling it and starting compiling the bar port. what is going on?
4.7.1.16. i installed the grizzle program from the ports and frankly it is
a complete waste of disk space. i want to delete it but i do not know
where it put all the files. any clues?
4.7.1.17. hang on a minute, you have to know the version number to use
that command. you do not seriously expect me to remember that, do you?
4.7.1.20. i like having lots and lots of programs to play with. is there
any way of installing all the ports in one go?
4.7.1.21. ok, i tried that, but i thought it would take a very long time
so i went to bed and left it to get on with it. when i looked at the
computer this morning, it had only done three and a half ports. did
something go wrong?
4.7.1.22. i really do not want to spend all day staring at the monitor.
any better ideas?
ah, you must be thinking of the serial ports on the back of your computer.
we are using ``port'' here to mean the result of ``porting'' a program
from one version of unix to another.
you can see what files are in them, or even extract them yourself by using
the standard unix tar program, which comes with the base freebsd system,
like this:
4.7.1.5. i did what you said for compiling ports from a cdrom and it
worked great until i tried to install the kermit port.
# make install
>> cku190.tar.gz doesn't seem to exist on this system.
>> attempting to fetch from ftp://kermit.columbia.edu/kermit/archives/.
as explained in the compiling ports from cdrom section, some ports cannot
be put on the cdrom set due to licensing restrictions. kermit is an
example of that. the licensing terms for kermit do not allow us to put the
tarball for it on the cdrom, so you will have to fetch it by hand--sorry!
the reason why you got all those error messages was because you were not
connected to the internet at the time. once you have downloaded it from
any of the master_sites (listed in the makefile), you can restart the
install process.
4.7.1.7. does the ports scheme only work if you have everything in
/usr/ports? my system administrator says i must put everything under
/u/people/guests/wurzburger, but it does not seem to work.
you can use the portsdir and prefix variables to tell the ports mechanism
to use different directories. for instance,
and of course,
will combine the two (it is too long to write fully on the page, but it
should give you the general idea).
some ports that use imake(1) (a part of the x windows system) do not work
well with prefix, and will insist on installing under /usr/x11r6.
similarly, some perl ports ignore prefix and install in the perl tree.
making these ports respect prefix is a difficult or impossible job.
if you do not fancy typing all that in every time you install a port, it
is a good idea to put these variables into your environment. read the
manual page for your shell for instructions on doing so.
4.7.1.8. i do not have a freebsd cdrom, but i would like to have all the
tarballs handy on my system so i do not have to wait for a download every
time i install a port. is there any way to get them all at once?
# cd /usr/ports
# make fetch
# cd /usr/ports/directory
# make fetch
and for just one port--well, you have probably guessed already.
yes. if you know, for example, that ftp.freebsd.org is much closer to you
than the sites listed in master_sites, do as follows:
# cd /usr/ports/directory
# make master_site_override= \
ftp://ftp.freebsd.org/pub/freebsd/ports/distfiles/ fetch
4.7.1.10. i want to know what files make is going to need before it tries
to pull them down.
make fetch-list will display a list of the files needed for a port.
4.7.1.11. is there any way to stop the port from compiling? i want to do
some hacking on the source before i install it, but it is a bit tiresome
to watch it and hit ctrl+c every time.
doing make extract will stop it after it has fetched and extracted the
source code.
yes, make patch is what you want. you will probably find the patch_debug
option useful as well. and by the way, thank you for your efforts!
4.7.1.13. i have heard that some compiler options can cause bugs. is this
true? how can i make sure that i compile ports with the right settings?
yes, with version 2.6.3 of gcc (the version shipped with freebsd 2.1.0 and
2.1.5), the -o2 option could result in buggy code unless you used the
-fno-strength-reduce option as well. (most of the ports do not use -o2).
you should be able to specify the compiler options used by something like:
4.7.1.14. there are so many ports it is hard to find the one i want. is
there a list anywhere of what ports are available?
look in the index file in /usr/ports. if you would like to search the
ports collection for a keyword, you can do that too. for example, you can
find ports relevant to the lisp programming language using:
% cd /usr/ports
% make search key=lisp
4.7.1.15. i went to install the foo port but the system suddenly stopped
compiling it and starting compiling the bar port. what is going on?
the foo port needs something that is supplied with bar -- for instance, if
foo uses graphics, bar might have a library with useful graphics
processing routines. or bar might be a tool that is needed to compile the
foo port.
4.7.1.16. i installed the grizzle program from the ports and frankly it is
a complete waste of disk space. i want to delete it but i do not know
where it put all the files. any clues?
# pkg_delete grizzle-6.5
# cd /usr/ports/somewhere/grizzle
# make deinstall
4.7.1.17. hang on a minute, you have to know the version number to use
that command. you do not seriously expect me to remember that, do you?
# pkg_info -i 'grizzle*'
information for grizzle-6.5:
grizzle-6.5 - the combined piano tutorial, logo interpreter and shoot 'em up
arcade game.
the version number can also be found using the pkg_info or by typing: ls
/var/db/pkg
yes, if you have installed the program and are fairly certain you will not
need the source again, there is no point in keeping it hanging around. the
surest way to do this is:
# cd /usr/ports
# make clean
which will go through all the ports subdirectories and delete everything
except the skeletons for each port.
4.7.1.19. i tried that and it still left all those tarballs or whatever
you called them in the distfiles directory. can i delete those as well?
yes, if you are sure you have finished with them, those can go as well.
they can be removed manually, or by using make distclean.
4.7.1.20. i like having lots and lots of programs to play with. is there
any way of installing all the ports in one go?
just do:
# cd /usr/ports
# make install
be careful, as some ports may install files with the same name. if you
install two graphics ports and they both install /usr/local/bin/plot then
you will obviously have problems.
4.7.1.21. ok, i tried that, but i thought it would take a very long time
so i went to bed and left it to get on with it. when i looked at the
computer this morning, it had only done three and a half ports. did
something go wrong?
no, the problem is that some of the ports need to ask you questions that
we cannot answer for you (e.g., ``do you want to print on a4 or us letter
sized paper?'') and they need to have someone on hand to answer them.
4.7.1.22. i really do not want to spend all day staring at the monitor.
any better ideas?
# cd /usr/ports
# make -dbatch install
this will install every port that does not require user input. then, when
you come back, do:
# cd /usr/ports
# make -dinteractive install
no problem, assuming you know how to make patches for your changes:
# cd /usr/ports/somewhere/frobble
# make extract
# cd work/frobble-2.8
[apply your patches]
# cd ../..
# make package
----------------------------------------------------------------------
if you come across a port that does not work for you, there are a few
things you can do, including:
#1. fix it! the porter's handbook includes detailed information on the
"ports" infrastructure so that you can fix the occasional broken port
or even submit your own!
#2. gripe--by email only! send email to the maintainer of the port first.
type make maintainer or read the makefile to find the maintainer's
email address. remember to include the name and version of the port
(send the $freebsd: line from the makefile) and the output leading up
to the error when you email the maintainer. if you do not get a
response from the maintainer, you can use send-pr to submit a bug
report.
#3. grab the package from an ftp site near you. the ``master'' package
collection is on ftp.freebsd.org in the packages directory, but be
sure to check your local mirror first! these are more likely to work
than trying to compile from source and are a lot faster as well. use
the pkg_add(1) program to install the package on your system.
----------------------------------------------------------------------
----------------------------------------------------------------------
5.2 understanding x
using x for the first time can be somewhat of a shock to someone familiar
with other graphical environments, such as microsoft windows or macos.
----------------------------------------------------------------------
5.2.1 why x?
x is not the first window system written for unix, but it is the most
popular. x's original development team had worked on another window system
before writing x. that system's name was ``w'' (for ``window''). x is just
the next letter in the roman alphabet.
x can be called ``x'', ``x window system'', ``x11'', and other terms.
calling x11 ``x windows'' can offend some people; see x(1) for a bit more
insight on this.
----------------------------------------------------------------------
remember that the x server is the machine with the monitor and keyboard,
and the x clients are the programs that display the windows.
there is nothing in the protocol that forces the client and server
machines to be running the same operating system, or even to be running on
the same type of computer. it is certainly possible to run an x server on
microsoft windows or apple's macos, and there are various free and
commercial applications available that do exactly that.
the x server that ships with freebsd is called xfree86, and is available
for free, under a license very similar to the freebsd license. commercial
x servers for freebsd are also available.
----------------------------------------------------------------------
the x design philosophy is much like the unix design philosophy, ``tools,
not policy''. this means that x does not try to dictate how a task is to
be accomplished. instead, tools are provided to the user, and it is the
user's responsibility to decide how to use those tools.
this philosophy extends to x not dictating what windows should look like
on screen, how to move them around with the mouse, what keystrokes to
should use to move between windows (i.e., alt+tab, in the case of
microsoft windows), what the title bars on each window should look like,
whether or not they have close buttons on them, and so on.
in addition, the kde and gnome desktop environments both have their own
window managers which integrate with the desktop.
each window manager also has a different configuration mechanism; some
expect configuration file written by hand, others feature gui tools for
most of the configuration tasks; at least one (sawfish) has a
configuration file written in a dialect of the lisp language.
x does not support any particular focus policy. instead, the window
manager controls which window has the focus at any one time. different
window managers will support different focus methods. all of them
support click to focus, and the majority of them support several others.
focus-follows-mouse
the window that is under the mouse pointer is the window that
has the focus. this may not necessarily be the window that is on
top of all the other windows. the focus is changed by pointing
at another window, there is no need to click in it as well.
sloppy-focus
click-to-focus
----------------------------------------------------------------------
5.2.4 widgets
the x approach of providing tools and not policy extends to the widgets
that seen on screen in each application.
``widget'' is a term for all the items in the user interface that can be
clicked or manipulated in some way; buttons, check boxes, radio buttons,
icons, lists, and so on. microsoft windows calls these ``controls''.
microsoft windows and apple's macos both have a very rigid widget policy.
application developers are supposed to ensure that their applications
share a common look and feel. with x, it was not considered sensible to
mandate a particular graphical style, or set of widgets to adhere to.
----------------------------------------------------------------------
the freebsd setup program offers users the opportunity to install and
configure xfree86 3.3.6 during installation (covered in section 2.9.11).
to run xfree86 4.x, wait until after the base freebsd system is installed,
and then install xfree86. for example, to build and install xfree86 4.x
from the ports collection:
# cd /usr/ports/x11/xfree86-4
# make all install clean
alternatively, xfree86 4.x can be installed from a binary package with the
pkg_add tool or directly from the freebsd binaries provided on the xfree86
web site.
the rest of this chapter will explain how to configure xfree86, and how to
setup a productive desktop environment.
----------------------------------------------------------------------
----------------------------------------------------------------------
the specifications for the monitor are used by xfree86 to determine the
resolution and refresh rate to run at. these specifications can usually be
obtained from the documentation that came with the monitor or from the
manufacturer's website. there are two ranges of numbers that are needed,
the horizontal scan rate and the vertical synchronization rate.
the video adapter's chipset defines what driver module xfree86 uses to
talk to the graphics hardware. with most chipsets, this can be
automatically determined, but it is still useful to know in case the
automatic detection does not work correctly.
video memory on the graphic adapter determines the resolution and color
depth which the system can run at. this is important to know so the user
knows the limitations of the system.
----------------------------------------------------------------------
# xfree86 -configure
the next step is to test the existing configuration to verify that xfree86
can work with the graphics hardware on the target system. to perform this
task, the user needs to run:
if a black and grey grid and an x mouse cursor appear, the configuration
was successful. to exit the test, just press ctrl+alt+backspace
simultaneously.
next, tune the xf86config.new configuration file to taste. open the file
in a text editor such as emacs(1) or ee(1). first, add the frequencies for
the target system's monitor. these are usually expressed as a horizontal
and vertical synchronization rate. these values are added to the
xf86config.new file under the "monitor" section:
section "monitor"
identifier "monitor0"
vendorname "monitor vendor"
modelname "monitor model"
horizsync 30-107
vertrefresh 48-120
endsection
the horizsync and vertrefresh keywords may not exist in the configuration
file. if they do not, they need to be added, with the correct horizontal
synchronization rate placed after the horizsync keyword and the vertical
synchronization rate after the vertrefresh keyword. in the example above
the target monitor's rates were entered.
x allows dpms (energy star) features to be used with capable monitors. the
'xset' program controls the time-outs and can force standby, suspend, or
off modes. if you wish to enable dpms features for your monitor, you must
add the following line to the monitor section.
option "dpms"
section "screen"
identifier "screen0"
device "card0"
monitor "monitor0"
defaultdepth 24
subsection "display"
depth 24
modes "1024x768"
endsubsection
endsection
finally, write the configuration file and test it using the test mode
given above. if all is well, the configuration file needs to be installed
in a common location where xfree86(1) can find it. this is typically
/etc/x11/xf86config or /usr/x11r6/etc/x11/xf86config.
# cp xf86config.new /etc/x11/xf86config
----------------------------------------------------------------------
5.4.3 advanced configuration topics
configuration with intel i810 integrated chipsets requires the agpgart agp
programming interface for xfree86 to drive the card. to use agpgart, the
agp.ko kernel loadable module needs to be loaded into the kernel with
kldload(8). this can be done automatically with the loader(8) at boot
time. simply add this line to /boot/loader.conf:
agp_load="yes"
# cd /dev
# sh makedev agpgart
this will allow configuration of the hardware as any other graphics board.
if you are using xfree86 4.1.0 (or later) and messages about unresolved
symbols like fbpictureinit appear, try adding the following line after
driver "i810" in the xfree86 config file:
option "noddc"
----------------------------------------------------------------------
the default fonts that ship with xfree86 are less than ideal for typical
desktop publishing applications. large presentation fonts show up jagged
and unprofessional looking, and small fonts in netscape are almost
completely unintelligible. however, there are several free, high quality
type1 (postscript) fonts available which can be readily used with xfree86,
either version 3.x or version 4.x. for instance, the urw font collection
(x11-fonts/urwfonts) includes high quality versions of standard type1
fonts (times roman, helvetica, palatino and others). the freefont
collection (x11-fonts/freefont) includes many more fonts, but most of them
are intended for use in graphics software such as the gimp, and are not
complete enough to serve as screen fonts. in addition, xfree86 can be
configured to use truetype fonts with a minimum of effort: see the section
on truetype fonts later.
to install the above type1 font collections from the ports collection, run
the following commands:
# cd /usr/ports/x11-fonts/urwfonts
# make install clean
and likewise with the freefont or other collections. to tell the x server
that these fonts exist, add an appropriate line to the xf86config file (in
/etc/ for xfree86 version 3, or in /etc/x11/ for version 4), which reads:
fontpath "/usr/x11r6/lib/x11/fonts/urw/"
this will work but will be lost when the x session is closed, unless it is
added to the startup file (~/.xinitrc for a normal startx session, or
~/.xsession when logging in through a graphical login manager like xdm). a
third way is to use the new xftconfig file: see the section on
anti-aliasing.
----------------------------------------------------------------------
xfree86 4.x has built in support for rendering truetype fonts. there are
two different modules that can enable this functionality. the "freetype"
module is used in this example because it is more consistent with the
other font rendering back-ends. to enable the freetype module just add the
following line to the module section of the /etc/x11/xf86config file.
load "freetype"
# cd /usr/x11r6/lib/x11/fonts/truetype
# ttmkfdir > fonts.dir
now add the truetype directory to the font path. this is just the same as
described above for type1 fonts, that is, use
that's it. now netscape, gimp, staroffice, and all of the other x
applications should now recognize the installed truetype fonts. extremely
small fonts (as with text in a high resolution display on a web page) and
extremely large fonts (within staroffice) will look much better now.
----------------------------------------------------------------------
first, tell the x server about the fonts that are to be anti-aliased. for
each font directory, add a line similar to this:
dir "/usr/x11r6/lib/x11/type1"
likewise for the other font directories (urw, truetype, etc) containing
fonts to be anti-aliased. anti-aliasing makes sense only for scalable
fonts (basically, type1 and truetype) so do not include bitmap font
directories here. the directories included here can now be commented out
of the xf86config file.
antialiasing makes borders slightly fuzzy, which makes very small text
more readable and removes ``staircases'' from large text, but can cause
eyestrain if applied to normal text. to exclude point sizes between 9 and
13 from anti-aliasing, include these lines:
match
any size > 8
any size < 14
edit
antialias = false;
(this aliases the other common names for fixed fonts as "mono"), and then
add:
finally, it is nice to allow users to add commands to this file, via their
personal .xftconfig files. to do this, add a last line:
includeif "~/.xftconfig"
one last point: with an lcd screen, sub-pixel sampling may be desired.
this basically treats the (horizontally separated) red, green and blue
components separately to improve the horizontal resolution; the results
can be dramatic. to enable this, add the line somewhere in the xftconfig
file
(depending on the sort of display, the last word may need to be changed
from from ``rgb'' to ``bgr'', ``vrgb'' or ``vbgr'': experiment and see
which works best.)
----------------------------------------------------------------------
5.6.1 overview
----------------------------------------------------------------------
----------------------------------------------------------------------
file description
xaccess client authorization ruleset.
xresources default x resource values.
xservers list of remote and local displays to manage.
xsession default session script for logins.
xsetup_* script to launch applications before the login interface.
xdm-config global configuration for all displays running on this machine.
xdm-errors errors generated by the server program.
xdm-pid the process id of the currently running xdm.
also in this directory are a few scripts and programs used to setup the
desktop when xdm is running. the purpose of each of these files will be
briefly described. the exact syntax and usage of all of these files is
described in xdm(1)
----------------------------------------------------------------------
5.6.3.1 xaccess
----------------------------------------------------------------------
5.6.3.2 xresources
this is an application-defaults file for the display chooser and the login
screens. this is where the appearance of the login program can be
modified. the format is identical to the app-defaults file described in
the xfree86 documentation.
----------------------------------------------------------------------
5.6.3.3 xservers
----------------------------------------------------------------------
5.6.3.4 xsession
this is the default session script for xdm to run after a user has logged
in. normally each user will have a customized session script in
~/.xsessionrc that overrides this script.
----------------------------------------------------------------------
5.6.3.5 xsetup_*
----------------------------------------------------------------------
5.6.3.6 xdm-config
----------------------------------------------------------------------
5.6.3.7 xdm-errors
this contains the output of the x servers that xdm is trying to run. if a
display that xdm is trying to start hangs for some reason, this is a good
place to look for error messages. these messages are also written to the
user's ~/.xsession-errors file on a per-session basis.
----------------------------------------------------------------------
in order for other clients to connect to the display server, edit the
access control rules, and enable the connection listener. by default these
are set to conservative values. to make xdm listen for connections, first
comment out a line in the xdm-config file:
----------------------------------------------------------------------
several replacements for the default xdm program exist. one of them, kdm
(bundled with kde) is described later in this chapter. kdm offers many
visual improvements and cosmetic frills, as well as the functionality to
allow users to choose their window manager of choice at login time.
----------------------------------------------------------------------
----------------------------------------------------------------------
5.7.1 gnome
----------------------------------------------------------------------
# pkg_add -r gnome
# cd /usr/ports/x11/gnome
# make install clean
once gnome is installed, the x server must be told to start gnome instead
of a default window manager. if a custom .xinitrc is already in place,
simply replace the line that starts the current window manager with one
that starts /usr/x11r6/bin/gnome-session instead. if nothing special has
been done to configuration file, then it is enough to simply type:
next, type startx, and the gnome desktop environment will be started.
note: if a display manager, like xdm, is being used, this will not work.
instead, create an executable .xsession file with the same command in
it. to do this, edit the file and replace the existing window manager
command with /usr/x11r6/bin/gnome-session:
----------------------------------------------------------------------
then, all that is needed is to tell gtk applications to look for their
font-rendering functions in libgdkxft.so before looking in the standard
place, libgdk.so. this is easily accomplished by setting an environment
variable to point to the right place; with the bourne shell (/bin/sh) or
similar shells, type the command (to start the gimp, say)
% ld_preload=/usr/x11r6/lib/libgdkxft.so gimp
ld_preload=/usr/x11r6/lib/libgdkxft.so
export ld_preload
----------------------------------------------------------------------
5.7.2 kde2
----------------------------------------------------------------------
just as with gnome or any other desktop environment, the easiest way to
install kde is through the ``desktop configuration'' menu during the
freebsd installation process as described in chapter 2. once again, the
software can be easily installed from a package or from the ports
collection:
# pkg_add -r kde2
# cd /usr/ports/x11/kde2
# make install clean
after kde2 has been installed, the x server must be told to launch this
application instead of the default window manager. this is accomplished by
editing the .xinitrc file:
now, whenever the x window system is invoked with startx, kde2 will be the
desktop.
if a display manager such as xdm is being used, the configuration is
slightly different. edit the .xsession file instead. instructions for kdm
are described later in this chapter.
----------------------------------------------------------------------
now that kde2 is installed on the system, most things can be discovered
through the help pages, or just by pointing and clicking at various menus.
windows or mac users will feel quite at home.
the best reference for kde is the on-line documentation. kde comes with
its own web browser, konqueror, dozens of useful applications, and
extensive documentation. the remainder of this section discusses the
technical items that are difficult to learn by random exploration.
----------------------------------------------------------------------
click on the icon on the left marked system, then on login manager. on the
right there are various configurable options, which the kde manual will
explain in greater detail. click on sessions on the right. click new type
to add various window managers and desktop environments. these are just
labels, so they can say kde and gnome rather than startkde or
gnome-session. include a label failsafe.
play with the other menus as well, they are mainly cosmetic and
self-explanatory. when are done, click on apply at the bottom, and quit
the control center.
to make sure kdm understands what the labels (kde, gnome etc) mean, edit
the files used by xdm.
note: in kde 2.2 this has changed: kdm now uses its own configuration
files. please see the kde 2.2 documentation for details.
case $# in
1)
case $1 in
failsafe)
exec xterm -geometry 80x24-0-0
;;
esac
esac
a few lines need to be added to this section. assuming the labels from
used were ``kde2'' and ``gnome'', use the following:
case $# in
1)
case $1 in
kde)
exec /usr/local/bin/startkde
;;
gnome)
exec /usr/x11r6/bin/gnome-session
;;
failsafe)
exec xterm -geometry 80x24-0-0
;;
esac
esac
/usr/local/bin/kdmdesktop
----------------------------------------------------------------------
----------------------------------------------------------------------
5.7.4 xfce
xfce is a desktop environment based on the gtk toolkit used by gnome, but
is much more lightweight and meant for those who want a simple, efficient
desktop which is nevertheless easy to use and configure. visually, it
looks very much like cde, found on commercial unix systems. some of xfce's
features are:
* main panel similar to cde, with menus, applets and app launchers
----------------------------------------------------------------------
a binary package for xfce exists (at the time of writing). to install,
simply type:
# pkg_add -r xfce
# cd /usr/ports/x11-wm/xfce
# make install clean
now, tell the x server to launch xfce the next time x is started. simply
type this:
these chapters are designed to be read when you need the information. you
do not have to read them in any particular order, nor do you need to read
all of them before you can begin using freebsd.
table of contents
10 security
11 printing
12 storage
14 sound
15 serial communications
17 advanced networking
18 electronic mail
----------------------------------------------------------------------
6.1 synopsis
this chapter will also describe some of the parameters that can be set to
tune a freebsd system for optimum performance.
* why and how to efficiently size, layout, and place filesystems and
swap partitions on your hard drive.
----------------------------------------------------------------------
----------------------------------------------------------------------
the size of your /var partition reflects the intended use of your machine.
/var is primarily used to hold mailboxes, log files, and printer spools.
mailboxes and log files, in particular, can grow to unexpected sizes based
upon how many users are on your system and how long your log files are
kept. if you intend to run a mail server, a /var partition of over a
gigabyte can be suitable. additionally, /var/tmp must be large enough to
contain any packages you may wish to add.
the /usr partition holds the bulk of the files required to support the
system and a subdirectory within it called /usr/local holds the bulk of
the files installed from the ports(7) hierarchy. if you do not use ports
all that much and do not intend to keep system source (/usr/src) on the
machine, you can get away with a 1 gigabyte /usr partition. however, if
you install a lot of ports (especially window managers and linux
binaries), we recommend at least a two gigabyte /usr and if you also
intend to keep system source on the machine, we recommend a three gigabyte
/usr. do not underestimate the amount of space you will need in this
partition, it can creep up and surprise you!
when sizing your partitions, keep in mind the space requirements for your
system to grow. running out of space in one partition while having plenty
in another can lead to much frustration.
as a rule of thumb, your swap space should typically be double the amount
of main memory. for example, if the machine has 128 megabytes of memory,
the swap file should be 256 megabytes. systems with lesser memory may
perform better with a lot more swap. it is not recommended that you
configure any less than 256 megabytes of swap on a system and you should
keep in mind future memory expansion when sizing the swap partition. the
kernel's vm paging algorithms are tuned to perform best when the swap
partition is at least two times the size of main memory. configuring too
little swap can lead to inefficiencies in the vm page scanning code as
well as create issues later on if you add more memory to your machine.
finally, on larger systems with multiple scsi disks (or multiple ide disks
operating on different controllers), it is strongly recommend that you
configure swap on each drive (up to four drives). the swap partitions on
the drives should be approximately the same size. the kernel can handle
arbitrary sizes but internal data structures scale to 4 times the largest
swap partition. keeping the swap partitions near the same size will allow
the kernel to optimally stripe swap space across the disks. do not worry
about overdoing it a little, swap space is the saving grace of unix. even
if you do not normally use much swap, it can give you more time to recover
from a runaway program before being forced to reboot.
----------------------------------------------------------------------
why partition at all? why not create one big root partition and be done
with it? then i do not have to worry about undersizing things!
there are several reasons this is not a good idea. first, each partition
has different operational characteristics and separating them allows the
filesystem to tune itself to those characteristics. for example, the root
and /usr partitions are read-mostly, with very little writing, while a lot
of reading and writing could occur in /var and /var/tmp.
----------------------------------------------------------------------
* rc.conf:
. rc.conf.site
hostname="node15.example.com"
network_interfaces="fxp0 lo0"
ifconfig_fxp0="inet 10.1.1.1"
* rc.conf.site:
defaultrouter="10.1.1.254"
saver="daemon"
blanktime="100"
the rc.conf.site file can then be distributed to every system using rsync
or a similar program, while the rc.conf file remains unique.
upgrading the system using sysinstall(8) or make world will not overwrite
the rc.conf file, so system configuration information will not be lost.
----------------------------------------------------------------------
the filesize difference shows that only the srm.conf file has been
changed. a later update of the apache port would not overwrite this
changed file.
----------------------------------------------------------------------
software installed from a port or the packages collection will often place
a script in /usr/local/etc/rc.d which is invoked at system startup with a
start argument, and at system shutdown with a stop argument. this is the
recommended way for starting system-wide services that are to be run as
root, or that expect to be started as root. these scripts are registered
as part of the installation of the package, and will be removed when the
package is removed.
#!/bin/sh
echo -n ' foobar'
case "$1" in
start)
/usr/local/bin/foobar
;;
stop)
kill -9 `cat /var/run/foobar.pid`
;;
*)
echo "usage: `basename $0` {start|stop}" >&2
exit 64
;;
esac
exit 0
this script is called with start at startup, and the stop at shutdown to
allow it to carry out its purpose.
----------------------------------------------------------------------
a very common use of freebsd is virtual site hosting, where one server
appears to the network as many servers. this is achieved by assigning
multiple network addresses to a single interface.
a given network interface has one ``real'' address, and may have any
number of ``alias'' addresses. these aliases are normally added by placing
alias entries in /etc/rc.conf.
note that alias entries must start with alias0 and proceed upwards in
order, (for example, _alias1, _alias2, and so on). the configuration
process will stop at the first missing number.
for example, consider the case where the fxp0 interface is connected to
two networks, the 10.1.1.0 network with a netmask of 255.255.255.0 and the
202.0.75.16 network with a netmask of 255.255.255.240. we want the system
to appear at 10.1.1.1 through 10.1.1.5 and at 202.0.75.17 through
202.0.75.20.
----------------------------------------------------------------------
----------------------------------------------------------------------
6.7.2 hostnames
----------------------------------------------------------------------
6.7.2.1 /etc/resolv.conf
nameserver the ip address of a name server the resolver should query. the
servers are queried in the order listed with a maximum of
three.
search search list for hostname lookup. this is normally determined by
the domain of the local hostname.
domain the local domain name.
a typical resolv.conf:
search example.com
nameserver 147.11.1.11
nameserver 147.11.100.30
note: only one of the search and domain options should be used.
----------------------------------------------------------------------
6.7.2.2 /etc/hosts
# $freebsd$
#
# host database
# this file should contain the addresses and aliases
# for local hosts that share this file.
# in the presence of the domain name service or nis, this file may
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.
#
#
::1 localhost localhost.my.domain myname.my.domain
127.0.0.1 localhost localhost.my.domain myname.my.domain
#
# imaginary network.
#10.0.0.2 myname.my.domain myname
#10.0.0.3 myfriend.my.domain myfriend
#
# according to rfc 1918, you can use the following ip networks for
# private nets which will never be connected to the internet:
#
# 10.0.0.0 - 10.255.255.255
# 172.16.0.0 - 172.31.255.255
# 192.168.0.0 - 192.168.255.255
#
# in case you want to be able to connect to the internet, you need
# real official assigned numbers. please please please do not try
# to invent your own network numbers but instead get one from your
# network provider (if any) or from the internet registry (ftp to
# rs.internic.net, directory `/templates').
#
for example:
----------------------------------------------------------------------
6.7.3 log file configuration
----------------------------------------------------------------------
6.7.3.1 syslog.conf
# $freebsd$
#
# spaces are valid field separators in this file. however,
# other *nix-like systems still insist on using tabs as field
# separators. if you are sharing this file between systems, you
# may want to use only tabs as field separators here.
# consult the syslog.conf(5) manual page.
*.err;kern.debug;auth.notice;mail.crit /dev/console
*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
security.* /var/log/security
mail.info /var/log/maillog
lpr.info /var/log/lpd-errs
cron.* /var/log/cron
*.err root
*.notice;news.err root
*.alert root
*.emerg *
# uncomment this to log all writes to /dev/console to /var/log/console.log
#console.info /var/log/console.log
# uncomment this to enable logging of all log messages to /var/log/all.log
#*.* /var/log/all.log
# uncomment this to enable logging to a remote log host named loghost
#*.* @loghost
# uncomment these if you're running inn
# news.crit /var/log/news/news.crit
# news.err /var/log/news/news.err
# news.notice /var/log/news/news.notice
!startslip
*.* /var/log/slip.log
!ppp
*.* /var/log/ppp.log
----------------------------------------------------------------------
6.7.3.2 newsyslog.conf
newsyslog.conf indicates which log files are to be managed, how many are
to be kept, and when they are to be touched. log files can be rearranged
and/or archived when they have either reached a certain size, or at a
certain periodic time/date.
----------------------------------------------------------------------
6.7.4 sysctl.conf
a sample sysctl.conf turning off logging of fatal signal exits and letting
linux programs know they are really running under freebsd.
----------------------------------------------------------------------
at its core, sysctl(8) serves two functions: to read and to modify system
settings.
% sysctl -a
to read a particular variable, for example, kern.maxproc:
% sysctl kern.maxproc
kern.maxproc: 1044
# sysctl kern.maxfiles=5000
kern.maxfiles: 2088 -> 5000
----------------------------------------------------------------------
6.9.1.1 vfs.vmiodirenable
----------------------------------------------------------------------
6.9.1.2 hw.ata.wc
freebsd 4.3 flirted with turning off ide write caching. this reduced write
bandwidth to ide disks but was considered necessary due to serious data
consistency issues introduced by hard drive vendors. the problem is that
ide drives lie about when a write completes. with ide write caching turned
on, ide hard drives not only write data to disk out of order, but will
sometimes delay writing some blocks indefinitely when under heavy disk
loads. a crash or power failure may cause serious filesystem corruption.
freebsd's default was changed to be safe. unfortunately, the result was
such a huge performance loss that we changed write caching back to on by
default after the release. you should check the default on your system by
observing the hw.ata.wc sysctl variable. if ide write caching is turned
off, you can turn it back on by setting the kernel variable back to 1.
this must be done from the boot loader at boot time. attempting to do it
after the kernel boots will have no effect.
----------------------------------------------------------------------
the second case is asynchronous meta-data updates. this is the default for
linux/ext2fs and mount -o async for *bsd ufs. all meta-data updates are
simply being passed through the buffer cache too, that is, they will be
intermixed with the updates of the file content data. the advantage of
this implementation is there is no need to wait until each meta-data
update has been written to disk, so all operations which cause huge
amounts of meta-data updates work much faster than in the synchronous
case. also, the implementation is still clear and simple, so there is a
low risk for bugs creeping into the code. the disadvantage is that there
is no guarantee at all for a consistent state of the filesystem. if there
is a failure during an operation that updated large amounts of meta-data
(like a power failure, or someone pressing the reset button), the file
system will be left in an unpredictable state. there is no opportunity to
examine the state of the file system when the system comes up again; the
data blocks of a file could already have been written to the disk while
the updates of the inode table or the associated directory were not. it is
actually impossible to implement a fsck which is able to clean up the
resulting chaos (because the necessary information is not available on the
disk). if the filesystem has been damaged beyond repair, the only choice
is to newfs it and restore it from backup.
the usual solution for this problem was to implement dirty region logging,
which is also referred to as journaling, although that term is not used
consistently and is occasionally applied to other forms of transaction
logging as well. meta-data updates are still written synchronously, but
only into a small region of the disk. later on they will be moved to their
proper location. because the logging area is a small, contiguous region on
the disk, there are no long distances for the disk heads to move, even
during heavy operations, so these operations are quicker than synchronous
updates. additionally the complexity of the implementation is fairly
limited, so the risk of bugs being present is low. a disadvantage is that
all meta-data are written twice (once into the logging region and once to
the proper location) so for normal work, a performance ``pessimization''
might result. on the other hand, in case of a crash, all pending meta-data
operations can be quickly either rolled-back or completed from the logging
area after the system comes up again, resulting in a fast filesystem
startup.
kirk mckusick, the developer of berkeley ffs, solved this problem with
soft updates: all pending meta-data updates are kept in memory and written
out to disk in a sorted sequence (``ordered meta-data updates''). this has
the effect that, in case of heavy meta-data operations, later updates to
an item ``catch'' the earlier ones if the earlier ones are still in memory
and have not already been written to disk. so all operations on, say, a
directory are generally performed in memory before the update is written
to disk (the data blocks are sorted according to their position so that
they will not be on the disk ahead of their meta-data). if the system
crashes, this causes an implicit ``log rewind'': all operations which did
not find their way to the disk appear as if they had never happened. a
consistent filesystem state is maintained that appears to be the one of 30
to 60 seconds earlier. the algorithm used guarantees that all resources in
use are marked as such in their appropriate bitmaps: blocks and inodes.
after a crash, the only resource allocation error that occurs is that
resources are marked as ``used'' which are actually ``free''. fsck(8)
recognizes this situation, and frees the resources that are no longer
used. it is safe to ignore the dirty state of the filesystem after a crash
by forcibly mounting it with mount -f. in order to free resources that may
be unused, fsck(8) needs to be run at a later time. this is the idea
behind the background fsck: at system startup time, only a snapshot of the
filesystem is recorded. the fsck can be run later on. all filesystems can
then be mounted ``dirty'', so the system startup proceeds in multiuser
mode. then, background fscks will be scheduled for all filesystems where
this is required, to free resources that may be unused. (filesystems that
do not use soft updates still need the usual foreground fsck though.)
----------------------------------------------------------------------
----------------------------------------------------------------------
6.10.1.1 kern.maxfiles
each open file, socket, or fifo uses one file descriptor. a large-scale
production server may easily require many thousands of file descriptors,
depending on the kind and number of services running concurrently.
----------------------------------------------------------------------
----------------------------------------------------------------------
no matter how well you plan, sometimes a system doesn't run as you expect.
if you find you need more swap space, it's simple enough to add. you have
three ways to increase swap space: adding a new hard drive, enabling swap
over nfs, and creating a swap file on an existing partition.
----------------------------------------------------------------------
the best way to add swap, of course, is to use this as an excuse to add
another hard drive. you can always use another hard drive, after all. if
you can do this, go reread the discussion of swap space from the initial
configuration section of the handbook for some suggestions on how to best
arrange your swap.
----------------------------------------------------------------------
swapping over nfs is only recommended if you do not have a local hard disk
to swap to. swapping over nfs is slow and inefficient in versions of
freebsd prior to 4.x. it is reasonably fast and efficient in 4.0-release
and newer. even with newer versions of freebsd, nfs swapping will be
limited by the available network bandwidth and puts an additional burden
on the nfs server.
----------------------------------------------------------------------
6.11.3 swapfiles
you can create a file of a specified size to use as a swap file. in our
example here we will use a 64mb file called /usr/swap0. you can use any
name you want, of course.
#1. be certain that your kernel configuration includes the vnode driver.
it is not in recent versions of generic.
#6. reboot the machine or to enable the swap file immediately, type:
----------------------------------------------------------------------
7.1 synopsis
this chapter details the configuration options you can set and how to
customize the freebsd boot process. this includes everything that happens
until the freebsd kernel has started, probed for devices, and started
init(8). if you are not quite sure when this happens, it occurs when the
text color changes from bright white to grey.
* what the components of the freebsd bootstrap system are, and how they
interact.
* the options you can give to the components in the freebsd bootstrap to
control the boot process.
x86 only: this chapter only describes the boot process for freebsd
running on intel x86 systems.
----------------------------------------------------------------------
this problem parallels one in the book the adventures of baron munchausen.
a character had fallen part way down a manhole, and pulled himself out by
grabbing his bootstraps, and lifting. in the early days of computing the
term bootstrap was applied to the mechanism used to load the operating
system, which has become shortened to ``booting''.
if you only have one operating system installed on your disks then the
standard mbr will suffice. this mbr searches for the first bootable slice
on the disk, and then runs the code on that slice to load the remainder of
the operating system.
if you have installed multiple operating systems on your disks then you
can install a different mbr, one that can display a list of different
operating systems, and allows you to choose the one to boot from. freebsd
comes with one such mbr which can be installed, and other operating system
vendors also provide alternative mbrs.
the kernel is then started and it begins to probe for devices and
initialize them for use. once the kernel boot process is finished, the
kernel passes control to the user process init(8), which then makes sure
the disks are in a usable state. init(8) then starts the user-level
resource configuration which mounts filesystems, sets up network cards to
communicate on the network, and generally starts all the processes that
usually are run on a freebsd system at startup.
----------------------------------------------------------------------
7.3 the mbr, and boot stages one, two, and three
boot0 is very simple, since the program in the mbr can only be 512 bytes
in size. if you have installed the freebsd mbr and have installed multiple
operating systems on your hard disks then you will see a display similar
to this one at boot time.
example 7-1. boot0 screenshot
f1 dos
f2 freebsd
f3 linux
f4 ??
f5 drive 1
default: f2
where device is the device that you boot from, such as ad0 for the first
ide disk, ad2 for the first ide disk on a second ide controller, da0 for
the first scsi disk, and so on.
if you are a linux user, however, and prefer that lilo control the boot
process, you can edit the /etc/lilo.conf file for freebsd, or select leave
the master boot record untouched during the freebsd installation process.
if you have installed the the freebsd boot manager, you can boot back into
linux and modify the lilo configuration file /etc/lilo.conf and add the
following option:
other=/dev/hdxy
table=/dev/hdb
loader=/boot/chain.b
label=freebsd
which will permit the booting of freebsd and linux via lilo. in our
example, we use xy to determine drive number and partition. if you are
using a scsi drive, you will want to change /dev/hdxy to read something
similar to /dev/sdxy, which again uses the xy syntax. the
loader=/boot/chain.b can be omitted if you have both operating systems on
the same drive. you can now run /sbin/lilo -v to commit your new changes
to the system, this should be verified with screen messages.
----------------------------------------------------------------------
conceptually the first and second stages are part of the same program, on
the same area of the disk. because of space constraints they have been
split into two, but you would always install them together.
they are found on the boot sector of the boot slice, which is where boot0,
or any other program on the mbr expects to find the program to run to
continue the boot process. the files in the /boot directory are copies of
the real files, which are stored outside of the freebsd filesystem.
boot1 is very simple, since it too can only be 512 bytes in size, and
knows just enough about the freebsd disklabel, which stores information
about the slice, to find and execute boot2.
boot2 is slightly more sophisticated, and understands the freebsd
filesystem enough to find files on it, and can provide a simple interface
to choose the kernel or loader to run.
if you ever need to replace the installed boot1 and boot2 use
disklabel(8).
# disklabel -b diskslice
where diskslice is the disk and slice you boot from, such as ad0s1 for the
first slice on the first ide disk.
dangerously dedicated mode: if you use just the disk name, such as ad0,
in the disklabel(8) command you will create a dangerously dedicated
disk, without slices. this is almost certainly not what you want to do,
so make sure you double check the disklabel(8) command before you press
return.
----------------------------------------------------------------------
the loader is the final stage of the three-stage bootstrap, and is located
on the filesystem, usually as /boot/loader.
----------------------------------------------------------------------
during initialization, the loader will probe for a console and for disks,
and figure out what disk it is booting from. it will set variables
accordingly, and an interpreter is started where user commands can be
passed from a script or interactively.
finally, by default, the loader issues a 10 second wait for key presses,
and boots the kernel if it is not interrupted. if interrupted, the user is
presented with a prompt which understands the easy-to-use command set,
where the user may adjust variables, unload all modules, load modules, and
then finally boot or reboot.
----------------------------------------------------------------------
these are the most commonly used loader commands. for a complete
discussion of all available commands, please see loader(8)
autoboot seconds
boot-conf
help [topic]
processes the file with the given filename. the file is read in,
and interpreted line by line. an error immediately stops the
include command.
loads the kernel, kernel module, or file of the type given, with
the filename given. any arguments after filename are passed to the
file.
ls [-l] [path]
lsdev [-v]
lsmod [-v]
reboot
unload
----------------------------------------------------------------------
boot -s
* to unload your usual kernel and modules, and then load just your old
(or another) kernel:
unload
load kernel.old
you can use kernel.generic to refer to the generic kernel that comes
on the install disk, or kernel.old to refer to your previously
installed kernel (when you have upgraded or configured your own
kernel, for example).
note: use the following to load your usual modules with another
kernel:
unload
set kernel="kernel.old"
boot-conf
----------------------------------------------------------------------
once the kernel is loaded by either loader (as usual) or boot2 (bypassing
the loader), it examines its boot flags, if any, and adjusts its behavior
as necessary.
----------------------------------------------------------------------
-a
-c
-c
-s
-v
note: there are other boot flags, read boot(8) for more information on
them.
----------------------------------------------------------------------
once the kernel has finished booting, it passes control to the user
process init, which is located at /sbin/init, or the program path
specified in the init_path variable in loader.
----------------------------------------------------------------------
the automatic reboot sequence makes sure that the filesystems available on
the system are consistent. if they are not, and fsck cannot fix the
inconsistencies, init drops the system into single-user mode for the
system administrator to take care of the problems directly.
----------------------------------------------------------------------
this mode can be reached through the automatic reboot sequence, or by the
user booting with the -s option or setting the boot_single variable in
loader.
it can also be reached by calling shutdown without the reboot (-r) or halt
(-h) options, from multi-user mode.
note: an insecure console means that you consider your physical security
to the console to be insecure, and want to make sure only someone who
knows the root password may use single-user mode, and it does not mean
that you want to run your console insecurely. thus, if you want
security, choose insecure, not secure.
----------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
upon controlled shutdown, via shutdown, init will attempt to run the
script /etc/rc.shutdown, and then proceed to send all processes the term
signal, and subsequently the kill signal to any that do not terminate
timely.
----------------------------------------------------------------------
8.1 synopsis
freebsd allows multiple users to use the computer at the same time.
obviously, only one of those users can be sitting in front of the screen
and keyboard at any one time [2], but any number of users can log in
through the network to get their work done. to use the system every user
must have an account.
----------------------------------------------------------------------
8.2 introduction
all access to the system is achieved via accounts, and all processes are
run by users, so user and account management are of integral importance on
freebsd systems.
user name
password
each account has a password associated with it. the password may
be blank, in which case no password will be required to access the
system. this is normally a very bad idea; every account should
have a password.
user id (uid)
group id (gid)
login class
the user name uniquely identifies the account to freebsd, but does
not necessarily reflect the user's real name. this information can
be associated with the account.
home directory
user shell
there are three main types of accounts; the superuser, system users, and
user accounts. the superuser account, usually called root, is used to
manage the system with no limitations on privileges. system users run
services. finally, user accounts are used by real people, who log on, read
mail, and so forth.
----------------------------------------------------------------------
this is because the superuser, unlike normal user accounts, can operate
without limits, and misuse of the superuser account may result in
spectacular disasters. user accounts are unable to destroy the system by
mistake, so it is generally best to use normal user accounts whenever
possible, unless you especially need the extra privilege.
you should always double and triple-check commands you issue as the
superuser, since an extra space or missing character can mean irreparable
data loss.
so, the first thing you should do after reading this chapter is to create
an unprivileged user account for yourself for general usage if you have
not already. this applies equally whether you are running a multi-user or
single-user machine. later in this chapter, we discuss how to create
additional accounts, and how to change between the normal user and
superuser.
----------------------------------------------------------------------
system users are those used to run services such as dns, mail, web
servers, and so forth. the reason for this is security; if all services
ran as the superuser, they could act without restriction.
examples of system users are daemon, operator, bind (for the domain name
service), and news. often sysadmins create httpd to run web servers they
install.
----------------------------------------------------------------------
user accounts are the primary means of access for real people to the
system, and these accounts insulate the user and the environment,
preventing the users from damaging the system or other users, and allowing
users to customize their environment without affecting others.
every person accessing your system should have a unique user account. this
allows you to find out who is doing what, prevent people from clobbering
each others' settings or reading each others' mail, and so forth.
each user can set up their own environment to accommodate their use of the
system, by using alternate shells, editors, key bindings, and language.
----------------------------------------------------------------------
+------------------------------------------------------------------------+
| command | summary |
|---------+--------------------------------------------------------------|
| adduser | the recommended command-line application for adding new |
| | users. |
|---------+--------------------------------------------------------------|
| rmuser | the recommended command-line application for removing users. |
|---------+--------------------------------------------------------------|
| chpass | a flexible tool to change user database information. |
|---------+--------------------------------------------------------------|
| passwd | the simple command-line tool to change user passwords. |
|---------+--------------------------------------------------------------|
| pw | a powerful and flexible tool to modify all aspects of user |
| | accounts. |
+------------------------------------------------------------------------+
----------------------------------------------------------------------
8.6.1 adduser
# adduser -v
use option ``-silent'' if you don't want to see all warnings and questions.
check /etc/shells
check /etc/master.passwd
check /etc/group
enter your default shell: csh date no sh tcsh zsh [sh]: zsh
your default shell is: zsh -> /usr/local/bin/zsh
enter your default home partition: [/home]:
copy dotfiles from: /usr/share/skel no [/usr/share/skel]:
send message from file: /etc/adduser.message no
[/etc/adduser.message]: no
do not send message
use passwords (y/n) [y]: y
name: jru
password: ****
fullname: j. random user
uid: 1001
gid: 1001 (jru)
class:
groups: jru wheel
home: /home/jru
shell: /usr/local/bin/zsh
ok? (y/n) [y]: y
added user ``jru''
copy files from /usr/share/skel to /home/jru
add another user? (y/n) [y]: n
goodbye!
#
in summary, we changed the default shell to zsh (an additional shell found
in the ports collection), and turned off the sending of a welcome mail to
added users. we then saved the configuration, created an account for jru,
and made sure jru is in wheel group (so that she may assume the role of
root with the su command.)
note: the password you type in is not echoed, nor are asterisks
displayed. make sure you do not mistype the password twice.
note: just use adduser without arguments from now on, and you will not
have to go through changing the defaults. if the program asks you to
change the defaults, exit the program, and try the -s option.
----------------------------------------------------------------------
8.6.2 rmuser
you can use rmuser to completely remove a user from the system. rmuser
performs the following steps:
#4. removes the user from the system's local password file.
#5. removes the user's home directory (if it is owned by the user).
#6. removes the incoming mail files belonging to the user from /var/mail.
#7. removes all files owned by the user from temporary file storage areas
such as /tmp.
#8. finally, removes the username from all groups to which it belongs in
/etc/group.
note: if a group becomes empty and the group name is the same as the
username, the group is removed; this complements the per-user unique
groups created by adduser(8).
# rmuser jru
matching password entry:
jru:*:1001:1001::0:0:j. random user:/home/jru:/usr/local/bin/tcsh
is this the entry you wish to remove? y
remove user's home directory (/home/jru)? y
updating password file, updating databases, done.
updating group file: trusted (removing group jru -- personal group is empty)
done.
removing user's incoming mail file /var/mail/jru: done.
removing files belonging to jru from /tmp: done.
removing files belonging to jru from /var/tmp: done.
removing files belonging to jru from /var/tmp/vi.recover: done.
#
----------------------------------------------------------------------
8.6.3 chpass
the normal user can change only a small subset of this information, and
only for themselves.
note: chfn and chsh are just links to chpass, as are ypchpass, ypchfn,
and ypchsh. nis support is automatic, so specifying the yp before the
command is not necessary. if this is confusing to you, do not worry, nis
will be covered in chapter 17
----------------------------------------------------------------------
8.6.4 passwd
passwd is the usual way to change your own password as a user, or another
user's password as the superuser.
note: users must type in their original password before changing their
password, to prevent an unauthorized person from changing their password
when the user is away from their console.
% passwd
changing local password for jru.
old password:
new password:
retype new password:
passwd: updating the database...
passwd: done
# passwd jru
changing local password for jru.
new password:
retype new password:
passwd: updating the database...
passwd: done
----------------------------------------------------------------------
8.6.5 pw
----------------------------------------------------------------------
if you run a multi-user system, chances are that you do not trust all of
your users not to damage your system. freebsd provides a number of ways a
system administrator can limit the amount of system resources an
individual user can use. these limits are generally divided into two
sections: disk quotas, and other resource limits.
disk quotas are a way for the system administrator to tell the filesystem
the amount of disk space a user may use; moreover, they provide a way to
quickly check on the disk usage of a user without having to calculate it
every time. quotas are discussed in section 12.5.
the other resource limits include ways to limit the amount of cpu, memory,
and other resources a user may consume. these are defined using login
classes and are discussed here.
resource limits are different from plain vanilla login capabilities in two
ways. first, for every limit, there is a soft (current) and hard limit. a
soft limit may be adjusted by the user or application, but may be no
higher than the hard limit. the latter may be lowered by the user, but
never raised. second, most resource limits apply per process to a specific
user, not the user as a whole. note, however, that these differences are
mandated by the specific handling of the limits, not by the implementation
of the login capability framework (i.e., they are not really a special
case of login capabilities).
and so, without further ado, below are the most commonly used resource
limits (the rest, along with all the other login capabilities, may be
found in login.conf(5)).
coredumpsize
cputime
filesize
this is the maximum size of a file the user may possess. unlike
disk quotas, this limit is enforced on individual files, not the
set of all files a user owns.
maxproc
memorylocked
memoryuse
openfiles
this is the maximum amount of files a process may have open. in
freebsd, files are also used to represent sockets and ipc
channels; thus, be careful not to set this too low. the
system-wide limit for this is defined by the kern.maxfiles sysctl.
sbsize
this is the limit on the amount of network memory, and thus mbufs,
a user may consume. this originated as a response to an old dos
attack by creating a lot of sockets, but can be generally used to
limit network communications.
stacksize
this is the maximum size a process' stack may grow to. this alone
is not sufficient to limit the amount of memory a program may use;
consequently, it should be used in conjunction with other limits.
there are a few other things to remember when setting resource limits.
following are some general tips, suggestions, and miscellaneous comments.
* remember that many limits apply to individual processes, not the user
as a whole. for example, setting openfiles to 50 means that each
process the user runs may open up to 50 files. thus, the gross amount
of files a user may open is the value of openfiles multiplied by the
value of maxproc. this also applies to memory consumption.
----------------------------------------------------------------------
----------------------------------------------------------------------
8.9 groups
the group name to group id map is in /etc/group. this is a plain text file
with four colon-delimited fields. the first field is the group name, the
second is the encrypted password, the third the group id, and the fourth
the comma-delimited list of members. it can safely be edited by hand
(assuming, of course, that you do not make any syntax errors!). for a more
complete description of the syntax, see the group(5) manual page.
if you do not want to edit /etc/group manually, you can use the pw(8)
command to add and edit groups. for example, to add a group called teamtwo
and then confirm that it exists you can use:
# pw groupadd teamtwo
# pw groupshow teamtwo
teamtwo:*:1100:
the number 1100 above is the group id of the group teamtwo. right now,
teamtwo has no members, and is thus rather useless. let's change that by
inviting jru to the teamtwo group.
% id jru
uid=1001(jru) gid=1001(jru) groups=1001(jru), 1100(teamtwo)
as you can see, jru is a member of the groups jru and teamtwo.
for more information about pw(8), see its manual page, and for more
information on the format of /etc/group, consult the group(5) manual page.
----------------------------------------------------------------------
* how to use the kernel configuration file to create and build a new
kernel.
----------------------------------------------------------------------
* faster boot time. since the kernel will only probe the hardware you
have on your system, the time it takes your system to boot will
decrease dramatically.
* less memory usage. a custom kernel often uses less memory than the
generic kernel, which is important because the kernel must always be
present in real memory. for this reason, a custom kernel is especially
useful on a system with a small amount of ram.
----------------------------------------------------------------------
first, let us take a quick tour of the kernel build directory. all
directories mentioned will be relative to the main /usr/src/sys directory,
which is also accessible through /sys. there are a number of
subdirectories here representing different parts of the kernel, but the
most important, for our purposes, are arch/conf, where you will edit your
custom kernel configuration, and compile, which is the staging area where
your kernel will be built. arch represents either i386, alpha, or pc98 (an
alternative development branch of pc hardware, popular in japan).
everything inside a particular architecture's directory deals with that
architecture only; the rest of the code is common to all platforms to
which freebsd could potentially be ported. notice the logical organization
of the directory structure, with each supported device, filesystem, and
option in its own subdirectory.
# mount /cdrom
# mkdir -p /usr/src/sys
# ln -s /usr/src/sys /sys
# cat /cdrom/sys/ssys.[a-d]* | tar -xzvf
next, move to the arch/conf directory 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 mykernel
tip: storing your kernel config file directly under /usr/src can be a
bad idea. if you are experiencing problems it can be tempting to just
delete /usr/src and start again. five seconds after you do that you
realize that you have deleted your custom kernel config file.
you might want to keep your kernel config file elsewhere, and then
create a symbolic link to the file in the i386 directory.
for example:
# cd /usr/src/sys/i386/conf
# mkdir /root/kernels
# cp generic /root/kernels/mykernel
# ln -s /root/kernels/mykernel
note: you must execute these and all of the following commands under the
root account or you will get permission denied errors.
now, edit mykernel with your favorite text editor. if you are just
starting out, the only editor available will probably be vi, which is too
complex to explain here, but is covered well in many books in the
bibliography. however, freebsd does offer an easier editor called ee
which, if you are a beginner, should be your editor of choice. feel free
to change the comment lines at the top to reflect your configuration or
the changes you have made to differentiate it from generic.
if you have built a kernel under sunos or some other bsd operating system,
much of this file will be very familiar to you. if you are coming from
some other operating system such as dos, on the other hand, the generic
configuration file might seem overwhelming to you, so follow the
descriptions in the configuration file section slowly and carefully.
you must now compile the source code for the kernel. there are two
procedures you can use to do this, and the one you will use depends on why
you are rebuilding the kernel, and the version of freebsd you are running.
* if you have installed only the kernel source code, use procedure 1.
* if you are running a freebsd version prior to 4.0, and you are not
upgrading to freebsd 4.0 or higher using the make world procedure, use
procedure 1.
* if you are building a new kernel without updating the source code
(perhaps just to add a new option, such as ipfirewall) you can use
either procedure.
* if you are rebuilding the kernel as part of a make world process, use
procedure 2.
# /usr/sbin/config mykernel
# make depend
# make
# make install
# cd /usr/src
note: in freebsd 4.2 and older you must replace kernconf= with kernel=.
4.2-stable that was fetched after feb 2nd, 2001 does recognize
kernconf=.
if you have not upgraded your source tree in any way (you have not run
cvsup, ctm, or used anoncvs), then you should use the config, make depend,
make, make install sequence.
the new kernel will be copied to the root directory as /kernel and the old
kernel will be moved to /kernel.old. now, shutdown the system and reboot
to use your kernel. in case something goes wrong, there are some
troubleshooting instructions at the end of this chapter. be sure to read
the section which explains how to recover in case your new kernel does not
boot.
note: if you have added any new devices (such as sound cards) you may
have to add some device nodes to your /dev directory before you can use
them. for more information, take a look at "making device nodes" later
on in this chapter.
----------------------------------------------------------------------
this requirement was removed in the 4.x branch, which this book covers,
so if you are on a pre-4.x system, see the /usr/src/sys/i386/conf/lint
and /usr/src/sys/i386/conf/generic files on your system for examples.
#
# generic -- generic kernel configuration file for freebsd/i386
#
# for more information on this file, please read the handbook section on
# kernel configuration files:
#
# http://www.freebsd.org/handbook/kernelconfig-config.html
#
# the handbook is also available locally in /usr/share/doc/handbook
# if you've installed the doc distribution, otherwise always see the
# freebsd world wide web server (http://www.freebsd.org/) for the
# latest information.
#
# an exhaustive list of options and more detailed explanations of the
# device lines is also present in the ./lint configuration file. if you are
# in doubt as to the purpose or necessity of a line, check first in lint.
#
# $freebsd: src/sys/i386/conf/generic,v 1.246 2000/03/09 16:32:55 jlemon exp
$
the following are the mandatory keywords required in every kernel you
build:
machine i386
cpu i386_cpu
cpu i486_cpu
cpu i586_cpu
cpu i686_cpu
the above specifies the type of cpu you have in your system. you may have
multiple instances of the cpu line (i.e., you are not sure whether you
should use i586_cpu or i686_cpu), however, for a custom kernel, it is best
to specify only the cpu you have. if you are unsure of your cpu type, you
can use the dmesg command to view your boot up messages.
the alpha architecture has different values for cpu. they include:
cpu ev4
cpu ev5
if you are using an alpha machine, you should be using one of the above
cpu types.
ident generic
maxusers n
the maxusers option sets the size of a number of important system tables.
this number is supposed to be roughly equal to the number of simultaneous
users you expect to have on your machine.
starting with freebsd 4.5, the system will auto-tune this setting for you
if you explicitly set it to 0[4]. if you are using an earlier version of
freebsd, or you want to manage it yourself you will want to set maxusers
to at least 4, especially if you are using the x window system or
compiling software. the reason is that the most important table set by
maxusers is the maximum number of processes, which is set to 20 + 16 *
maxusers, so if you set maxusers to 1, then you can only have 36
simultaneous processes, including the 18 or so that the system starts up
at boot time, and the 15 or so you will probably create when you start the
x window system. even a simple task like reading a manual page will start
up nine processes to filter, decompress, and view it. setting maxusers to
64 will allow you to have up to 1044 simultaneous processes, which should
be enough for nearly all uses. if, however, you see the dreaded proc table
full error when trying to start another program, or are running a server
with a large number of simultaneous users (like ftp.freebsd.org), you can
always increase the number and rebuild.
note: maxusers does not limit the number of users which can log into
your machine. it simply sets various table sizes to reasonable values
considering the maximum number of users you will likely have on your
system and how many processes each of them will be running. one keyword
which does limit the number of simultaneous remote logins is
pseudo-device pty 16.
npx0 is the interface to the floating point math unit in freebsd, which is
either the hardware co-processor or the software math emulator. this is
not optional.
this is the generic loopback device for tcp/ip. if you telnet or ftp to
localhost (a.k.a., 127.0.0.1) it will come back at you through this
pseudo-device. this is mandatory.
everything that follows is more or less optional. see the notes underneath
or next to each option for more information.
note: the normal math co-processor emulation routines that come with
freebsd are not very accurate. if you do not have a math co-processor,
and you need the best accuracy, it is recommended that you change this
option to gpl_math_emulate to use the gnu math support, which is not
included by default for licensing reasons.
networking support. leave this in, even if you do not plan to be connected
to a network. most programs require at least loopback networking (i.e.,
making network connections within your pc), so this is essentially
mandatory.
this is the basic hard drive filesystem. leave it in if you boot from the
hard disk.
this option enables soft updates in the kernel, this will help speed up
write access on the disks. they are enabled by default in the 4.x branch
but may not be turned on. review the output from mount(8) to see if you
have them enabled. if you do not see the soft-updates option then you will
need to activate it using the tunefs(8) or newfs(8) for new filesystems.
now you simply need to either reboot, or run the command mount /tmp.
the network filesystem. unless you plan to mount partitions from a unix
file server over tcp/ip, you can comment these out.
the ms-dos filesystem. unless you plan to mount a dos formatted hard drive
partition at boot time, you can safely comment this out. it will be
automatically loaded the first time you mount a dos partition, as
described above. also, the excellent mtools software (in the ports
collection) allows you to access dos floppies without having to mount and
unmount them (and does not require msdosfs at all).
the iso 9660 filesystem for cdroms. comment it out if you do not have a
cdrom drive or only mount data cds occasionally (since it will be
dynamically loaded the first time you mount a data cd). audio cds do not
need this filesystem.
compatibility with 4.3bsd. leave this in; some programs will act strangely
if you comment this out.
this causes the kernel to pause for 15 seconds before probing each scsi
device in your system. if you only have ide hard drives, you can ignore
this, otherwise you will probably want to lower this number, perhaps to 5
seconds, to speed up booting. of course, if you do this, and freebsd has
trouble recognizing your scsi devices, you will have to raise it back up.
allow users to grab the console, which is useful for x users. for example,
you can create a console xterm by typing xterm -c, which will display any
write, talk, and any other messages you receive, as well as any console
messages sent by the kernel.
this option allows you to boot the configuration editor from the boot
menu.
options visual_userconfig #visual boot -c editor
this option allows you to boot the visual configuration editor from the
boot menu.
this option provides for system v shared memory. the most common use of
this is the xshm extension in x, which many graphics-intensive programs
will automatically take advantage of for extra speed. if you use x, you
will definitely want to include this.
support for system v semaphores. less commonly used but only adds a few
hundred bytes to the kernel.
support for system v messages. again, only adds a few hundred bytes to the
kernel.
note: the ipcs(1) command will list any processes using each of these
system v facilities.
this option enables icmp error response bandwidth limiting. you typically
want this option as it will help protect the machine from denial of
service packet attacks.
device isa
all pcs supported by freebsd have one of these. if you have an ibm ps/2
(micro channel architecture), you cannot run freebsd at this time (support
is being worked on).
device eisa
# floppy drives
device fdc0 at isa? port io_fd1 irq 6 drq 2
device fd0 at fdc0 drive 0
device fd1 at fdc0 drive 1
this is the floppy drive controller. fd0 is the a: floppy drive, and fd1
is the b: drive.
device ata
this driver supports all ata and atapi devices. you only need one device
ata line for the kernel to detect all pci ata/atapi devices on modern
machines.
this is needed along with device ata for atapi disk drives.
this is needed along with device ata for atapi cdrom drives.
this is needed along with device ata for atapi floppy drives.
this is needed along with device ata for atapi tape drives.
this makes the controller number static (like the old driver) or else the
device numbers are dynamically allocated.
# scsi controllers
device ahb # eisa aha1742 family
device ahc # aha2940 and onboard aic7xxx devices
device amd # amd 53c974 (teckram dc-390(t))
device dpt # dpt smartcache - see lint for options!
device isp # qlogic family
device ncr # ncr/symbios logic
device sym # ncr/symbios logic (newer chipsets)
scsi controllers. comment out any you do not have in your system. if you
have an ide only system, you can remove these altogether.
# scsi peripherals
device scbus # scsi bus (required)
device da # direct access (disks)
device sa # sequential access (tape etc)
device cd # cd
device pass # passthrough device (direct scsi
access)
scsi peripherals. again, comment out any you do not have, or if you have
only ide hardware, you can remove them completely.
# raid controllers
device ida # compaq smart raid
device amr # ami megaraid
device mlx # mylex dac960 family
supported raid controllers. if you do not have any of these, you can
comment them out or remove them.
the keyboard controller (atkbdc) provides i/o services for the at keyboard
and ps/2 style pointing devices. this controller is required by the
keyboard driver (atkbd) and the ps/2 pointing device driver (psm).
the atkbd driver, together with atkbdc controller, provides access to the
at 84 keyboard or the at enhanced keyboard which is connected to the at
keyboard controller.
use this device if your mouse plugs into the ps/2 mouse port.
sc0 is the default console driver, which resembles a sco console. since
most full-screen programs access the console through a terminal database
library like termcap, it should not matter whether you use this or vt0,
the vt220 compatible console driver. when you log in, set your term
variable to scoansi if full-screen programs have trouble running under
this console.
# enable this and pcvt_freebsd for pcvt vt220 compatible console driver
#device vt0 at isa?
#options xserver # support for x server on a vt console
#options fat_cursor # start with block cursor
# if you have a thinkpad, uncomment this along with the rest of the pcvt
lines
#options pcvt_scanset=2 # ibm keyboards are non-std
these are the four serial ports referred to as com1 through com4 in the
ms-dos/windows world.
note: if you have an internal modem on com4 and a serial port at com2,
you will have to change the irq of the modem to 2 (for obscure technical
reasons, irq2 = irq 9) in order to access it from freebsd. if you have a
multiport serial card, check the manual page for sio(4) for more
information on the proper values for these lines. some video cards
(notably those based on s3 chips) use io addresses in the form of
0x*2e8, and since many cheap serial cards do not fully decode the 16-bit
io address space, they clash with these cards making the com4 port
practically unavailable.
each serial port is required to have a unique irq (unless you are using
one of the multiport cards where shared interrupts are supported), so
the default irqs for com3 and com4 cannot be used.
# parallel port
device ppc0 at isa? irq 7
note: all three of the above are required to enable parallel printer
support.
this is for an iomega zip drive. it requires scbus and da support. best
performance is achieved with ports in epp 1.9 mode.
various pci network card drivers. comment out or remove any of these not
present in your system.
# pci ethernet nics that use the common mii bus controller code.
device miibus # mii bus support
mii bus support is required for some pci 10/100 ethernet nics, namely
those which use mii-compliant transceivers or implement transceiver
control interfaces that operate like an mii. adding device miibus to the
kernel config pulls in support for the generic miibus api and all of the
phy drivers, including a generic one for phys that are not specifically
handled by an individual driver.
sl is for slip support. this has been almost entirely supplanted by ppp,
which is easier to set up, better suited for modem-to-modem connection,
and more powerful. the number after sl specifies how many simultaneous
slip sessions to support.
this is for kernel ppp support for dial-up connections. there is also a
version of ppp implemented as a userland application that uses tun and
offers more flexibility and features such as demand dialing. the number
after ppp specifies how many simultaneous ppp connections to support.
this is used by the userland ppp software. a number after tun specifies
the number of simultaneous ppp sessions to support. see the ppp section of
this book for more information.
pesudo-device gif
or
this implements ipv6 over ipv4 tunneling, ipv4 over ipv6 tunneling, ipv4
over ipv4 tunneling, and ipv6 over ipv6 tunneling. beginning with freebsd
4.4 the gif device is ``auto-cloning'', and you should use the first
example (without the number after gif). earlier versions of freebsd
require the number.
this pseudo-device captures packets that are sent to it and diverts them
to the ipv4/ipv6 translation daemon.
# usb support
#device uhci # uhci pci->usb interface
#device ohci # ohci pci->usb interface
#device usb # usb bus (required)
#device ugen # generic
#device uhid # ``human interface devices''
#device ukbd # keyboard
#device ulpt # printer
#device umass # disks/mass storage - requires scbus and da
#device ums # mouse
# usb ethernet, requires mii
#device aue # admtek usb ethernet
#device cue # catc usb ethernet
#device kue # kawasaki lsi usb ethernet
----------------------------------------------------------------------
suppose you add the ide cd-rom support to the kernel. the line to add is:
device acd0
this means that you should look for some entries that start with acd0 in
the /dev directory, possibly followed by a letter, such as c, or preceded
by the letter r, which means a ``raw'' device. it turns out that those
files are not there, so you must change to the /dev directory and type:
# sh makedev acd0
when this script finishes, you will find that there are now acd0c and
racd0c entries in /dev so you know that it executed correctly.
for sound cards, the following command creates the appropriate entries:
# sh makedev snd0
note: when creating device nodes for devices such as sound cards, if
other people have access to your machine, it may be desirable to protect
the devices from outside access by adding them to the /etc/fbtab file.
see fbtab(5) for more information.
follow this simple procedure for any other non-generic devices which do
not have entries.
note: all scsi controllers use the same set of /dev entries, so you do
not need to create these. also, network cards and slip/ppp
pseudo-devices do not have entries in /dev at all, so you do not have to
worry about these either.
----------------------------------------------------------------------
there are five categories of trouble that can occur when building a custom
kernel. they are:
config fails:
make fails:
after booting with a good kernel you can check over your
configuration file and try to build it again. one helpful resource
is the /var/log/messages file which records, among other things,
all of the kernel messages from every successful boot. also, the
dmesg(8) command will print the kernel messages from the current
boot.
and, if you want to ``lock'' your new kernel into place, or any
file for that matter, so that it cannot be moved or tampered
with:
----------------------------------------------------------------------
chapter 10 security
much of this chapter has been taken from the security(7) manual page by
matthew dillon.
----------------------------------------------------------------------
10.1 synopsis
----------------------------------------------------------------------
10.2 introduction
security is a function that begins and ends with the system administrator.
while all bsd unix multi-user systems have some inherent security, the job
of building and maintaining additional security mechanisms to keep those
users ``honest'' is probably one of the single largest undertakings of the
sysadmin. machines are only as secure as you make them, and security
concerns are ever competing with the human necessity for convenience. unix
systems, in general, are capable of running a huge number of simultaneous
processes and many of these processes operate as servers - meaning that
external entities can connect and talk to them. as yesterday's
mini-computers and mainframes become today's desktops, and as computers
become networked and internetworked, security becomes an even bigger
issue.
a user account compromise is even more common than a dos attack. many
sysadmins still run standard telnetd, rlogind, rshd, and ftpd servers on
their machines.