FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Development

 
 
LinkBack Thread Tools
 
Old 05-24-2012, 11:22 PM
Serge
 
Default Moving /tmp to tmpfs makes it useless

I've read across different debates about whether using tmpfs is good or bad
but I could not find the most important reason, so here it is...

Reason
======
What's a temporary file? Really, why would applications temporarily store
its data in a file? They do that to *free some memory*. Placing those files
back to memory renders the whole process of writing the file useless.
If the files are small and can stay in memory why would application save it
to file?

Moving /tmp to tmpfs is effectively the same as suggesting to delete /tmp,
because there's no use for it as a temporary files storage any more.


FHS
===
Filesystem Hierarchy Standard defines two directories for temporary files:
/var/tmp — for files that should be preserved between reboots
/tmp — for files that should not be preserved between reboots
It's simple and clear.
Since it's only reasonable to store large data sets in temporary files,
standard sets no size limits for these files. So if application's author
had actually read FHS he should expect these directories to handle
large files.


Who uses /tmp
=============
Let's check the real world and see what applications actually use /tmp.
When you copy files in `mc` they're copied over /tmp/mc-username (to
handle some complex cases, like copying from inside iso-image to ssh).
When you click on a file in Firefox and select "Open with", Firefox stores
that file in /tmp. You cannot assume these files to be small. When you
watch large videos, adobe flash stores downloaded part of it as something
like /tmp/FlashXXG49VWF. Archive managers may unpack archives to /tmp.
CD burners store iso-files there. Image processing software was already
mentioned in this list.

All these files may be large, but should not be preserved on reboot, so
according to FHS they should go to /tmp.

And the most important thing: file managers, browsers, image editors,
cd burners — these are not some rare scientific stuff, but a common
programs, that most people use every day. Putting them on a small tmpfs
will break them. Putting them on large tmpfs may slow down or freeze
the system due to heavy swapping.


Suggestion
==========
Do not mount /tmp as tmpfs by default. Instead...
Debian already allows custom partitioning during the system install. For
example it's possible to mount /tmp on a separate partition. The suggestion
is to extend partitioner with a new option "Configure tmpfs partitions".
That option should allow to mount anything as tmpfs (not just /tmp, but
also /var/run, /media, /opt or whatever the user might want). It would be
nice to have the `size` option there as well.

In that case most users won't get new problems. But really smart people,
that really know what they're doing, will be able to put /tmp on tmpfs
with the options they need.


PS: To save some discussion time I'll try to answer the most common
questions I've seen:

Q: I extremely care about my / fs and want to use it as rarely as possible.
A: There're a lot of options:
* symlink or mount-bind /tmp to i.e. /home/tmp
* have /tmp on a separate partition (common and probably best solution)
* you hate partitions? make /home/tmp_ext3fs.img and loop-mount it.
That would solve your problem without making your system unstable because
of high memory usage, or break programs because of no free space in /tmp.

Q: /tmp on tmpfs increases apps performance.
A: What apps? Real apps don't write files during performance-critical
operations. Even if they do, they write large files. And large files are
written faster when they're written on real disk, rather then swapped
out and slow down the entire system (see the "Who uses /tmp" part).
The apps that can really benefit from tmpfs are too rare. And we're
talking about default settings and most common cases.

Q: gcc writes small files in /tmp
A: usually it does not, especially when used with -pipe option

Q: Solaris uses /tmp in tmpfs for years.
A: Yes. And Linux uses it on extfs for years.
And, BTW, Linux's faster than Solaris: http://www.tux.org/lkml/#s9-12
Solaris had no such a fast extfs, so it had to use tmpfs instead.

Q: But still solaris uses /tmp in tmpfs and has no problems
A: That's not true. Solaris users/admins actually have problems because
of the whole swap space being exhausted by a few iso-files in /tmp.
The matter is that /tmp is being tmpfs under Solaris for so long that
solaris admins are used to look for free space in /tmp and fix the
problems, that linux users never had.
I don't want to get used to problems, do you?

Q: I'm a smart man, I know what I'm doing, what apps I'm breaking and what
consequences my decision might have, but I still need my /tmp in tmpfs.
A: Then you should do that. In those rare cases when defaults need to be
changed they should be changed.

That's it. Thanks for reading.

PS: should I had filled this as a bugreport?

--
Serge


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CAOVenEo+CT6Ou_vHq8HvuCz1NdW0Ogq5UqxMZh-4Qkw4e01CsA@mail.gmail.com">http://lists.debian.org/CAOVenEo+CT6Ou_vHq8HvuCz1NdW0Ogq5UqxMZh-4Qkw4e01CsA@mail.gmail.com
 
Old 05-24-2012, 11:54 PM
Russ Allbery
 
Default Moving /tmp to tmpfs makes it useless

Serge <sergemdev@gmail.com> writes:

> What's a temporary file? Really, why would applications temporarily
> store its data in a file? They do that to *free some memory*. Placing
> those files back to memory renders the whole process of writing the file
> useless. If the files are small and can stay in memory why would
> application save it to file?

Every file that exists in /tmp on the system from which I'm writing this
exists there not because the application is saving memory but because the
application needs to share that file with other applications. That
includes a bunch of Kerberos ticket caches, several X server IPC
rendezvous points, gnupg-agent and ssh-agent data, and a bunch of UNIX
domain sockets for ORBit.

Other common examples are mail clients or web browsers saving files
temporarily so that they can pass them to external viewers.

Putting /tmp in tmpfs provides some mild benefits for file-based Kerberos
ticket caches since they're automatically wiped on reboot. (Using a more
sophisticated cache such as keyrings has even nicer benefits, but aren't
fully supported by all applications yet.)

--
Russ Allbery (rra@debian.org) <http://www.eyrie.org/~eagle/>


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 8762blp228.fsf@windlord.stanford.edu">http://lists.debian.org/8762blp228.fsf@windlord.stanford.edu
 
Old 05-25-2012, 12:30 AM
Jakub Wilk
 
Default Moving /tmp to tmpfs makes it useless

Q: I'm a smart man, I know what I'm doing, what apps I'm breaking and
what consequences my decision might have, but I still need my /tmp in
tmpfs.
A: Then you should do that. In those rare cases when defaults need to
be changed they should be changed.


ACK. /tmp on tmpfs is a nice hack (I use it myself!), but it's a
terrible default.


--
Jakub Wilk


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120525003051.GA1497@jwilk.net">http://lists.debian.org/20120525003051.GA1497@jwilk.net
 
Old 05-25-2012, 12:39 AM
Fernando Lemos
 
Default Moving /tmp to tmpfs makes it useless

On Thu, May 24, 2012 at 9:30 PM, Jakub Wilk <jwilk@debian.org> wrote:
>> Q: I'm a smart man, I know what I'm doing, what apps I'm breaking and what
>> consequences my decision might have, but I still need my /tmp in tmpfs.
>> A: Then you should do that. In those rare cases when defaults need to be
>> changed they should be changed.
>
>
> ACK. /tmp on tmpfs is a nice hack (I use it myself!), but it's a terrible
> default.

Hasn't this been discussed at length already in previous threads? I'm
all for discussion and even revisiting topics to some extent, but it
doesn't seem healthy that we come back to a dead discussion, raising
the same topics again, over and over, not taking into account what has
already been said about it, not doing proper research beforehand, not
taking into account constraints such as the looming freeze...

Regards,


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CANVYNa-kuH89XAxDYckLUXk1qObSypXib1L2_CENjZka0dcsQg@mail.g mail.com">http://lists.debian.org/CANVYNa-kuH89XAxDYckLUXk1qObSypXib1L2_CENjZka0dcsQg@mail.g mail.com
 
Old 05-25-2012, 12:57 AM
Serge
 
Default Moving /tmp to tmpfs makes it useless

2012/5/25 Russ Allbery wrote:

> Every file that exists in /tmp on the system from which I'm writing this
> exists there not because the application is saving memory but because the
> application needs to share that file with other applications. That
> includes a bunch of Kerberos ticket caches, several X server IPC
> rendezvous points, gnupg-agent and ssh-agent data, and a bunch of UNIX
> domain sockets for ORBit.

I agree, not everybody read FHS, some software may have bugs.

According to FHS these should go to /var/run (or /run, if you like).
I mean, if you want to fix this, you should move those files to /run,
you should not turn /tmp into /run because of them.

But even as it is - it's not a big problem. Those files are small, they
almost never change, cause no disk writes, no performance issues, and
having them on disk adds no problems for users.

> Other common examples are mail clients or web browsers saving files
> temporarily so that they can pass them to external viewers.

Those files can be large, especially those opened from browsers (I've seen
a lot of users watching movies and opening archives that way). So these
files should be really stored on disk.

> Putting /tmp in tmpfs provides some mild benefits for file-based Kerberos
> ticket caches since they're automatically wiped on reboot. (Using a more
> sophisticated cache such as keyrings has even nicer benefits, but aren't
> fully supported by all applications yet.)

One more reason to move those files to /run.

--
Serge


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CAOVenEpD7iBp5icT29Z=nKDhvcBGFeDBAUjWOkYVdq7xQ39fk w@mail.gmail.com">http://lists.debian.org/CAOVenEpD7iBp5icT29Z=nKDhvcBGFeDBAUjWOkYVdq7xQ39fk w@mail.gmail.com
 
Old 05-25-2012, 01:09 AM
Michael Biebl
 
Default Moving /tmp to tmpfs makes it useless

On 25.05.2012 01:22, Serge wrote:
>
> PS: should I had filled this as a bugreport?
>

No need to, there is already
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630615

--
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?
 
Old 05-25-2012, 01:25 AM
Miles Bader
 
Default Moving /tmp to tmpfs makes it useless

Jakub Wilk <jwilk@debian.org> writes:
> ACK. /tmp on tmpfs is a nice hack (I use it myself!), but it's a
> terrible default.

I can't say whether it's a good default or not (though it seems to
work pretty well in practice), but the OP's argument is completely
silly. Most apps use /tmp not for "reducing memory usage", but for
communicating with other apps (of course, often, such as in a shell
script, or indeed the user himself, the choice of /tmp is not done by
the app itself, but by the invoker) -- it's a common namespace.

Of course it's the rare exceptions to this that cause problems;
whether there are enough such exceptions to make the default a bad
idea, I dunno. [apparently my /tmp got switched over to tmpfs by some
automatic upgrade, and it took me _months_ to even notice...]

-miles

--
Mayonnaise, n. One of the sauces that serve the French in place of a state
religion.


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87pq9tdpbl.fsf@catnip.gol.com">http://lists.debian.org/87pq9tdpbl.fsf@catnip.gol.com
 
Old 05-25-2012, 01:34 AM
Serge
 
Default Moving /tmp to tmpfs makes it useless

2012/5/25 Fernando Lemos wrote:

> Hasn't this been discussed at length already in previous threads?

Well, I brought that up because I hadn't seen the main argument about
temporary files discussed yet. I hope that it may change things to the
better way.

But that's not just for more talking, it's also a new suggestion:
0. remember why temporary files are created;
1. don't mount /tmp on tmpfs by default;
2. extend installer so that it allowed to configure all tmpfs mountpoints
in custom install mode (all of them, including /tmp as an option);
3. [optionally] fix the software, that misuse /tmp by moving their files
to appropriate directories (i.e. /run).

Alternatively, if everybody still believe that /tmp must be always mounted
to tmpfs - I suggest to make the second step and do not create /tmp at all
by default, since it's useless for real temporary files and is not a good
place for IPC/sockets anyway.

If these ideas were already suggested and discussed before, I'm sorry,
I guess I missed them.

--
Serge


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CAOVenEqAcbH1GgLSadE1OynYY3Cb_14H0ieKVwT-u3K7LHUP7w@mail.gmail.com">http://lists.debian.org/CAOVenEqAcbH1GgLSadE1OynYY3Cb_14H0ieKVwT-u3K7LHUP7w@mail.gmail.com
 
Old 05-25-2012, 02:00 AM
Steve Langasek
 
Default Moving /tmp to tmpfs makes it useless

On Fri, May 25, 2012 at 03:57:28AM +0300, Serge wrote:
> > Every file that exists in /tmp on the system from which I'm writing this
> > exists there not because the application is saving memory but because the
> > application needs to share that file with other applications. That
> > includes a bunch of Kerberos ticket caches, several X server IPC
> > rendezvous points, gnupg-agent and ssh-agent data, and a bunch of UNIX
> > domain sockets for ORBit.

> I agree, not everybody read FHS, some software may have bugs.

> According to FHS these should go to /var/run (or /run, if you like).
> I mean, if you want to fix this, you should move those files to /run,
> you should not turn /tmp into /run because of them.

Absolutely not. /run is a root-only directory, suitable only for
system-wide data/sockets. It absolutely must not be used for non-root data.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
slangasek@ubuntu.com vorlon@debian.org
 
Old 05-25-2012, 02:31 AM
Joey Hess
 
Default Moving /tmp to tmpfs makes it useless

Steve Langasek wrote:
> Absolutely not. /run is a root-only directory, suitable only for
> system-wide data/sockets. It absolutely must not be used for non-root data.

With that said, if you want to fill up /run as a normal user,
and screen is installed, you certianly can. There are probably other ways.

--
see shy jo
 

Thread Tools




All times are GMT. The time now is 11:48 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org