nanobsd, saving files in /etc/local?

I'm working on setting up my first FreeBSD router. I'm using an alix 2D13 board with FreeBSD 9.0. I've built a nice little nanobsd image with a custom kernel and all that. Now I'm onto the configuration aspect of things. One thing I'm configuring is dnsmasq for DHCP and DNS resolution. By default dnsmasq keeps its configuration in /etc/local/dnsmasq.conf. I can't for the life of me figure out how to get "save_cfg" to save this file into /cfg. Is there some basic trick I'm missing? Surely this should work...right? This is what I'm seeing:

Code:
alix# sh save_cfg local/dnsmasq.conf
find: *: No such file or directory
cp: /cfg/local/dnsmasq.conf: No such file or directory

I've also tried it with just the name:
Code:
alix# sh save_cfg dnsmasq.conf
find: *: No such file or directory
cp: /etc/dnsmasq.conf: No such file or directory

Based on this it looks like "save_cfg" automatically adds "/etc" to the front of the names. So, technically, "local/dnsmasq.conf" should work, the file does exist:

Code:
alix# ls -l /etc/local/dnsmasq.conf
-r--r--r--  1 root  wheel  2777 Mar  8 05:21 /etc/local/dnsmasq.conf

Any hints?
 
adam2104 said:
By default dnsmasq keeps its configuration in /etc/local/dnsmasq.conf. I can't for the life of me figure out how to get "save_cfg" to save this file into /cfg.
All ports use /usr/local/etc/, not /etc/.
 
The port installs the sample config to /usr/local/etc/dnsmasq.conf.example.
 
Yes, I know, I've found it, that isn't my question. I've created my own dnsmasq.conf and now its sitting there, configured. However, with nanobsd's read-only file system the changes will be lost if I reboot the system. There is a script with nanobsd, save_cfg, that is used to sync files from /etc to the /cfg partition that is read on bootup. However, the script doesn't appear to be able to handle anything outside of the /etc base directory. Anything deeper doesn't seem to sync, and that is my question. Am I missing something on how to sync something deep that /etc with save_cfg?
 
I think I'm actually missing something :e

Never played with NanoBSD before, that's probably where my confusion comes from.

Is /usr/local/etc/ symlinked to /etc/local/?

What happens if you try
# save_cfg /usr/local/etc/dnsmasq.conf
 
adam2104: As far as I can guess, when nanobsd boots, it copies everything from /cfg to /etc. So you may see /etc/local/dnsmasq.conf after you booted. However, for permanent configuration change, the file needs to be appended to /cfg. I guess there lies this confusion, but not sure. ;-)

It was true until FreeBSD 8.3, with FreeBSD 9, I cannot say because I am finding difficulty even to compile a nanobsd image (http://forums.freebsd.org/showthread.php?t=30331) :-(
 
SirDice said:
I think I'm actually missing something :e

Never played with NanoBSD before, that's probably where my confusion comes from.

Is /usr/local/etc/ symlinked to /etc/local/?

What happens if you try
# save_cfg /usr/local/etc/dnsmasq.conf

Exactly, /usr/local/etc/ is symlinked to /etc/local/. I tried the command you suggest, but it does this:

# save_cfg /etc//usr/local/etc/dnsmasq.conf

Which isn't quite right. I've done some more digging and it looks like save_cfg doesn't recurse into any directories, so if I want to save that file I need to just use /etc/dnsmasq.conf, manually copy it to /cfg, or embed it directly in my nanobsd image.
 
adam2104 said:
so if I want to save that file I need to just use /etc/dnsmasq.conf, manually copy it to /cfg, or embed it directly in my nanobsd image.

That is exactly what I stated in my previous post. Whatever changes one makes in nanobsd, it should be appended to /cfg to make it permanent, because /etc is memory device which gets appended from /cfg when booting.
 
Ok, did I understood correctly the contents of /cfg/ gets copied to /etc/ when NanoBSD boots?

If that's the case just save the file in /cfg/local/. Then it'll probably get copied to the correct place.

The reason save_cfg might be failing is because /cfg/local/ doesn't exist.
 
Also, the /cfg should be mounted in rw (read-write) mode before trying to append. /cfg/local may be there already, but it is only in ro (read-only) mode.
 
Back
Top