File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_use_tmpfs.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sun Feb 5 07:14:36 2012 UTC (2 years, 2 months ago) by schmonz
Branches: MAIN
CVS tags: HEAD
dos2unix

**Contents**

[[!toc]]

#  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)](http://netbsd.gw.com/cgi-bin/man-cgi?mount_tmpfs+8+NetBSD-current)


#  View source code (Please report any bugs or suggestions [here](http://www.netbsd.org/cgi-bin/sendpr.cgi?gndb=netbsd)). 


  * [mount_tmpfs.c](http://cvsweb.de.netbsd.org/cgi-bin/cvsweb.cgi/src/sbin/mount_tmpfs/mount_tmpfs.c?rev=HEAD)


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb