File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_use_tmpfs.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Sun Nov 20 20:55:21 2011 UTC (6 years, 3 months ago) by mspo
Branches: MAIN
CVS tags: HEAD
import all of the how-to articles from the wiki



#  What is tmpfs ? 

tmpfs is an efficient memory file system written by Julio M. Merino Vidal during the Summer of Code Project in 2005. It was merged into the NetBSD tree on the 10th of September 2005. Tmpfs left experimental status on 11/11/2006 and is now enabled by default in all GENERIC kernels. 

#  How does it work ? 

In the contrary to mfs, tmpfs uses its own data structures to manage the stored files. It uses the correct amount of memory to work correctly and efficiently, which means it grows and shrinks. 

#  Why do I need it ? 

Normally you don't. You can work with your hard disk. But you can use it to reduce hard disk activity, if you store temporary data to tmpfs, which is faster aswell. I personally prefer tmpfs for `/tmp` and use it on all my servers. 

#  How do I use it ? 

Before you can use tmpfs, you have to rebuild your Kernel. To enable TMPFS please ensure that the line 
    file-system TMPFS 

is available and uncommented in your Kernel config file. Now, rebuild your Kernel and reboot. 

#  Testing tmpfs 

Before we change the file `/etc/fstab`, we have to ensure, that tmpfs is working. Otherwise your server won't be able to boot. To test if tmpfs is working, mount it manually with: 
    # mount_tmpfs tmpfs /tmp

and check, if it is mounted: 
    # mount
    tmpfs on /tmp type tmpfs (local)

#  Editing fstab 

You can now edit your `/etc/fstab` to mount it automatically everytime you boot. Please add exactly this line to your `/etc/fstab`: 
    tmpfs /tmp tmpfs rw 

You're done. Have fun. 

#  Caveats 

Unfortunately tmpfs doesn't support whiteouts yet. That's why it can't be used with union_mount's. 

#  See also 

  * [mount_tmpfs(8)](

#  View source code (Please report any bugs or suggestions [here]( 

  * [mount_tmpfs.c](

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb