Tmpfs

Introduction
tmpfs (Temporary File System) is a virtual filesystem to store files in memory.

In GNU Linux the RAMFS(Random Access Memory File System) has been replaced by TMPFS as the old RAMFS did not handle well when the system run out of memory. The TMPFS allows the filesystem to grow dynamically as and when it needs more space until it hits the pre-set maximum value it has been allocated, after which time it will complain it is out of space and if the ram is used up before it's maximum set value is used it will then use swap space if it is available.

There are many ways and many things we can use the temporary file system in GNU Linux, one being the /tmp directory which does not need to physically store non-volatile data. It matter not that this data is wiped out after a reboot as you are booting up a new session which will be creating and writing new cache data and so on into the /tmp directory.

Installation
You need to activate the following kernel options:

Usage
Generation and mounting of tmpfs in one step:

You can specify the mount option size to control the maximum size of the filesystem (default: half of your memory). Note that tmpfs doesn't reserve this memory, but allocates only the needed memory.

SystemD
When using SystemD the /tmp directory is mounted by default as a TMPFS and given a default size which is deemed big enough for your usage but not so big it will chew up too much RAM. You can view mounted temporary filesystems using this command

This will show you if the /tmp mount-point is a tmpfs filesystem and will show you the set size of said filesystem.

If you want to disable this and take back control of the directory and have it controlled through your /etc/fstab then we can do this by disabling the automatic mount from SystemD and adding it to our /etc/fstab.

This command will now not mount /tmp as a tmpfs and will automatically default back to your block device i.e. you HDD/SSD. We can now add a new line in our /etc/fstab which will create a tmpfs for /tmp manually.

OpenRC
OpenRC is the same as for SystemD only we ommit having to disable SystemD from mounting the /tmp directory manually. This means it is as simple as adding the mountpoint into your /etc/fstab.

Other directories to consider
Performance boosting our systems is for many first and foremost, faster performance higher security and better privacy so here are a few other directories to consider in mounting as a tmpfs to boost your Gentoo GNU Linux box. Most standard installations of Gentoo have already set the folders bellow as a tmpfs so use the findmnt command to check if they are already a tmpfs before you attempt to manually mount them in your fstab.

Conclusion
The outcome of using a temporary filesystem for non volatile files such as the /tmp directory is that the system has a very fast and very responsive access to caching files and or stored session media. This also helps when you use a browser to surf the web as the cookies can be made to be stored on this volatile media speeding up the browser and on every reboot they are scrubbed or wiped from RAM. If you intend on keeping your temporary files for analytics then use of the tmpfs for /tmp and other directories which are used similarly may not be for you. Remember all data stored in the tmpfs mount point will be lost when the system is rebooted or powered down.

Advancements in Technology
There has been some new offerings from the tech giants including a not as fast as RAM but faster than SSD technology to be used as cache drives. These devices are usually incorporated on a PCIe add-in card and have either a adaptor from PCIe to M.2 slot or the entire memory device is embedded into the PCIe card.

So if you need a non-volatile high speed versatile solution that is faster than SSD/SAS/SATA then these high speed solutions are something you should look into. Of course you would not be mounting these devices with tmpfs but instead using a conventional partitioning filesystem and then mounting the appropriate mount-point to the device such as /dev/sd* /tmp and so on.

Technology such as the Intel 3Dx Optaine memory cache can be used for task like this but this technology although more versatile than SSD it is still subject to wearing out. It does however provide a brilliant midway point that will only get better as the technology progresses in the future and provide us with a much faster much snappier computing experience when setup correctly.