Front | Info | Lists | Newsfeeds | Study Guide | What is BSD?
Advertisement: The OpenBSD PF Packet Filter Book: PF for NetBSD, FreeBSD, DragonFly and OpenBSD

BSD Links
·New Links
·User Groups

This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at

Configure a service to start at boot time


Recognize that the BSD boot process does not use runlevels. Be able to configure essential services to start at boot time to minimize the impact of a system reboot.



The BSDs all run the /etc/rc system startup script. It is ran by /sbin/init (known as the "parent of all processes") before it initializes the terminals and local logins.

Note that the BSDs do not have System V-style runlevels, such as found on Linux, where different startup scripts are available for networking, X11 workstation, server, etc. (On systems with multiple runlevels, these are normally done by using symlinks in the specific runlevel directories pointing to the desired startup scripts.)

TODO: should this mention single-user mode here? Point to it.

The /etc/rc scripts vary on each system, but all basically do the same steps:

  • Load the "rc.conf" configurations.
  • Enable special virtual disks, like concatenated disks, Vinum Logical Volume Manager, and RAID devices.
  • Enable swap device for virtual memory.
  • Check file systems.
  • Mount special disks or pseudo-devices.
  • Mount the main / (root) disk partition.
  • Set device-specific flags for terminals. (TODO: should I remove this?)
  • Configure system console driver, such as setting a video mode, screen burner timeout, keyboard bell's pitch, and keyboard encoding.
  • Loading initial firewall (packet filter) rules.
  • Set default settings (tunables) for the kernel.
  • Set the hostname.
  • Turn on the network.
  • Load custom packet filter rules.
  • Mount /usr and /var partitions (if not already mounted).
  • Initialize (seed) random devices.
  • Clean up junk and /tmp files.
  • Save a copy of the "dmesg" boot messages.
  • Startup the syslogger daemon.
  • Mount other filesystems.
  • Enable swap files (if any).
  • Save operating system core dump. TODO: why on OpenBSD does this happen after enabling swap?
  • Create kernel and /dev device databases.
  • Set default ownership and permissions on terminal devices.
  • Update the "message of the day".
  • Create runtime link editor directory cache. (TODO: reword that)
  • Check for vi editor recovery files.
  • Generate SSH host keys if needed.
  • Start the SSH server.
  • Start cron.

Some other tasks that may be enabled include:

  • Startup the "named" DNS server.
  • Start IKE key management daemon (and generate key if needed).
  • Start IPsec SA failover synchronization daemon.
  • Configure IPsec.
  • Start the RPC program number mapper server.
  • Start the YP/NIS database services.
  • Enable NFS services.
  • Start filesystem auto-mounter. TODO: "file system" or "filesystem"? Be consistent
  • Set date over network.
  • Start network time server.
  • Start Arla File System (AFS) cache manager. (Footnote: AFS is a distributed file system.)
  • Check and enable file system quotas.
  • Set kernel security level.
  • Enable system accounting.
  • Start various networking daemons, like routed and dhcpd.
  • Enable PPP over ethernet.
  • Start the "watchdog" daemon.
  • Start "lpd" printer server.
  • Start mail server.
  • Start FTP server.
  • Start inetd.
  • Set audio system mixer variables.
  • Start Kerberos services.
  • Start Advanced Power Management (APM) monitor.
  • Start mouse pointer daemon.
  • Start X Display Manager.

TODO: more to list

On OpenBSD, the /etc/rc script is mostly self-contained, while on DragonFly, FreeBSD, and NetBSD, the /etc/rc script runs many individual startup scripts, commonly found in the /etc/rc.d/ directory. Details about about using rc.d scripts as used on NetBSD, FreeBSD and DragonFly are covered in section Use an rc(8) script to determine if a service is running and start, restart or stop it as required.

The BSDs primarily use /etc/rc.conf to configure what is started up.

The configurations are done by setting a shell variable so be careful to use proper Bourne shell syntax such as no spaces around equal signs and making sure quotes are ended.

OpenBSD Configuration

On OpenBSD, /etc/rc.conf contains the system defaults. It is suggested to keep custom settings in /etc/rc.conf.local which overrides the defaults.

On OpenBSD, the shell variables can be set to "NO" to disable that feature or set to the command-line arguments (flags). For example, here is an example of some enabled settings on OpenBSD:

sendmail_flags="-L sm-mta -C/etc/mail/ -bd -q30m"

And here are some disabled settings on OpenBSD:

nfsd_flags="-tun 4"

Note in the above example, even though spamlogd_flags is not set to NO, it is disabled because spamd_flags=NO. And even though nfsd_flags has command-line arguments, it also disabled via nfs_server=NO. TODO: do formatting here

TODO: add separate sections for other BSDs here

On NetBSD, FreeBSD, and DragonFly, the rc.conf defaults are stored in the /etc/defaults/rc.conf file. The settings in /etc/rc.conf override the defaults. Do not edit the defaults so upgrades are easier.

TODO: FreeBSD and DragonFly also use /etc/rc.conf.local by default but NetBSD does not. TODO: /etc/rc.conf.d/ directory is also available but don't over in this intro book?

TODO: make sure this is not redundant with other sections


Practice Exercises

More information

rc.conf(5) (or rc.conf(8) on OpenBSD), rc(8), inetd(8)

Front | Information | Lists | Newsfeeds