Subject: Re: Read only filesystem support from FreeBSD
To: tech-embed@NetBSD.org <tech-embed@NetBSD.org>
From: Adam Hoka <adam.hoka@gmail.com>
List: tech-embed
Date: 06/13/2007 19:42:33
On Tue, 12 Jun 2007 19:26:51 +0200
Adam Hoka <adam.hoka@gmail.com> wrote:

> Someone mentioned on the list earlier the out of the box support of read only filesystems, like FreeBSD has.
> I have ported it to NetBSD. I don`t think it`s perfect, but it`s working for me.
> 
> Please test it and tell me what do you think about it. I don`t know if I left some FreeBSD-isms in them. :)
> The rc.d files and the patch needed for /etc/defaults/rc.conf are here:
> http://freeshells.ch/~replaced/ro_boot.tar
> 
> If you are not familiar with this ability of FreeBSD, here`s a short explanation, from the FreeBSD manpage:
> 
>      tmpmfs      Controls the creation of a /tmp memory file system.  Always
>                  happens if set to ``YES'' and never happens if set to ``NO''.
>                  If set to anything else, a memory file system is created if
>                  /tmp is not writable.
> 
>      tmpsize     Controls the size of a created /tmp memory file system.
> 
>      tmpmfs_flags
>                  Extra options passed to the mdmfs(8) utility when the memory
>                  file system for /tmp is created.  The default is ``-S -M'',
>                  which inhibits the use of softupdates on /tmp to waste as
>                  little space as possible and creates a pure memory backed
>                  disk, which will never be swapped out, for maximum perfor-
>                  mance and system stability at low memory conditions.  See
>                  mdmfs(8) for other options you can use in tmpmfs_flags.
> 
>      varmfs      Controls the creation of a /var memory file system.  Always
>                  happens if set to ``YES'' and never happens if set to ``NO''.
>                  If set to anything else, a memory file system is created if
>                  /var is not writable.
> 
>      varsize     Controls the size of a created /var memory file system.
> 
>      varmfs_flags
>                  Extra options passed to the mdmfs(8) utility when the memory
>                  file system for /var is created.  The default is ``-S -M'',
>                  which inhibits the use of softupdates on /var to waste as
>                  little space as possible and creates a pure memory backed
>                  disk, which will never be swapped out, for maximum perfor-
>                  mance and system stability at low memory conditions.  See
>                  mdmfs(8) for other options you can use in varmfs_flags.
> 
>      populate_var
>                  Controls the automatic population of the /var file system.
>                  Always happens if set to ``YES'' and never happens if set to
>                  ``NO''.  If set to anything else, a memory file system is
>                  created if /var is not writable.  Note that this process
>                  requires access to certain commands in /usr before /usr is
>                  mounted on normal systems.
> 
> It`s mounting a ramdisk device, and populating /var using mtree(8).
> The only major change, that it`s using mount_tmpfs(8), so the flags are empty by default, but I want to add support for mount_mfs(8).
> 
> Cheers! :)
> 
> -- 
> Adam

Ok, here`s the updated version, with support of mfs, which is the default now to be able to work on older releases out of the box.
But the fallback value is tmpfs if it`s not set properly. I don`t know which one should be the default. What do you think?
You can use tmpmfs_type and varmfs_type in rc.conf to set it to tmpfs or mfs.

Please test and report any problems or success, so I can fill a change request if it`s ok. :)

Here`s the tarball:
http://freeshells.ch/~replaced/ro_boot_2.tgz

-- 
Adam