:::: MENU ::::

Monthly Archives / February 2016

  • Feb 05 / 2016
  • 0
Linux

Set up RamFS or TmpFS on Linux

In the most modern Linux systems, you will find memory-based file systems to make access to disk storage much faster by allocating some RAM space on a disk mount point. But this means that this disk area will be ephemeral and won’t exist anymore after a system reboot. You should never use it for storing persistent data, but rather using it as cache mechanism that needs speed.

As of today, the two main memory-based file systems are tmpfs and ramfs. Both have their pros and cons, depending on your needs.
Right now, tmpfs is more and more used in replacement of ramfs.

Main differences between ramfs and tmpfs are:

RamFS(older)

+ Can be monitored as cached in memory with free
+ Is not using swap
– Can’t be limited in size

TmpFS (newer)

+ Can be monitored with df
+ Can be limited in size
– Can use swap

Setup tmpfs

First create the directory you will use

Then mount it as tmpfs (I’m using here 16M)

You can check that it’s mounted correctly (here I’m already using 21% of the tmpfs)

You can also make it automatically mounted by adding this line in your fstab configuration file:

Setup ramfs

First create the directory you will use

Then mount it as ramfs (I’m using here 16M)

You can check that it’s mounted correctly

You can also make it automatically mounted by adding this line in your fstab configuration file:

Question ? Contact