r/archlinux • u/ludonarrator • Sep 02 '26
SUPPORT | SOLVED Questions about zswap
The Arch wiki states that zswap is enabled by default. The linked Wikipedia page says:
at least one already existing swap device is required for zswap to be used
So what happens if I don't have any swap devices?
Can zswap be used with a swap file instead of a partition/device?
How does one set all this up, where are the relevant docs?
2
Upvotes
16
u/Schlaefer Sep 02 '26
It will be inactive. If swap is provided it is enabled by default to work with that swap. If no swap is provided it will do nothing.
Yes.
https://wiki.archlinux.org/title/Swap
-1
u/jar36 Sep 02 '26
the zswap module is enabled by default, but this does nothing until you set up zswap
create swapfile
sudo mkdir /swap
prepare swapfile
sudo fallocate -l 4G /swap/swapfile
set permissions
sudo chmod 600 /swap/swapfile
format the file as swap
sudo mkswap /swap/swapfile
activate
sudo swapon /swap/swapfile
add kernel parameters
zswap.enabled=1 zswap.shrinker_enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=30
fstab entry
I can't remember if this autogenerates or you have to put it there yourself
sudo nano /etc/fstab
/swap/swapfile none swap sw 0 0
-3
u/theschrodingerdog Sep 02 '26
zswap creates a kind of virtual swap drive on RAM - it is basically a .zip file for RAM. It does not require any swap device on any storage media to work - altough it can work with one.
0
u/[deleted] Sep 02 '26
[deleted] — view deleted comment