Zram

zram, formerly called compcache, is a Linux kernel module for creating a compressed block device in RAM, in other words a RAM disk, but with on-the-fly disk compression. The block device created with zram can then be used for swap or as general-purpose RAM disk. The two most common uses for zram are for the storage of temporary files () and as a swap device. Initially, zram had only the latter function, hence the original name "compcache" ("compressed cache").
Linux kernel module.
After four years in Linux's driver staging area, zram was introduced into the mainline Linux kernel in version 3.14, released on March 30, 2014. From Linux kernel version 3.15 onwards (released on June 8, 2014), zram supports multiple compression streams and multiple compression algorithms. Compression algorithms include DEFLATE (codice_1), LZ4 (codice_2, and codice_3 "high compression"), LZO (codice_4 "run-length encoding"), Zstandard (codice_5), 842 (codice_6). From kernel 5.1, the default is codice_4, which has a balance of speed and ratio. Like most other system parameters, the compression algorithm can be selected via sysfs.
When used as a compressed swap space, zram is similar to zswap, which is not a general-purpose RAM disk, but rather an in-kernel compressed cache for swap pages. Until the introduction of codice_8 in kernel version 4.14, unlike zswap, zram could not use a hard disk as a backing store, so it cannot move less-frequently used pages to disk. However, zswap requires a backing store, but zram does not.
When used for swap, zram (like zswap) allows Linux to make more efficient use of RAM, since the operating system can then hold more pages of memory in the compressed swap than if the same amount of RAM had been used as application memory or disk cache. This is particularly effective on machines that do not have much memory. In 2012, Ubuntu briefly considered enabling zram by default on computers with small amounts of installed RAM. For this same reason, Fedora enabled zram by default starting with release 33.
A compressed swap space with zram and zswap also offers advantages for low-end hardware devices such as embedded devices and netbooks. Such devices usually use flash-based storage, which has limited lifespan due to write amplification, and also use it to provide swap space. The reduction in swap usage as a result of using zram effectively reduces the amount of wear placed on such flash-based storage, resulting in prolonging its usable life. Also, using zram results in a significantly reduced I/O for Linux systems that require swapping.