Is there ever a reason to use tmpfs instead of or in addition to zRAM?
Solution 1:
Data written to a tmpfs
will be kept in-memory uncompressed as long as enough memory is available. Once the system comes under memory pressure, it tries to move data from the tmpfs
(and from any other places, like normal process memory) to any swap
(including swap
on zram
) it can find. Also you can change parameters of a tmpfs
by doing a simple mount -o remount
, especially the size of the file system or the number of inodes.
Using zram
as the backing of a temporary file system has the disadvantage, that all data written there needs to be compressed immediatelly (and decompressed upon use). Also you need to put a file system on top, whiches structures need to be stored even if there are no actual files stored. Also you get limitations like max number of inodes, you can't easily change it's size and so on.
IMHO, best solution is to mount tmpfs
somewhere to use and create a zram
swap. It combines the advantages of both by minimizing the disadvantages.
Or buy more ram of couse ;)