The post-boot initialization of an embedded FreeBSD system is controlled by /etc/rc.initdiskless.
/etc/rc.d/var mounts /var as a memory filesystem, makes a configurable list of directories in /var with the mkdir(1) command, and changes modes on some of those directories. In the execution of /etc/rc.d/var, one other rc.conf variable comes into play – varsize. The /etc/rc.d/var file creates a /var partition based on the value of this variable in rc.conf:
varsize=8192
Remember that this value is in sectors by default.
The fact that /var is a read-write filesystem is an important distinction, as the / partition (and any other partitions you may have on your flash media) should be mounted read-only. Remember that in Section 1 we detailed the limitations of flash memory - specifically the limited write capability. The importance of not mounting filesystems on flash media read-write, and the importance of not using a swap file, cannot be overstated. A swap file on a busy system can burn through a piece of flash media in less than one year. Heavy logging or temporary file creation and destruction can do the same. Therefore, in addition to removing the swap entry from your /etc/fstab file, you should also change the Options field for each filesystem to ro as follows:
# Device Mountpoint FStype Options Dump Pass# /dev/ad0s1a / ufs ro 1 1
A few applications in the average system will immediately begin to fail as a result of this change. For instance, cron will not run properly as a result of missing cron tabs in the /var created by /etc/rc.d/var, and syslog and dhcp will encounter problems as well as a result of the read-only filesystem and missing items in the /var that /etc/rc.d/var has created. These are only temporary problems though, and are addressed, along with solutions to the execution of other common software packages in Section 5.
An important thing to remember is that a filesystem that was mounted read-only with /etc/fstab can be made read-write at any time by issuing the command:
# /sbin/mount -uw partition
and can be toggled back to read-only with the command:
# /sbin/mount -ur partition