You will get better performance from using zram
for swap
due to the compression that is possible.
zram-init
makes zram
simple to use. Remember to read the instructions.
Your kernel needs to be built with CONFIG_ZRAM_LZ4_COMPRESS
enabled to be able to benefit from lz4
compression.
I use zram
for swap
& for /tmp
(zram-init
uses sensible default mount options for /tmp
):
root@alpine [~]# cat /proc/swaps
Filename Type Size Used Priority
/dev/vda7 partition 1045500 0 -1
/dev/zram0 partition 1048572 0 16383
root@alpine [~]# mount|grep zram
/dev/zram1 on /tmp type ext4 (rw,nosuid,nodev,noexec,discard)
There are still use cases for using tmpfs
. I use these for bind mounting volumes with secure mount options into lxc
containers:
root@http [~]# mount|grep tmpfs
tmpfs on /var/www/domain.com/bin type tmpfs (ro,nosuid,nodev,relatime,size=200k)
tmpfs on /var/www/domain.comm/dev type tmpfs (rw,nosuid,relatime,size=4k,mode=755)