Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
FREEDOM251

Freedom251 › Blog › GRUB

How to Enable zswap on Ubuntu (and Verify It Works After Reboot)

By Freedom251 Team · · 3 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What 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.

  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

/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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Enable zswap temporarily

A runtime change is useful for a controlled test. It does not modify GRUB and is lost at the next reboot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. 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.

GRUBLinuxMemory ManagementSwapUbuntuzswap

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.