# Zswap

Related articles

- Kernel parameters
- Mkinitcpio

"Zswap is a Linux kernel feature providing a compressed write-back cache for swapped pages. Instead of moving memory pages to a swap device when they are to be swapped out, zswap performs their compression and then stores them into a memory pool dynamically allocated inside system's RAM." - Wikipedia

In simple words, zswap - no swap as zram(compcache) or swap file/partition. Zswap only interlayer, for work this feature you need manually setup swap partition/file.

## Get in work

#### To enable zswap, you must add this to your kernel boot parameters

      zswap.enabled=1

#### Customize the maximum allowed size

      zswap.max_pool_percent=25

#### Changing the compression algorithm

      zswap.compressor=lzo #deflate #lz4

#### Enable LZ4 compression (faster than lzo and deflate, less compression)

1. Add `lz4 lz4_compress` to the Mkinitcpio#MODULES array.
2. Rerun `mkinitcpio`.
3. Add `zswap.compressor=lz4` to your kernel parameters Kernel_parameters#Configuration.
4. Reboot
5. Check dmesg :

       $ dmesg | grep 'zswap.* compressor'
       [    0.307223] zswap: using lz4 compressor

## See also

- Zswap documentation.
- zswap: How to determine whether it is compressing swap pages?.
- Archlinux forum thread.

Category:

- Kernel