System Startup

Table of Contents
  1. Section 1 Turn Features On
  2. Section 2 Switch Programs On
  3. Section 3 Configuration Options

[ ref OpenBSD 4.9, rc(8), rc.conf(8) ]

OpenBSD's startup instructions are built into the script /etc/rc "command scripts for system startup" which are normally configured through the 'localised' files:

  • /etc/rc.conf.local
  • /etc/rc.local

We do not make updates to the 'standard' files rc or rc.conf because this discipline will simplify upgrading to future versions of the Operating System. We make our modifications to 'localised' versions. rc.conf.local is the localised version for rc.conf, and rc.local is the localised additions to to rc.

With 4.9, OpenBSD introduced rcscripts rc.d the use of scripts stored in /etc/rc.d and are started by an entry in the /etc/rc.conf.local

rc_scripts="script1 script2 script3"

/etc/rc.conf - contains 'configuration' options for startup instructions in /etc/rc. To modify /etc/rc's behaviour, we create the 'localised' configuration file /etc/rc.conf.local and copy the flag you want to modify, and set the parameter changes.

The configuration options may include variable/feature assignments such as:

File: /etc/rc.conf


The preferred methodology is to copy rc.conf as your new rc.conf.local and delete the last two lines.

# cp /etc/rc.conf /etc/rc.conf.local

Lines to delete from /etc/rc.conf.local


[ -f ${local_rcconf} ] && . ${local_rcconf} # Do not edit this line

Make your configuration changes to rc.conf.local and it overrides the default settings in rc.conf.

For example: the apache web server is not started by default, but by adding a configuration entry into rc.conf.local, we tell OpenBSD to start the apache server, with specific options.

File: /etc/rc.conf


File: /etc/rc.conf.local


rc.local - is used to augment programs started in rc. For example when we install new programs like a database server, the rc does not know about these, and we can add the 'startup' process for that database into rc.local.


  • Changes you make in the /etc/rc.conf.local file will override settings in /etc/rc.conf.
  • Do not make changes to /etc/rc or /etc/rc.conf

Localised Configurations

To simplify my use of rc.conf.local, I look at it as a division of THREE separate sections.

  1. Section 1: Setting Programs that require Features turned on or off
  2. Section 2: Start/Stop Programs that do not need parameters
  3. Section 3: Configuring information for programs started above. Ignored if servers are not started.

File: /etc/rc.conf.local

# SECTION 1 - Turn Features on/off

# SECTION 2 - Switch Programs On/Off

# SECTION 3 - Configuration Options

shlib_dirs = ""

Section 1 - Turn Features On

This section is where you set parameters for programs that need to be started with different types of options.

For example, sendmail is usually started with different options depending on whether you wish to process queues only, or also set up smtp processing.

# SECTION 1 - Turn Features on/off
# ##
xdm_flags=""                # use two double-quotes
sendmail="-bd -q30m"        # for normal use: "-bd -q30m" 
ftpd_flags="-DllUSA"        # for non-inetd use: ftpd_flags="-D"

The above settings override the default /etc/rc.conf settings.

xdm_flags now specifies to start xdm (previously it was xdm=NO.) The sendmail directive now specifies the use of '-q30m' whereas the default specification is without '-bd'

The ftpd_flags are read by the start up scripts and specify parameters for the ftpd daemon.

Section 2 - Switch Programs On

This section is for programs that merely need to be turned on or off. For example this is a good place for programs that get their configuration information from configuration files and not from command-line arguments.

# SECTION 2 - Start/Stop Programs that do not require parameters
# ##

In the above modifications tells the variable assignments are relevant to updates I make to rc.local for to:

  • start: mysql services, but
  • do not start: Samba services (smbd, and nmbd.)

Section 3 - Configuration Options

In this section we specify directives for programs started in either Section 1 or Section 2. These directives will either be read when programs are activated or ignored when programs are not activated.

We can also place in here other directives that may be reviewed by the scripts in /etc/rc

# ##
shlib_dirs="$shlib_dirs /new/path1 /new/path2"

The above changes to shlibdirs expands the existing shlibdirs read from /etc/rc.conf ($shlibdirs) and adds two new paths to shlibdirs. Note that a space is used as the separator. You can also use multiple lines of shlib_dirs. Refer: rc.conf(8), ldconfig(8).

Because the script reading /etc/rc.conf{.local,} is Bourne Shell you can also use settings like shlib_dirs="/usr/local/lib/{path1,path2,path3,}

WARNING: There are no spaces between shlib_dirs, the "=" sign, and the first quote "