# all in rc.conf or /etc files?



## fluca1978 (Feb 8, 2013)

Hi,
just a curiosity: what is the rationale behind the choice of FreeBSD to have all services, interfaces, and stuff configured via /etc/rc.conf while other BSDs, such as OpenBSD, choose to have a file for interface (as in other commercial Unixes like Solaris too)?


----------



## kpa (Feb 8, 2013)

http://en.wikipedia.org/wiki/Hysterical_raisins


----------



## SirDice (Feb 8, 2013)

I prefer the FreeBSD way were everything is in one file, instead of several.


----------



## kpa (Feb 8, 2013)

There's one reasonable way to split the rc.conf(5) settings to multiple files and that is to use /etc/rc.conf for base system settings and /etc/rc.conf.local for settings that apply to ports/packages only.


----------



## SirDice (Feb 8, 2013)

kpa said:
			
		

> There's one reasonable way to split the rc.conf(5) settings to multiple files and that is to use /etc/rc.conf for base system settings and /etc/rc.conf.local for settings that apply to ports/packages only.



/usr/local/etc/rc.conf would probably be a better place


----------



## kpa (Feb 8, 2013)

Yes, that would be even better place. However, the rc_conf_files  variable is set like this in /etc/defaults/rc.conf:


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

If you want utitilies like service(8) to be aware of any additional rc.conf(5) files you'll have to modify that.


----------



## SirDice (Feb 8, 2013)

True. Wouldn't adding this to /etc/rc.conf work too?

Somewhere at the end:

```
. /usr/local/etc/rc.conf
```


----------



## kpa (Feb 8, 2013)

That works. Allthough you want to test if the file is readable first.


```
[ -r /usr/local/etc/rc.conf ] && . /usr/local/etc/rc.conf
```

Edit: Does not work actually, the code does not get evaluated at boot up.


----------



## AlexJ (Feb 10, 2013)

fluca1978 said:
			
		

> Hi,
> just a curiosity: what is the rationale behind the choice of FreeBSD to have all services, interfaces, and stuff configured via /etc/rc.conf .... ?



rc.conf(5)

`# mkdir /etc/rc.conf.d`

Place then service's configuration to a separate file(s) in the directory /etc/rc.conf.d to a file with name equal to the service's name.

So, for _Apache_ it would be /etc/rc.conf.d/apache22
for _MySQL_ it would be /etc/rc.conf.d/mysql-server and so on...

No mess, all configuration that related to particular service stay in separate configuration file.

By the way, if you create /etc/rc.conf.d/jail you can keep there separate configuration for jail(s) too.


----------



## throAU (Feb 12, 2013)

All rc.conf is, is a file defining a bunch of shell variables, personally I like that they're all in the one place.


----------



## Markand (Feb 12, 2013)

I personally love my system configuration in rc.conf. On Gentoo I needed to edit a lot of files in /etc/conf.d/*. almost of these files only have two or less variables.


----------



## drhowarddrfine (Feb 12, 2013)

@kpa has the answer in his first post. The scientists who created Unix did it that way and FreeBSD is a direct descendant of Unix. Now, why they did that, iirc, might have had something to do with the limited size of disks back then. Having everything in one location makes it easier to find things, too, rather than having them scattered all about as Linux does (from what I hear).


----------



## BlueCoder (Feb 18, 2013)

The rational is that rc.conf does not force you to use a single file. Although it is primarily used for variables it is actually a script in and of itself invoked from /etc/rc or scripts in /etc/rc.d/. So your free to separate files as you see fit in rc.conf. 

It follows the core of the Unix principle of keeping it simple. It is up to a system administrator to create more complicated systems if they so wish.

Case in point I sometimes separate files on desktop system but in jails since they only run a couple daemons their rc.conf is so short I don't bother. Only consequence is ordering the files and not using the same setting in more than one file which on a couple occasions which wasted a tiny bit of time tracking down. But then again you can the exact same problem with very large files.

Freebsd gives you the choice, it's up to you.


----------



## phoenix (Feb 19, 2013)

kpa said:
			
		

> There's one reasonable way to split the rc.conf(5) settings to multiple files and that is to use /etc/rc.conf for base system settings and /etc/rc.conf.local for settings that apply to ports/packages only.



If you have multiple systems that are virtually identical (for example, firewalls), then it's better to use /etc/rc.conf for settings that are common across them all, and /etc/rc.conf.local for settings that are specific to that one system (like hostname, ifconfig, etc).


----------

