[NetBSD logo]    &    [Google logo]

NetBSD-SoC: Efficient memory file-system

tmpfs was merged into the official NetBSD source tree on September 10th, 2005. Since then, the code has received multiple improvements and fixes which are only available in the official tree. The documentation written for this project was also finished and merged on January 28th, 2006. Please note that this page may be removed in the not-so-distant future.

What is it?

At the moment, NetBSD includes a memory-based file-system called mfs. mfs is is just an implementation of the regular ffs - designed for persistent storage - on top of the (volatile) virtual memory system. This means that it uses the same data structures as the on-disk implementation, rendering less than optimal performance and memory usage.

The NetBSD operating system is in a need of an efficient memory file-system that uses its own data structures to manage the stored files. The main design goal is to make it use the correct amount of memory to work correctly and efficiently; no more, no less.

The visible goals of the project will be:

You might want to read the original proposal for some more information.


Check out all posts in my blog that begin with the "SoC:" string for information about the process in the project's development.

You may want to subscribe to the RSS or Atom feeds for convenience.


This project provides a file-system driver for the kernel. In order to use it, the kernel must be patched to recognize the new code, and the files providing it must be copied in place. This is a tedious task to be done by hand, so a simple script, setup.sh is provided; it will take care to configure your existing NetBSD source tree to accept tmpfs.

In other words, follow these steps:

  1. Fetch a copy of the tmpfs module from the Sourceforge site. See the main NetBSD-SoC's page for instructions.
  2. After a successful fetch, set the NETBSDSRCDIR environmental variable to the path of your NetBSD source tree. If it is under /usr/src, you don't need to do this.
  3. Run the setup.sh script located in the tmpfs directory. Note that you must have write access to the kernel source tree for this to work.
  4. Add file-system TMPFS to your kernel configuration file.
  5. Rebuild and install your new kernel.
  6. Go to ${NETBSDSRCDIR}/sbin/mount_tmpfs and run make USETOOLS=NO dependall install to get the new mount_tmpfs(8) built and utility installed. Of course, you can use a prebuilt toolchain; USETOOLS=NO is given here for simplicity.
  7. Mount the file system: mkdir /tmp/test; mount -t tmpfs tmpfs /tmp/test and enjoy!

Existing related documentation:

Also, you may want to check all the steps I'm following to develop tmpfs. The list is very compact and maybe not self-explanatory; these are just notes that I will use to write the "file-system how-to".

At last, in case you want to verify the stability of the file-system, you can to run the regression tests provided with it. First of all, you have to be the super-user in order to do them; when you are, simply go to ${NETBSDSRCDIR}/regress/sys/fs/tmpfs/ and execute make regress within it. Even though, some of the tests want to run some commands as an unprivileged user; if you want these parts to be executed, you must tell the scripts which user to use. Assumming the user is named foo, do this instead: make regress TEST_ARGS=-ufoo. Furthermore, if you want the tests to be really verbose, pass the -v2 flag to them. Note that this can take a while depening on your CPU speed and can crash the system.

Technical Details

The following existing interfaces and subsystems are used by tmpfs. The list shows interesting manual pages and files specific to them:

SourceForge.net Logo
Julio M. Merino Vidal <jmmv84@gmail.com>
$Id: index.html,v 1.14 2006/02/24 20:06:25 jmmv Exp $