How can I use RAM storage for the /tmp directory and how to set a maximum amount of RAM usage for it?
After seeing the comment by Anonymous on the question How is the /tmp directory cleaned up?, I found that it would be a great idea to implement on my system, since I have 16GB of RAM and I never used all of it.
My temporary files never get written to the disk. They get written to a RAM disk. I did put
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0in /etc/fstab.
My question is:
Can I set a maximum value for RAM Usage for
/tmp? And in that case, what would happen if the maximum amount got exceeded, would it write into the hard-disk drive?
I have read a solution which states:
mkdir -p /tmp/ram
sudo mount -t tmpfs -o size=512M tmpfs /tmp/ram/
But in my understanding, this won't be a permanent solution. If I need it to be permanent, it has to be added to the
/etc/fstab configuration file.
If this is the correct solution, how can I transform that mount command into a line in