←back to thread

62 points hiAndrewQuinn | 1 comments | | HN request time: 0.001s | source
Show context
hackyhacky ◴[] No.44392515[source]
Rather than re-write your scripts to store temp files into /dev/shm, you can just mount /tmp using the tmpfs file system and get the same benefit for all your programs. Some distros do this by default.

The relevant line from fstab is:

    tmpfs /tmp            tmpfs    noatime 0       2
Now any program that writes to /tmp will be writing to a RAM disk, thus sparing unnecessary wear on my SSD.
replies(7): >>44392526 #>>44392690 #>>44392745 #>>44392789 #>>44392847 #>>44393129 #>>44393836 #
pkulak ◴[] No.44392745[source]
I did this for a while, but writing files to ram can be dangerous, since most things assume unlimited disk space. I noticed that updates would fail on machines that had 16 gigs of ram unless I logged out of my window manager and did it from the TTY. Took quite a long time to realize it was because of all the compiles writing to /tmp. Much easier to just let the SSD get used.
replies(1): >>44392802 #
buckle8017 ◴[] No.44392802[source]
This is why having swap even when you have plenty of memory for normal usage is good.

Swap on an SSD isn't even that slow.

replies(2): >>44392866 #>>44392886 #
pkulak ◴[] No.44392866[source]
You know what, your comment actually reminds me that this happened when I also had a bug in my configuration that was causing me to not actually use swap. I assume running out of tmpfs uses swap like anything else? I might give tmpfs another try.
replies(2): >>44393113 #>>44393717 #
AdieuToLogic ◴[] No.44393113[source]
> I assume running out of tmpfs uses swap like anything else?

This is not the case. RAM-based file system capacities are unrelated to process memory usage, of which "swap space" is for the latter.

replies(3): >>44393245 #>>44393314 #>>44393779 #
pkulak ◴[] No.44393245[source]
Interesting, thank you. I stand by my original point, downvotes be damned.
replies(2): >>44393330 #>>44400450 #
1. AdieuToLogic ◴[] No.44393330[source]
> Interesting, thank you.

Glad to help out. Here[0] is more information regarding Linux swap space as it relates to processes and the VMM subsystem.

> I stand by my original point, downvotes be damned.

:-D

0 - https://phoenixnap.com/kb/swap-space