Why doesn't /tmp use tmpfs?
I have loads of RAM and I use very little. I also do record some screencasts with gtk-recordmydesktop
, which by default saves to /tmp
while recording. I assumed that it would mean storing to RAM as much as possible, but then I actually checked and found that /tmp
isn't mounted with tmpfs. Why is that?
I think you answered your own question. A lot of programs use /tmp
for storing temporary files, and they can be huge.
For example Brasero defaults to that directory to store a CD/DVD's image file, which can be 4.7 GB of size. It's not worth risking a serious slowdown (or a system lockup) in an out of memory situation if your RAM and swap get full.
For advanced users it's no problem to change some applications' defaults and mount /tmp
as tmpfs
. For general use it's just not worth the risk I guess.
What about zram compression ?
The available space is more than 256 Mbytes, it depends on files' type.
modprobe zram num_devices=1
# max ram usage = 256 Mbytes
echo 262144 > /sys/block/zram0/disksize
mke2fs -q -m 0 -b 4096 -O sparse_super -L zram /dev/zram0
mount -o relatime,noexec,nosuid /dev/zram0 /tmp
There was an idea to use tmpfs while it has enough space, and write to disk when you run out of space: http://www.bigdbahead.com/?p=137 However, it never really took off. I've managed to get it working, but the FUSE overhead defeats any benefit of using tmpfs: http://shnatsel.blogspot.com/2011/11/miniwheatfs-aka-reliable-ramdisks.html