MFS file systems are nice and fast but they do not retain their data through a system reboot. For this reason we will save all files from a few of these directories on a special directory that we will create: /mfs/var.log. So type mkdir p /mfs/var.log to create this directory.
Upon system shutdown we will copy all files from the /var/log directory to the /mfs/var.log directory. This can be automated from the /etc/rc.shutdown file.
When the system boots we will fill the /var/log directory from the /mfs/var.log directory by adding a line to the /etc/rc file using rsync. Type the following lines to create an initial copy of the /var/log directory. The first line merely gets rid of any compressed log files that might have been created since you installed OpenBSD:
rm /var/log/*.gz
/usr/local/bin/rsync -vorpug /var/log/ /mfs/var.log
and add the following to the /etc/rc file just after the "mount /var >/dev/null 2>&1" line:
# Fill /var/log directory
printf "copying files to mfs "
/usr/local/bin/rsync orpug /mfs/var.log/ /var/log
echo " done."
and reboot the machine. After a reboot the contents of the /var/log directory are located in memory.
Now we want to synchronize the content of the /var/log directory when we reboot our machine in the future. Append the following lines to/etc/rc.shutdown
# Save /var/log directory
printf "Copying /var/log to CF "
# ReMount / read-write now
mount uw /dev/wd0a /
/usr/local/bin/rsync orpug --delete /var/log/ /mfs/var.log
echo " done."
and reboot the machine one more time to see it in action. The "mount uw " line is necessary since we are going to mount the root file system read-only later.