# Minimizing Writes



## clermontp (Feb 23, 2010)

got FreeBSD 8.0 installed on a soekris with a cf card. I would like to minimize filesystem writes and to an extent load read-only filesystems in order to maximize the longevity of the cf card. 

Anyone aware of work already done towards this? Any pointers on subjects/articles I should read in order to obtain the information required in this direction ?

thanks for any suggestion/comments.


----------



## oliverh (Feb 23, 2010)

If you have enough memory, using tmpfs would be an option. Mounting partitions with noatime would be another option.


----------



## richardpl (Feb 24, 2010)

Also using async and tweaking geom.


----------



## SirDice (Feb 24, 2010)

From the top of my head...

/ and /usr can be mounted read-only. Take care of /usr/home (use a seperate filesystem for it) and perhaps a few files in /etc (/etc/resolv.conf if you use DHCP i.e.). 

/var is a bit tricky but you may be able to stop everything that writes there. Syslogging to another server is also an option. 

/var/tmp, /var/run and /tmp can be tmpfs

For the most ideal situation I would probably use something similar to a live cd setup.


----------



## Carpetsmoker (Feb 24, 2010)

> /var/tmp, /var/run and /tmp can be tmpfs



/var/tmp and /tmp are not the same. /tmp/ is for truly temporarily data which may be lost any minute. /var/tmp/ however is for semi-temporarily data which may need to be saved in case of unexpected reboot or even a normal reboot.
An example would be the vi recovery files or PHP session data.

You can use tmpfs for /var/tmp if you absolutely must minimize writes, but even modern MLC drives can survive up to decades with normal usage ...

There are also some ports which may need write access to /usr/ by default, for example postgrsql or samba.


----------



## clermontp (Feb 24, 2010)

the only usage of the this system at the moment of this writing is firewall+gateway usage. No other function will appear in the near future. 

I believe that I will use tmpfs for /var/tmp if the only issue will be unrecovery vi sessions. Since there shouldn't be any of those and I will be the only user accessing the device.


----------



## aragon (Feb 25, 2010)

NanoBSD


----------



## jem (Feb 25, 2010)

There are a couple of FreeBSD startup scripts that deal with creating volatile /var and /tmp filesystems for diskless operation.  I've not really looked into them but they may be of use to you.

/etc/rc.d/var
/etc/rc.d/tmp


----------

