Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
VGSOURCES
Get listed

LinuxPATCH 2026.10.16

How to Enable zswap on Ubuntu (and Make It Persistent)

By VGSources Team 11 min read

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

Enable zswap by first confirming that Ubuntu has an active swap file or partition, then either writing 1 to the running kernel’s zswap parameter for a temporary test or adding zswap.enabled=1 to GRUB for a setting that survives reboot. Verify the live kernel state after every change: zswap is a compressed RAM cache in front of swap, not a replacement for swap itself.

Ubuntu kernels do not all start with the same zswap defaults. Your Ubuntu release, HWE kernel, architecture and vendor configuration determine whether it starts enabled and which compressors or tuning parameters are available, so inspect the running kernel before changing anything.

As an Amazon Associate I earn from qualifying purchases.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

What zswap does on Ubuntu

zswap intercepts pages that the kernel is preparing to move to swap and stores compressed copies in a pool in physical RAM. When a page is needed again, the kernel can retrieve and decompress it from that pool instead of immediately reading it from the backing swap device. Pages that do not fit in the pool, or pages written out according to the kernel’s policy, can still be written to the configured swap file or partition.

That design makes zswap a cache in front of swap. It does not create swap space, enlarge an existing swap file, or work as a standalone replacement for one. An active swap device or file is a prerequisite.

  • Compressed storage: the first copy is held in RAM, using CPU time to compress and decompress pages.
  • Backing store: an ordinary swap file or partition remains necessary for pages that leave the cache.
  • Policy: the running kernel decides which pages are accepted, how large the pool may become and when writeback occurs.
  • Persistence: writing the sysfs parameter changes only the current boot; a kernel command-line option is needed to enable it after reboot.

For a game, launcher or desktop session that occasionally runs short of memory, the relevant question is not whether zswap is universally faster. Compression consumes CPU cycles, and the outcome depends on the workload, memory pressure and storage device. Treat the first enablement as a controlled change, observe the counters and system behavior, and tune only if the live kernel exposes the relevant controls.

zswap, zram and ordinary swap

These names describe different layers. The following comparison uses the practical axes that matter when deciding what to configure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Where compressed data is held Backing swap requirement Writeback behavior What to observe
zswap Compressed pool in physical RAM Required: zswap is a cache in front of a swap file or partition Pages can leave the pool and be written to the backing swap device according to kernel policy Enabled parameter plus, on kernels that expose them, debugfs counters such as stored pages and pool size
zram Compressed RAM block device It provides a swap device itself rather than acting as a cache in front of an existing one Its behavior follows the swap device and kernel configuration using it Its own device and compression statistics, not the zswap parameter
Ordinary swap The configured swap file or partition It is the backing store Pages are written directly to the swap device swapon --show, memory pressure and storage I/O

Do not enable zswap merely because another compressed-memory design helped a different system. Keep the comparison tied to your machine’s CPU, RAM, storage and workload, and measure before and after rather than assuming a performance gain.

Check swap and the running kernel first

Do these checks before changing boot parameters. They establish whether zswap has somewhere to send pages and whether the kernel currently exposes the feature.

1. Confirm an active swap file or partition

swapon --show
free -h

swapon --show should list at least one active device or file. The free -h output gives a human-readable view of total, used and available memory plus swap. If the first command prints no swap entries, stop here and configure swap first; enabling zswap without backing swap does not solve that missing prerequisite.

Keep the output from this check when troubleshooting. It tells you whether a later zswap problem is actually a swap-configuration problem.

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

2. Inspect zswap’s sysfs interface

ls -l /sys/module/zswap/parameters/
cat /sys/module/zswap/parameters/enabled 2>/dev/null || true
cat /proc/cmdline

Ubuntu commonly builds zswap into the kernel rather than shipping it as a separate package. The authoritative test is the live kernel interface: if /sys/module/zswap/parameters/ exists, inspect its files; the value in enabled tells you whether the current kernel has the feature on.

/proc/cmdline shows the arguments supplied to this boot. Look for zswap.enabled=1 or another zswap. option, but do not treat a command-line string alone as proof that the feature is active. Confirm the resulting sysfs value as well.

3. Record the kernel identity

Ubuntu release, HWE kernel, architecture and vendor configuration can change the initial state and available tunables. Include the output of uname -r and the Ubuntu release in any support report. There is no single Ubuntu-wide claim that zswap is enabled by default: boot-time behavior depends on whether that kernel was built with CONFIG_ZSWAP_DEFAULT_ON.

Temporarily enable zswap for a test

A runtime change is useful when you want to observe the current boot without editing the bootloader. It is deliberately temporary and will be lost at reboot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Write 1 to the running kernel parameter:
    sudo sh -c 'echo 1 > /sys/module/zswap/parameters/enabled'
  2. Read it back immediately:
    cat /sys/module/zswap/parameters/enabled
  3. Expect the output to be 1. If the write fails, preserve the error and inspect the parameter directory again rather than repeatedly forcing the command.

This uses the kernel’s documented runtime interface. It changes the current kernel instance only; a reboot restores whatever state the kernel and boot arguments specify. A successful value of 1 proves that zswap is enabled, but it does not prove that pages are currently being stored in the compressed pool. Use the statistics procedure below to look for activity.

Make zswap persistent with GRUB

To enable zswap on every boot, add its kernel argument to the existing GRUB command line. Do not replace unrelated options that Ubuntu or your hardware already needs.

  1. Open the GRUB defaults file with administrative privileges:
    sudo editor /etc/default/grub
  2. Find the line beginning with GRUB_CMDLINE_LINUX_DEFAULT=. Append zswap.enabled=1 inside the existing quotation marks. For example:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash zswap.enabled=1"

    Preserve options already present on your system; the example is illustrative, not a complete replacement for your line.

  3. Regenerate the bootloader configuration:
    sudo update-grub

    Read the command’s output for errors before rebooting.

  4. Reboot to load the new kernel command line:
    sudo reboot
  5. After the system returns, verify both the argument and the live state:
    cat /proc/cmdline
    cat /sys/module/zswap/parameters/enabled

    The first command should contain zswap.enabled=1; the second should report 1.

If the argument appears in /proc/cmdline but the sysfs value is not enabled, the running kernel may not expose zswap in the expected way or may apply a configuration that overrides the requested state. Check the parameter directory, kernel version and boot output before adding more options.

Understand the tuning parameters before changing them

Ubuntu kernel builds differ. A parameter documented for one kernel may be absent, have a different default or accept a different compressor on another release or HWE build. Inspect the live values first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cat /sys/module/zswap/parameters/max_pool_percent 2>/dev/null || true
cat /sys/module/zswap/parameters/compressor 2>/dev/null || true
cat /sys/module/zswap/parameters/accept_threshold_percent 2>/dev/null || true

max_pool_percent is a RAM limit

max_pool_percent caps the zswap compressed pool as a percentage of physical RAM. It is not a percentage of the swap file or partition, and it is not a promise that the pool will grow to that size. For example, a boot option such as zswap.max_pool_percent=25 expresses a cap based on installed RAM, not a quarter of the disk-backed swap area.

Leave the default alone until you have verified the live value and observed a real workload. A larger cap consumes more RAM for compressed pages; a smaller cap can cause pages to reach backing swap sooner. The useful choice depends on memory pressure and the rest of the system, not on the swap device’s nominal size.

compressor depends on the kernel

The compressor controls how accepted pages are compressed. Available compressors and the default are determined by the kernel configuration. Do not copy a compressor name from another Ubuntu installation without checking whether your running kernel exposes and accepts it. If you specify one that is unavailable, the boot argument may fail to deliver the intended configuration.

accept_threshold_percent affects admission

The acceptance threshold is another kernel policy control. Its meaning and default come from the zswap implementation in the running kernel. Inspect the sysfs value before changing it, and change one variable at a time so that any behavioral difference can be attributed to a known setting.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Use the smallest persistent change first

A conservative sequence is:

  1. Enable only zswap.enabled=1.
  2. Reboot and verify /proc/cmdline plus the enabled sysfs value.
  3. Exercise the workload that matters to you and inspect activity counters if available.
  4. Add a pool cap or compressor only after confirming that the running kernel supports the exact option and value.
  5. Regenerate GRUB and reboot after each persistent change, then verify again.

The Ubuntu procedure also permits optional boot parameters such as zswap.max_pool_percent=25 and zswap.compressor=.... The ellipsis is intentional: use a compressor value shown as supported by your own kernel rather than guessing a name.

Check whether zswap is actually doing work

The enabled flag answers one question: is the feature switched on? It does not answer whether pages have been accepted into the pool or whether writeback is occurring.

Inspect zswap statistics when the kernel provides them

Some kernels expose zswap counters through debugfs. If debugfs is not mounted, mount it using your system’s normal debugfs procedure, then inspect the zswap statistics exposed by that kernel. Counters such as stored pages and pool size show activity; the exact files and names can vary with kernel configuration.

  • Stored-page counters indicate that pages have entered the compressed pool.
  • Pool-size information shows how much RAM the compressed pool is using.
  • Writeback-related counters, when present, indicate that pages are being sent onward to backing swap.

Record the values before and after a repeatable memory-pressure scenario. A counter that remains at zero during an idle desktop session is not evidence of failure; there may simply be no pages worth caching. Conversely, an enabled flag with growing counters demonstrates use more directly than the flag alone.

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

Interpret results without assuming a benchmark

No independent Ubuntu-wide benchmark establishes that zswap is faster for every workload. Compression can trade CPU time for reduced swap-device traffic, and the balance changes with hardware and workload. Compare the same application set, memory pressure and session pattern before drawing a conclusion. Keep the kernel version and tunables with your notes so the comparison remains meaningful after an update.

Per-service and cgroup controls

Recent systemd versions expose MemoryZSwapMax= and MemoryZSwapWriteback= for per-service or cgroup policy. These settings can limit a unit’s zswap use or permit and restrict writeback for that unit. They do not replace enabling zswap globally with the kernel parameter.

If a service has an explicit cgroup policy, an enabled global flag may coexist with little or no zswap activity for that service. Check the unit’s policy when system-wide counters and the service’s behavior appear inconsistent. Treat these controls as an additional policy layer, not as an alternative activation method.

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

Troubleshoot common enablement failures

swapon --show is empty

zswap needs backing swap. Configure and activate a swap file or partition first, then rerun the prerequisite checks. Do not attempt to solve an absent swap device by increasing zswap pool settings.

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

The zswap parameter directory does not exist

The running kernel may not expose zswap through the expected interface, or the feature may not be present in that build. Check uname -r, the Ubuntu release and architecture, and compare the live kernel rather than assuming that installing a package will add it. zswap is commonly built into Ubuntu kernels, not installed separately.

The runtime write is rejected

Re-read the path and permissions, then list /sys/module/zswap/parameters/ to confirm that the parameter exists and is writable in the current state. If the feature is unavailable or the kernel rejects a transition, stop changing values and use the kernel identity and error text for diagnosis.

The setting disappears after reboot

That is expected for a sysfs-only change. Add zswap.enabled=1 inside GRUB_CMDLINE_LINUX_DEFAULT, run sudo update-grub, reboot and verify /proc/cmdline plus the sysfs value. If the argument is missing, inspect the edited file and the output from update-grub.

The flag is enabled but counters do not move

First confirm that swap is active and that you are observing a workload that creates reclaimable, swappable pages. Then check whether debugfs statistics are available and whether a service-level MemoryZSwapMax= or MemoryZSwapWriteback= policy limits use. An idle system may legitimately show no activity.

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

A compressor or tuning option causes boot problems

Remove the optional zswap.* setting from the GRUB line, regenerate the configuration and reboot. Reintroduce options one at a time only after checking the live kernel’s supported parameters. Keep the minimal zswap.enabled=1 configuration as your known-good baseline.

Roll back safely

Temporary rollback

sudo sh -c 'echo 0 > /sys/module/zswap/parameters/enabled'

Read the parameter afterward to confirm the requested state. Disabling does not instantly flush every page already held in the compressed pool. The kernel documentation states that those pages remain until they are invalidated or faulted back; swapoff forces pages out of the compressed pool as part of disabling swap.

Persistent rollback

  1. Edit /etc/default/grub and remove the zswap.* options you added, while leaving unrelated kernel options intact.
  2. Apply the change:
    sudo update-grub
  3. Reboot:
    sudo reboot
  4. Confirm the resulting command line and live parameter state with cat /proc/cmdline and cat /sys/module/zswap/parameters/enabled.

Keep a rollback path before tuning: save the original GRUB line, make one change at a time and know how to remove the option from a working system or from a recovery environment.

A practical decision checklist for Ubuntu systems

  • Is an active swap file or partition listed by swapon --show?
  • Does /sys/module/zswap/parameters/ exist on the running kernel?
  • What does /sys/module/zswap/parameters/enabled report right now?
  • Does /proc/cmdline contain the boot option you expect?
  • Which values does the live kernel expose for max_pool_percent, compressor and accept_threshold_percent?
  • Are debugfs counters available to demonstrate stored pages, pool size or writeback?
  • Could a systemd cgroup policy be limiting the service you are examining?
  • Have you recorded the Ubuntu release and uname -r before reporting a discrepancy?
  • Do you have a tested GRUB rollback path before adding optional tuning?

The kernel documentation describes zswap as aiming to keep its policies simple. In practice, the safest Ubuntu configuration follows that principle: establish backing swap, enable the feature, verify the live state, measure activity and only then decide whether a pool cap, compressor or cgroup policy is justified.

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

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.

Linuxswapsystem administrationUbuntuzswap

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.