# Firewall running on Compact FLASH memory /var /tmp - Bind



## embeddedbob (Apr 8, 2010)

Ive got a firewall with PF, Bind, Dhcpd all running nicely on my new hardware but Id like to transfer this from the harddisk to Compact FLASH. My old router ran on CF too but without /var and I must admit to forgetting much of what I did 3 years ago... (much credit to FreeBSD  )

First step is for a read-only filesystem on the CF, so a varmfs and tmpmfs are required. 


```
varmfs_enable="YES"
varsize="128m"
varmfs_flags="-S -M" 

tmpmfs_enable="YES"
tmpsize="128m"
varmfs_flags="-S -M"
```

However Bind wownt run after becuase /etc/namedb/named.conf doesnt exist. As I created the file in /etc im unsure why this is? 

I also need to make sure theres a dhcpd.leases file.
touch /var/db/dhcpd.leases

Ive read that most people use 'populate_var="YES"' but Im unsure exactly what this does. Copy the modifications during runtime to CF on shutdown? 
populate_var="AUTO"     # Set to YES to always (re)populate /var, NO to never

Reading the rc.d documentation would something like this be going in the right direction?


```
#!/bin/sh

. /etc/rc.subr

name="popmfsvar"
start_cmd="${name}_start"
stop_cmd=":"

popmfsvar_start()
{
    tar -xf /cfg/varmfs.tar.gz -C /var
    # chmod permissions of files in memfs to set the same as on disk.
    echo "Populated varmfs from /var."
}

popmfsvar_stop()
{
    tar -cf /cfg/varmfs.tar.gz /var
    echo "Stored varmfs to /var."
}

load_rc_config $name
run_rc_command "$1"
```

The issue with this is that I need it to run first on startup and last on shutdown.

Anyway, whats the best way of accomplishing this? 

I presume if I only wanted to move files that are volatile, its just a case of keep running it until error messages stop appearing... :\


----------



## SirDice (Apr 8, 2010)

embeddedbob said:
			
		

> However Bind wownt run after becuase /etc/namedb/named.conf doesnt exist. As I created the file in /etc im unsure why this is?


If bind is chrooted this will actually be /var/named/etc/namedb/named.conf 



> Ive read that most people use 'populate_var="YES"' but Im unsure exactly what this does. Copy the modifications during runtime to CF on shutdown?
> populate_var="AUTO"     # Set to YES to always (re)populate /var, NO to never


It just creates the directory/file structure during boot.


----------



## aragon (Apr 8, 2010)

Have a look at NanoBSD.


----------

