what is tmpfs

Temporary file systems (tmpfs) allow users to create and manage volatile storage in RAM. tempfs is the best method to handle temporary files and directories and improve performance and responsiveness. In this post, I will share the steps of creating and mounting tmpfs on a Linux system. The main function of a RAM disk is to keep the application caching folder, log files, or temporary data. There are two main types of RAM Disk, which are used in Linux.


Create and Mount tmpfs

Step 1: Check Support

First confirm before creating, that your Linux kernel supports tmpfs. Most modern Linux kernels support by default.

Step 2: Create and Mount

Create a mount folder to use your tempfs RAM disk.

 mkdir /ramdisk 

Use the mount command to create a RAM disk and mount. The below command will mount temporarily, we can use also /etc/fstab for permanent mounting.


 mount -t [TYPE] -o size=[SIZE] [FSTYPE] [MOUNTPOINT]

For example below :

mount -t tmpfs -o size=256M tmpfs /ramdisk 

[TYPE] RAM disk type.
[SIZE] is the size to use for the file system.
[FSTYPE] Type of RAM disk to use.


mount -t tmpfs -o size=256M tmpfs /ramdisk

If you have to make it available after reboot then you can edit the /etc/fstab files and add below the following line:

 tmpfs /ramdisk      tmpfs   size=256M,mode=0777     0   0

In the example [TYPE] of the ramdisk, the size of the Ramdisk will be used for the ramdisk. type of ram disk like ext4, ext3, ext4 ,xfs tmpfs.

Mounted Partition showing tmpfs

If you want to unmount when you’re done using it, run:

 umount /ramdisk

Step 3: Utilize tmpfs

Now that it is attached, we can use it for temporary storage needs. Create files and directories, and they’ll reside in RAM, offering swift access.

It presents an important solution for managing temporary data efficiently in Linux systems. Whether you need a fast and volatile storage space for caches, logs, or other transient data, provides a nimble and responsive option. Experiment with and tailor it to your specific needs.

By Sachin G

I am a professional freelance contributor and founder of tech transit. Love to write and lover of education, culture, and community. I have been using it, setting, supporting, and maintaining it since 2009.Linux rocks! Sachin G Follow me on LinkedIn and x formerly twitter