How to make tmpfs to use only the physical RAM and not the swap

ramswaptmpfs

How to be sure that a tmpfs filesystem can only deal with physical and it's not using a swap partition on disk?

Since I have a slow HDD and a fast RAM, I would like, at least, giving higher priority to the RAM usage for swap and tmpfs or disabling the disk usage for tmpfs related mount points.

Best Answer

use ramfs instead of tmpfs. ramfs is a ramdisk (no swap) tmpfs can be both in your /etc/fstab:

none     /path/to/location     ramfs  defaults,size=512M   0     0

edit the size parameter to whatever you like but be careful not to exceed your actual amount of ram.

NOTE: the use of a ramfs instead of tmpfs is not something i would recommend. you will find yourself experiencing stability issues if something happens and you write a ton of data to your ramdisk. you can NOT unallocate ram from a ramfs. once your ramdisk (all of your ram) is full your system will seize up. ram is volatile memory, meaning once it looses power all data is gone. so if your ramdisk fills up your ram and you crash you will never see what was on your ram disk again. unlike ramfs, tmpfs limits its size.

Related Question