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

FreeBSD configuration File

Our /etc/rc.con

To summarize the changes from the defaults, /etc/rc.conf for gw should now contain the following entries:

firewall_enable="YES"    # Set to YES to enable firewall functionality
firewall_type="client"   # Firewall type (see /etc/rc.firewall)
natd_enable="YES"        # Enable natd (if firewall_enable == YES).
natd_interface="tun0"    # Public interface or IPaddress to use.
syslogd_flags=" "        # Allow logging from other systems
inetd_enable="YES"       # Run inetd
named_enable="YES"       # Run named, the DNS server (or NO).
sshd_enable="YES"        # Enable sshd
nfs_client_enable="YES"  # This host is an NFS client (or NO).
nfs_server_enable="YES"  # This host is an NFS server (or NO).
ntpd_enable="YES"        # Run ntpd Network Time Protocol (or NO).
defaultrouter=""  # Set to default gateway (or NO).
gateway_enable="YES"     # Set to YES if this host will be a gateway.
lpd_enable="YES"         # Run the line printer daemon.
start_vinum="YES"        # set to YES to start vinum

The corresponding /etc/rc.conf for andante should now contain the following entries:

inetd_enable="YES"       #Run inetd
nfs_client_enable="YES"  #This host is an NFS client (or NO).
ntpd_enable="YES"        #Run ntpd Network Time Protocol (or NO).
moused_enable="YES"      #Run the mouse daemon
lpd_enable="YES"         #Run the line printer daemon.
start_vinum="YES"        #set to YES to start vinum

Files you need to change

rc.conf is only part of the story, of course. The /etc directory contains a large number of other files, nearly all of them relating to the configuration. Some of them, like /etc/amd.map and /etc/dm.conf, are intended for specific subsystems that we don't discuss here. In general, they have comments in them to explain their purpose, and they have a man page in section 5 of the manual.

Most of the files in /etc are intended to be left the way they are. Some, however, will definitely need changing, and there are others that you may need to change. In this section we'll look at the ones you almost certainly need to change, and on page 569 we'll look at the ones you may have to change. On page 576 we'll look at the some of the more interesting ones you should normally leave alone.


/etc/exports is a list of file systems that should be NFS exported. We looked at it on page 463. See also the man page exports(5).


/etc/fstab contains a list of file systems known to the system. The script /etc/rc starts mount twice during system startup first to mount the local file systems, and later to mount the NFS file system. mount will mount all file systems in /etc/fstab unless they are explicitly excluded.

Here's atypical /etc/fStab, from host freebie.example.org:

#File system  Mount point   fstype  flags
/dev/ad0s1a   /             ufs     rw                  1 1
/dev/ad0s1b   none          swap    sw                  0 0
/dev/ad0s1e   /usr          ufs     rw                  2 2
/dev/da0b     none          swap    sw                  0 0
/dev/da0h     /src          ufs     rw                  2 2
/dev/dalh     /home         ufs     rw                  2 2
/dev/da2b     none          swap    sw                  0 0
/dev/da2e     /S            ufs     rw,noauto           2 2
/dev/da3a     /mod          ufs     rw,noauto           0 0
Proc          /proc         procfs  rw                  0 0
/dev/cd0a     /cdrom/1      cd9660  ro,noauto           0 0
/dev/cd1a     /cdrom/2      cd9660  ro,noauto           0 0
/dev/cd2a     /cdrom/3      cd9660  ro,noauto           0 0
/dev/cd3a     /cdrom/4      cd9660  ro,noauto           0 0
/dev/cd4a     /cdrom/5      cd9660  ro,noauto           0 0
/dev/cd5a     /cdrom/6      cd9660  ro,noauto           0 0
/dev/cd6a     /cdrom/7      cd9660  ro,noauto           0 0
/dev/cd7a     /cdrom/8      cd9660  ro,noauto           0 0
presto:/      /presto       nfs     soft,rw,noauto      0 0
presto:/usr   /presto/usr   nfs     soft,rw,noauto      0 0
presto:/home  /presto/home  nfs     soft,rw,noauto      0 0
bumble:/      /bumble       nfs     soft,rw,noauto      0 0
bumble:/usr   /bumble/usr   nfs     soft,rw,noauto      0 0
wait:/C       /C            nfs     soft,rw,noauto      0 0
wait:/        /wait         nfs     soft,rw,noauto,tcp  0 0

This information has the following meaning:

  • The first column contains either the name of a device (for swap, ufs and cd9660 file systems), the name of a file system (for NFS file systems), or proc for the proc file system.
  • The lines beginning with # are commented out: mount ignores them completely.
  • The second column is either a mount point or the keyword none in the case of a partition that is not mounted, such as swap.
  • The third column is the kind of file system (or swap).
  • The fourth column are flags relating to the particular file system being mounted. We'll look at them below.
  • The fifth column is used by dump(8) to determine how often to dump the file system. 0 means not to dump the file system. dump only understands ufs file systems, so this field should be 0 for all other file systems.
  • The sixth column is the pass number for running fsck at boot time. Again, 0 means "'don't run fck." Normally you set pass 1 only for the root file system, and pass 2 for other file systems.

The flags are worth a closer look. Some of the more common are:

Таблица 30.1. Mount flags
Flag Purpose
ro Mount read-only.
rw Mount read/write.
sw Mount as swap.
noauto Don't mount automatically.
soft For an NFS mount, fail if the request times out. If you don't specify this option, NFS will keep retrying for ever.
tcp For NFS only, mount with TCP transport rather than the standard UDP transport. This feature is supported almost only by BSD systems—check whether the other end offers TCP transport.

For NFS mount fags, see "Chapter 24" , page 442.

Why are there so many entries with the noauto keyword? If you don't bother to mount them, why bother to mention them?

If file system has an entry in /etc/fstab, mount is clever enough to get all the information it needs from this file. You just need to specify the name of the mount point or the name of the special device (for ufs and cd9660) or the remote file system (for NFS). This is particularly useful for cd9660, the CD file system type. Without an entry in /etc/fstab, you would have to write something like the following to mount a CD-ROM.

# mount -t cd9660 -o ro /dev/cd0a /cdrom

With the entry, you can simplify this to:

mount /cdrom