Live data from Hacker News

Tmpfs considered harmful

rwmj.wordpress.com

61–70 of 85 posts

Re: Tmpfs considered harmful

#62
post #4

Minor disagreement about the following: "Everyone must worry about whether their files need to survive a reboot" I believe there was never such expectation of /tmp. On many systems it's being wiped periodically or even when the user's last session ends. The example app(s) that use /tmp for drafts need(s) to be fixed.

Totally agree, /tmp should be wiped at the end of each session.

Agreed; this prevents establishment of expectations otherwise.

Re: Tmpfs considered harmful

#65
post #11
post #4

Minor disagreement about the following: "Everyone must worry about whether their files need to survive a reboot" I believe there was never such expectation of /tmp. On many systems it's being wiped periodically or even when the user's last session ends. The example app(s) that use /tmp for drafts need(s) to be fixed.

Sure, but if the power goes down, there's at least a chance that I may be able to find that long email I was writing. With /tmp on tmpfs, it's gone.

No, because /tmp is supposed to be assumed to be cleared on start up. If you want something to survive between reboots, /tmp is the last place you should put it, even if you're not using tmpfs.

I've never had a problem with this using mutt, but if I cared, I'd switch it to use /var/tmp.

Either way, if there's a problem, it's with the program, not the filesystem - no need to use a cannon to kill a fly.

Re: Tmpfs considered harmful

#66
post #49

The fact is, is that not every app that uses /tmp does so in a safe manner. As long as that is true, it's not a good idea to use tmpfs for /tmp. It's perfectly reasonable, however, to use tmpfs for, say, /var/local/tmp and let individual users point $TMP at that. Want to live fast and dangerously? Set $TMP.

This assumes processes use $TMP.

Re: Tmpfs considered harmful

#68

Why on earth would anybody ever use tmpfs for /tmp? If I'm writing a program that deals with a big file, and I want to temporarily write something to the filesystem, it is because I dont want it in memory. Why would you ever write to /tmp for any reason other than to get something out of ram for a while?

Because tmpfs is RAM cached disk (swap) space just like any other filesystem?

Is there some better place than swap to accommodate /tmp?

Re: Tmpfs considered harmful

#69
post #41

Earlier quoted context omitted.

That's like saying "RAM considered harmful", because every time a developer has to think "do I just store this in memory, or do I sync it to disk" "it forces a complex decision about the storage hierarchy": /tmp is simply RAM that has the API of a file; it used to be implemented using a horrible kludge with files on disk that were periodically deleted, but with tmpfs the dream became a reality.

RAM really is a harmful kludge. Neither Turing machines nor lambda calculus call for some of an algorithm's state to suddenly be obliterated. The only reason we put up with it is that disk and SSD are so much slower.

Speed is not the only benefit of RAM. The internal data structures of most programs are gnarly messes of intertwined pointers, fragile, easily corrupted, hard to upgrade in place, almost impossible to fix when they break. The division between RAM and disk forces everything to be serialized at intervals to clean storage formats that can be reread for a fresh start. As a practical matter, that's a big enough benefit to justify enforcing the division at an API level even if disk were as fast as RAM.

Re: Tmpfs considered harmful

#70

Why on earth would anybody ever use tmpfs for /tmp? If I'm writing a program that deals with a big file, and I want to temporarily write something to the filesystem, it is because I dont want it in memory. Why would you ever write to /tmp for any reason other than to get something out of ram for a while?

This is very popular amongst people just working on desktop setups. They usually don't need /tmp to house anything too large. Arch Linux actually switched recently to mounting /tmp as tmpfs recently.
Post reply on HN