[lug] Tempfs

Jeff Schroeder jeff at neobox.net
Mon Jul 19 11:35:53 MDT 2004


Shannon asked:

> Has anybody had any experience using tempfs for the /tmp directory in
> linux? I know that Solaris uses it, but I haven't used it on linux
> before. Is there any advantage to it? Can it still be assigned
> options like no suid?

I've used tmpfs for some time.  I'm not sure what sparked me to use it 
(probably some article like the one you mentioned) but I've been very 
happy with it.

I actually mount /var/tmp as tmpfs, and then symlink /tmp to there.  
That way I cover *both* temporary areas with the same filesystem, and 
not worry about cruft building up if/when I need to reboot.  Also, I 
avoid runaway processes writing to /tmp and filling up a partition-- in 
the worst case, they'll fill up a chunk of RAM (I use 64MB, which seems 
to be plenty).

A quick Google search turns up this nice summary page:

http://www-106.ibm.com/developerworks/library/l-fs3.html

It mentions three nice things about tmpfs:

1) Dynamic filesystem size.  It only uses what it needs, so although I 
initialize it with a 64MB size, I'm typically only using less than 1MB 
of it.

2) Speed.  This is particularly useful for, say, compiling-- which 
writes a *lot* of files to /tmp during the compilation process.

3) Non-persistence.  Reboot, and the stuff in /tmp is gone.  No cruft.  
Of course, a good Linux system only needs to reboot a couple times a 
year anyway. ;)

All in all, I'd say tmpfs is a nice solution to a number of issues.  
Honestly, I started using it just because it sounded nifty, but then 
recognized that it has a number of advantages over a HDD-based /tmp 
area...

HTH,
Jeff



More information about the LUG mailing list