how to disable tmpfs

Chris Adams linux at cmadams.net
Fri Aug 8 17:39:39 UTC 2014


Once upon a time, Dennis Kaptain <dennis.kaptain at gmail.com> said:
> It still doesn't seem like an ideal way to handle /tmp when I have a
> perfectly good partition and swapping is a major performance killer.
> I'd rather disk access wait time is caused by accessing /tmp when I
> need to rather than swapping tmpfs in and out for a program.

Swapping tmpfs files to swap is no more of a performance killer than
writing /tmp to disk to begin with (the same data would be written to
the same disk, just in a little bit different format and location).

When a program writes data to disk, it goes through the kernel page
cache, to the filesystem layer, to the block layer, and then to disk.
The filesystem has to allocate space (which means other writes to disk,
updating block allocations, directories, etc.).  The blocks are cached
in the page cache in case they are read later.  If the kernel needs RAM,
it can throw them away.

tmpfs lives directly in the page cache.  So, when a program writes to a
tmpfs file, it goes to the page cache and stops.  Later, if the kernel
needs RAM, it can push those pages to disk (swap space).

The only difference between /tmp on disk and tmpfs is when pages get
pushed to disk.  In a system with sufficient RAM to hold the normal /tmp
contents (which aren't very big under most circumstances), they never
get pushed to disk with tmpfs, and performance is faster.

The only downside to /tmp-on-tmpfs is that it is limited in size, based
on available RAM.  Ideally, it would be based on swap size, or total
RAM+swap, but that's harder to do.  However, Fedora defaults to a root
filesystem that isn't huge (with a separate /home), so the size of /tmp
is still limited.  /tmp was never supposed to be about holding arbitrary
sized chunks of data.

-- 
Chris Adams <linux at cmadams.net>


More information about the users mailing list