Even though swap is not necessary for the most of use cases, but developers might need swap space when doing a big compilation, browsing on chrome or on slack. but it is a really painful experience using a swap partition on Disk space. ZRAM helps us allocate small storage from RAM as swap space and store 3,4 times of data on that space. its even faster than the SSD swap partitions because this is a ram drive.
Since zstd has an excellent compression ratio, 2GB of zram space will have total swap capacity around 6GB. please note that these commands are only tested on Fedora 32. All the changes will be lost in the next reboot.
$ modprobe zram num_devices=2 $ echo zstd > /sys/block/zram0/comp_algorithm $ echo 2G > /sys/block/zram0/disksize $ mkswap --label zram0 /dev/zram0
$ swapon --priority 1 /dev/zram0
$ free -h total used free shared buff/cache available Mem: 15Gi 7.3Gi 1.8Gi 1.5Gi 6.4Gi 6.4Gi Swap: 2.0Gi 5.0Mi 2.0Gi
$ swapoff /dev/zram0
update: zram is enabled by default