How to mount Linux folders into RAM using tmpfs

fluffyc3rb3rus
2 min readDec 27, 2019
How to mount Linux Folders into RAM using TMPFS

When you are doing a lot of I/O operations on a set of files, you may wish to keep files in RAM to speed up everything.
Sometimes, you may wish to keep some files in RAM just because you don’t need to preserve them (e.g. temporary files).

If you ever had problems like these, maybe tmpfs can help you.

What is a TMPFS and how can we use it?

Tmpfs stands for Temporary File System.
To create files inside a tmpfs-mounted folder means that they will disappear when you shutdown your PC or unmount the folder.
How to create a tmpfs folder?

First, create a folder to use as a mount point.

mkdir [foldername]

Then, transform it into a tmpfs folder.

sudo mount -t tmpfs -o size=[desiredSize] tmpfs [folderPath]

Now, we can check if everything is fine with df command.

df -lh

Checking the status of our brand new folder

We have created a folder mounted into RAM. Its size is 512MB, but it can be easily modified.

--

--

fluffyc3rb3rus
fluffyc3rb3rus

Written by fluffyc3rb3rus

Penetration Tester, traveller and food addicted, but still human. I love security, Linux, games :) | eMAPT| eWPT | OSCP | CTF Player