To enable zswap on Ubuntu, first make sure the system has an active swap file or partition. Then either turn it on temporarily with sudo sh -c 'echo 1 > /sys/module/zswap/parameters/enabled', or add zswap.enabled=1 to the kernel command line in /etc/default/grub and rebuild GRUB. The runtime method lasts only until reboot; the GRUB method is persistent.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
zswap is a compressed RAM cache for pages that would otherwise be written to swap. It can reduce swap-device I/O, but it is not a replacement for swap: compressed pages eventually need backing storage, and compression consumes CPU time. Ubuntu kernels differ in defaults and available tunables, so verify the running kernel before changing anything.
As an Amazon Associate I earn from qualifying purchases.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWhat zswap does—and what it does not do
When Linux needs to reclaim memory, it can move infrequently used pages out of RAM to a swap file or partition. zswap inserts a compressed cache in RAM in front of that backing swap device. Pages are compressed and kept in the cache first; only pages that do not fit, are rejected, or are written back are sent to the swap device.
This arrangement can reduce physical swap writes and reads, particularly on systems where the swap device is slow. The trade-off is CPU work for compression and decompression, plus RAM reserved for the compressed pool. zswap therefore is not automatically faster for every workload. Measure it under the applications and memory pressure you actually care about.
#1 Best Overall
- Backing swap is still required. zswap has nowhere to write pages when its pool is full or writeback occurs unless a swap file or partition is active.
- The pool lives in physical RAM. Its limit is expressed as a percentage of installed RAM, not as a percentage of the swap device.
- It is a kernel feature. On Ubuntu it is commonly built into the kernel rather than installed as a separate package.
- Defaults are kernel-specific. Ubuntu release, HWE kernel, architecture and vendor configuration can change whether it starts enabled, which compressor is selected and which parameters are exposed.
Check prerequisites before enabling zswap
Confirm that swap is active
Run these commands in a terminal:
swapon --show
free -h
swapon --show should list at least one active swap file or partition. The free -h output should show a non-zero value in the Swap row. If no device or file appears, configure and activate swap first; enabling zswap without backing swap does not provide a usable swap path.
Do not confuse a swap file’s size with zswap’s RAM pool. A 16-GiB swap file, for example, does not give zswap a 16-GiB cache. The cache is bounded independently by a percentage of physical memory.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsRank #2
Inspect the running kernel interface
Check whether the kernel exposes zswap parameters and what the current boot command line contains:
ls -l /sys/module/zswap/parameters/
cat /sys/module/zswap/parameters/enabled 2>/dev/null || true
cat /proc/cmdline
The file /sys/module/zswap/parameters/enabled is the authoritative live-state check. It normally prints Y or 1 when enabled and N or 0 when disabled, depending on the kernel interface. If the directory or parameter does not exist, the running kernel may not have zswap built or exposed; installing a package with a similar name will not add it to that already-running kernel.
Rank #3
/proc/cmdline shows the arguments used to boot the current kernel. Seeing zswap.enabled=1 there confirms that the persistent boot option was passed, but you should still check the sysfs value because a boot argument and the resulting live state are separate observations.
Enable zswap temporarily
A runtime change is useful for a controlled test. It does not modify GRUB and is lost at the next reboot.
Quick Recap
Best Value
Rank #4
- Confirm that the parameter exists:
test -e /sys/module/zswap/parameters/enabled && echo
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

