[Wylug-discuss] Re: Using tmpfs on /dev/shm

Neil Pilgrim kepier at clara.co.uk
Wed Jun 2 20:08:27 BST 2004


Not sure if this will get to the list, since the wylug server doesn't like
me for some reason...

Dave Fisher writes:
> On Wed, Jun 02, 2004 at 07:45:44AM +0100, gARetH baBB wrote:
>> On Tue, 1 Jun 2004, Dave Fisher wrote:

>> > If the superficial view is accurate, what do I need to to to get the
>> > kernel/apps to use it?
>>
>> Erm, it's just a filing system like any other file system - if you point
>> things to use it they will use it.
>
> Sorry to be so dim, but if "it's _just_ a filing system" why does my
> system automatically mount it and allocate so much memory to it?

AFAIK, if you don't use it then the overhead is quite small. For one thing,
the memory for it comes from the VM, so you could consider that the unused
space resides in your (presumably sizable) swap. The other thing to note is
that programs can request more memory than is currently available -so I do
not see why it should be any different for tmpfs. Only when you have files
in the tmpfs directory will ram/swap be used. I assume that if those files
aren't used much, then they'll get swapped-out too, much like any other
process that isn't very active.

Tmpfs is basically the new preferred method for getting ram-disk behaviour
in Linux. One typical application is to use it for /tmp, which is what I
currently do. If you are concerned about your /tmp (or whatever) getting too
large, then you can set a 'size' option when you mount it (or in
/etc/fstab). In my current system I appear to have one in /dev/shm and the
one I set up previously over /tmp, of which only the latter is used. I'm not
sure what the former is used for, if anything, but I read an article on
developerworks which talked about binding (a new mount option?) a
subdirectory of the 'standard' mounted /dev/shm to /tmp, so perhaps I should
be doing that...or maybe Debian should be doing it for me. Either way, I
don't believe it takes (much) memory when there are no files there, so I'm
not too bothered anyhow.

> I don't remember ever typing the settings which appeared in my fstab
> (that's not to say that I didn't carelessly check some install/config
> option at some time in the past).

Is this Debian? Certainly I got the /dev/shm entry (cf the /tmp one) when I
upgraded at some point, so this could be from that...or perhaps its not
Debian ;)

> My, probably incorrect, understanding is that tmpfs can use both HDD and
> RAM memory and that problems can occur when you allocate more memory to
> it than you have free memory available.

Yes, so use the size option when you mount it, if you are paranoid about
that :)

> How do I find out which type of memory it is using, and set how much it
> uses of either type?

See above...doh...

> What little documentation I can find is pretty fragmented ... to say the
> least.

The developerworks article seems quite good; I don't have it to hand right
now, but it seemed sufficiently informative to me. OTOH, I'm not exactly
clear quite how tmpfs relates to Posix shared memory, ie. whether the latter
uses any tmpfs mounts you make, or what.

Hope this clarifies things,

--
Neil





More information about the Wylug-discuss mailing list