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?
-
See this bug report.– jarnoFeb 21, 2016 at 16:07
3 Answers
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.
-
1And, 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. ;)– arrangeSep 25, 2011 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, 2011 at 21:00
-
@Fraekkert: What do you mean? Why ext4? Why never? Can you elaborate please?– arrangeSep 25, 2011 at 21:20
-
1It'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, 2011 at 7:10
-
1For reference, here is a comment explaining the 5/30 seconds topic in detail: bugs.launchpad.net/ubuntu/+source/linux/+bug/317781/comments/45– lxgrSep 23, 2012 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
-
That's actually a pretty interesting idea...will try this out :) Jun 6, 2012 at 8:21
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