Опубликован: 06.08.2012 | Доступ: свободный | Студентов: 1328 / 46 | Оценка: 5.00 / 5.00 | Длительность: 53:41:00
Лекция 30:

FreeBSD configuration File

Аннотация: /etc/rc.conf; Files you need to change; Files you might need to change; Files you should not change; Obsolete configuration files.
Ключевые слова: ONE, Unix, ALL, system, configuration, information, text, directory, ITS, subdirectory, this, method, primitive, comparison, with, GUI, editor, registry, significant, SEE, real, format, CAN, read, AND, even, documented, TIME, MOST, problem, resolution, reinstall, declaration, very, slow, cause, find, if, look, chapter, CASE, GET, additional, AS, FROM, section, MAN, First, shell script, NOT, dependent, walk-through, change, relevant, install, create, script, default, VALUES, end, CHECK, override, upgrade, leave, still, build, server, laptop, wireless, constant, Width, bold, Font, fixed-width font, double, single quote, incorrect, shell, include, IDEA, convention, previous, Line, revision, CVS, repository, release, new, startup, NEXT, generation, netbsd, mistake, set, Swap, Entry, swapping, driver, control, used, USB, pc card, daemon, OLD, DESCRIPTION, running, list, background, off, stay, Search, Modify, integrity, inconsistency, inhibit, behaviour, damage, strength, single-user, option, meaning, answer, perform, fail, pass, qualified name, host, SUN, NIS, book, client, firewall, WHERE, technical, reason, result, Add, dynamic allocation, example, define, package, NAT, IP, utility, State, interface, course, Ethernet, DHCP, LIKE, implementation, USER, PPP, empty, security, flag, remote, comment, able, log, remote system, useful, entire, network, enabled, location, standard, load, X-10, connect, NFS, secure, RPC, DATE, SAW, routing, IPX, proprietary, networking protocol, routing table, ATM, ISDN, PARAMETER, denial, service, attack, respond, ping, broadcast address, Internet, fast, reply, vulnerability, protocol, DESCRIBE, alternate, keyboard map, MAP, screen, setting, mouse driver, global, virtual, alternative, mail, MTA, dump, accounting, OSF/1, emulation, SEQUENCE, file system, choice, MFS, memory, dynamic library, cache, issue, security check, disable, dynamic, remove, kernel, security level, init, insecure, immutable, tampering, network security, packet filter, level, EXCEPT, finally, diagnostic tool, alpha, processor, go, boot, internal, message buffer, entropy, summarization, part, story, general, explain, manual, Left, boot time, customize, client side, permanent connection, spooler, exposure, authenticated user, root user, configuration database, cpu time, data segment, data file, core dump, virtual terminal, configuration parameter, serial port, SIO, device register, motherboard, unit number, disk drive, scsi device, LUN, host adapter, networking functionality, machine-readable, serial device, control sequence, environment variable, operation, side effect

One of the outstanding things about UNIX is that all system configuration information is stored in text files, usually in the directory /etc or its subdirectories. Some people consider this method primitive by comparison with a flashy GUI configuration editor or a "registry," but it has significant advantages. In particular, you see the exact system configuration. With a GUI editor, the real configuration is usually stored in a format that you can't read, and even when you can, it's un documented. Also, you can see more of the configuration at a time: a GUI editor usually presents you with only small parts of the configuration, and it's difficult to see the relationships ("standing outside and looking in through a window").

In the Microsoft world, one of the most common methods of problem resolution is to reinstall the system. This is a declaration of bankruptcy: it's very slow, you're liable to cause other problems on the way, and you never find out what the problem was. If you have problems with your FreeBSD system configuration, don't reinstall the system. Take a look at the configuration files, and there's a good chance that you'll find the problem there.

Many configuration files are the same across all versions of UNIX. This chapter touches on them briefly, but in many case you can get additional information in books such as the UNIX System Administration Handbook, by Evi Nemeth, Garth Snyder, Scott Seebass, and Trent R. Hein. In all cases, you can get more information from section 5 of the man pages.

In the following section, we'll first look at /etc/rc.conf, the main configuration file. We'll look at the remaining configuration files on page 566.

/etc/rc.conf

/etc/rc.conf is the main system configuration file. In older releases of FreeBSD, this file was called /etc/sysconfig.

/etc/rc.conf is a shell script that is intended to be the one file that defines the configuration of your system—that is to say, what the system needs to do when it starts up. It's not quite that simple, but nearly all site-dependent information is stored here. We'll walk through the version that was current at the time of writing. The files will change as time goes on, but most of the information will remain relevant.

/etc/rc.conf is completely your work. When you install the system, there is no such file: you create it, usually implicitly with the aid of sysinstall. The system supplies a script /etc/defaults/rc.conf that contains default values for everything you might put in /etc/rc.conf, and which the other configuration files read to get their definitions. When the system starts, it first reads /etc/defaults/rc.conf. Commands at the end of this file check for the existence of the file /etc/rc.conf and read it in if they find it, so that the definitions in /etc/rc.conf override the defaults in /etc/defaults/rc.conf. This makes it easier to upgrade: just change the file with the defaults, and leave the site-specific configuration alone. You may still need to change some things, but it'll be a lot easier.

In this section we'll walk through /etc/defaults/rc.conf. As we do, we'll build up two different /etc/rc.conf files, one for a server and one for a laptop connected with an 802.11b wireless card. To avoid too much confusion, I show the text that goes into /etc/rc.conf in constant width bold font, whereas the text in /etc/defaults/rc.conf is in constant width font.

# !/bin/sh
#
# This is rc.conf - a file full of useful variables that you can set
# to change the default startup behavior of your system. You should
# not edit this file! Put any overrides into one of the ${rc_conf_files}
# instead and you will be able to update these defaults later without # spamming your local configuration information.
#
# The ${rc_conf_files} files should only contain values which override
# values set in this file. This eases the upgrade path when defaults
# are changed and new features are added.
#
# All arguments must be in double or single quotes.
#
# $FreeBSD: src/etc/defaults/rc.conf,v 1.159 2002/09/05 20:14:40 gordon Exp $

The claim that all arguments must be in double or single quotes is incorrect. Both this file and /etc/rc.conf are Bourne shell scripts and you only need quotes if the values you include contain spaces. It's a good idea to stick to this convention, though, in case the representation changes.

Note the version information on the previous line (1.159). Your /etc/defaults/rc.conf will almost certainly have a different revision. If you have a CVS repository on line (see "Chapter 31" ), you can see what is changed with the following commands:

$ cd /usr/src/etc/defaults
$ cvs diff -wu -r1.159 rc.can

Continuing,

#################################################################
###Important initial Boot-time options ##########################
#################################################################
rc_ng="YES"              # Set to NO to disable new-style rc scripts.
rc_info="YES"            # Enables display of informational messages at boot.
rcshutdown_timeout="30"  # Seconds to wait before terminating rc.shutdown

FreeBSD Release 5 has a new method of system startup, called RCng (run commands, next generation). This method was originally introduced in NetBSD. Don't change these values unless you know exactly what you are doing. If you make a mistake, you may find it impossible to start the system.

swapfile="NO"  # Set to name of swapfile if aux swapfile desired.

Normally you set up entries for swap partitions in /etc/fstab. This entry refers only to swapping on files, not for partitions. It requires the md driver, which we looked at on page 245.

apm_enable="NO"   # Set to YES to enable APM BIOS functions (or NO).
apmd_enable="NO"  # Run apmd to handle APM event from userland.
apmd_flags=""     # Flags to apmd (if enabled)

These parameters cover APM, Advanced Power Management.

devd_enable="NO"        # Run devd, to trigger programs on device tree changes.
pccard_enable="NO"      # Set to YES if you want to configure PCCARD devices.
pccard_mem="DEFAULT"    # If pccard_enable=YES, this is card memory address.
pccard_beep="2"         # pccard beep type.
pccard_ifconfig="NO"    # Specialized pccard ethernet configuration (or NO).
pccardd_flags=" z"      # Additional flags for pccardd
pccard_conf="/etc/defaults/pccard.conf"  # pccardd(8) config file
pccard_ether_delay="5"  # Delay before trying to start dhclient in pccard_ether

These parameters control devd, the device daemon used primarily for hot-pluggable devices such as USB and PC Card, and pccardd, the daemon for the old PC Card code. See page 159 for more details of devd, and page 161 for a brief description of pccardd and the old PC Card code.

If you're running PC Card devices, you would start devd. That's what we put in the /etc/rc.conf for andante:

devd_enable="YES"

Next comes a list of directories that are searched for startup scripts:

local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d" # startup script dirs.
script_name_sep=" "    #Change if startup scripts' names contain spaces

If you come from a System V background, you would expect to find these scripts in the directories such as /etc/rc2.d.

rc_conf_files="/etc/rc.conf /etc/rc.conf.local"

rc_conf_files is a list of files to read after this file. You'll recognize /etc/rc.conf, which we discussed above. /etc/rc.conf.local is an idea that hasn't completely died, but there's a good chance that it will. You'd be best off not to use it until you're sure it's going to stay.

For obvious reasons, this is one entry in /etc/defaults/rc.conf that you can't override in /etc/rc.conf. If you really want to search other files, you'll have to modify /etc/de-faults/rc.conf. It's still not a good idea.

fsck_y_enable="NO"      # Set to YES to fsck -y if the initial preen fails.
background_fsck="YES"   # Attempt to run fsck in the background
extra_netfs_types="NO"  # List of network extra filesystem types for delayed
                                  # mount at startup (or NO)

On system startup, the system checks the integrity of all file systems. It does this in a number of steps:

  • First, it checks the superblock, the key to the file system, to see whether it was unmounted before the system stopped. If so, it assumes that the file systems are consistent and continues with the startup.
  • If any file system was not unmounted, the system probably crashed or was turned off without proper shutdown. The file system could contain inconsistent data, so the startup scripts run fsck against the file system.
  • If you're running with soft updates and checkpointing, you may be able to perform the fsck in the background, in other words in parallel with other activities. If you have a good reason, you can inhibit this behaviour by setting background_fsck to NO.
  • If the file system is badly damaged, the "standard strength" fsck may not be able to recover the file system. In this case, the normal action is to drop into single-user mode and let a human take a look at it.

The usual first action of the human is to run fsck with the -y option, meaning "answer yes to all questions from fck". If you set fsck_y_enable to YES, the startup scripts will perform this task for you. It's still possible that the check will fail, so this is not enough to ensure that you will always pass fsck, but it helps.

##################################################
### Network configuration sub-section ##################
##################################################
### Basic network and firewall/security options: ###
hostname=""      # Set this!

hostname is the fully qualified name of the host. Always set it in /etc/rc.conf. See page 302 for more details. In our /etc/rc.conf we'll put:

hostname="gw.example.org"
hostname="andante.example.org"