^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) zram: Compressed RAM based block devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) ----------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Introduction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) The zram module creates RAM based block devices named /dev/zram<id>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) (<id> = 0, 1, ...). Pages written to these disks are compressed and stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) in memory itself. These disks allow very fast I/O and compression provides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) good amounts of memory savings. Some of the usecases include /tmp storage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) use as swap disks, various caches under /var and maybe many more :)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) Statistics for individual zram devices are exported through sysfs nodes at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /sys/block/zram<id>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) Kconfig required:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) CONFIG_ZRAM=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) CONFIG_CRYPTO_LZ4=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) CONFIG_ZPOOL=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) CONFIG_ZSMALLOC=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) ZRAM Testcases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) zram_lib.sh: create library with initialization/cleanup functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) zram.sh: For sanity check of CONFIG_ZRAM and to run zram01 and zram02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) Two functional tests: zram01 and zram02:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) zram01.sh: creates general purpose ram disks with ext4 filesystems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) zram02.sh: creates block device for swap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) Commands required for testing:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) - bc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) - dd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) - free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) - awk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) - mkswap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) - swapon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) - swapoff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) - mkfs/ mkfs.ext4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) For more information please refer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) kernel-source-tree/Documentation/admin-guide/blockdev/zram.rst