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.

  • 1
    And, I think you might get a little angry and curse the developers if you recorded a few great screencasts and then, after a power outage or system hitch, lost them all. ;)
    – arrange
    Sep 25 '11 at 20:12
  • And the stuff in /tmp might even reside in the RAM and never touch the disk if you use ext4. Sep 25 '11 at 21:00
  • @Fraekkert: What do you mean? Why ext4? Why never? Can you elaborate please?
    – arrange
    Sep 25 '11 at 21:20
  • 1
    It's not unique to ext4, but it's because of Delayed allocation. Essentially it means that files are not necessarily written to disk just because a program tells the os to do so. Instead it is kept in the ram for quick access. If the file is deleted relatively quickly thereafter, it would never reach the disk. Have a look at wikipedia if you need more info. Sep 26 '11 at 7:10
  • 1
    For reference, here is a comment explaining the 5/30 seconds topic in detail: bugs.launchpad.net/ubuntu/+source/linux/+bug/317781/comments/45
    – lxgr
    Sep 23 '12 at 7:41

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.