swap.conf(5)

NAME
swap.conf - systemd-swap configuration files.

SYNOPSIS

/etc/systemd/swap.conf.d/*.conf

/run/systemd/swap.conf.d/*.conf

/usr/lib/systemd/swap.conf.d/*.conf

/etc/systemd/swap.conf

/usr/share/systemd-swap/swap-default.conf

DESCRIPTION
These configuration files control zram, zswap and swapfc.

CONFIGURATION DIRECTORIES AND PRECEDENCE

The default configuration is defined during compilation, so a configuration file is only needed when it is necessary to deviate from those defaults. By default, the configuration file in /etc/systemd/ contains commented out entries showing the defaults as a guide to the administrator. This file can be edited to create local overrides.

When packages need to customize the configuration, they can install configuration snippets in /usr/lib/systemd/swap.conf.d/. The main configuration file is read before any of the configuration directories, and has the lowest precedence; entries in a file in any configuration directory override entries in the single configuration file. Files in the swap.conf.d/ configuration subdirectories are sorted by their filename in lexicographic order, regardless of in which of the subdirectories they reside. When multiple files specify the same option, for options which accept just a single value, the entry in the file with the lexicographically latest name takes precedence.

Files in /etc/ are reserved for the local administrator, who may use this logic to override the configuration files installed by vendor packages. It is recommended to prefix all filenames in those subdirectories with a two-digit number and a dash, to simplify the ordering of the files.

To disable a configuration file supplied by the vendor, the recommended way is to place a symlink to /dev/null in the configuration directory in /etc/, with the same filename as the vendor configuration file.

OPTIONS

The following options are available in the "zswap" section:

zswap_enabled=
    Whether zswap is enabled, set to yes/y/1/true to enable zswap. Zswap is a compressed writeback cache for swap files and swap partitions.

zswap_compressor=
    Compressor algorithm for zswap, Linux currently supports lzo, lz4, zstd, zlo-rle and zl4hc.

zswap_max_pool_percent=
    Percentage of ram that can be compressed.

zswap_zpool=
    Set wich compressed memory pool to use, if unsure use z3fold.

The following options are available in the "zram" section:

zram_enabled=
    Whether zram is enabled, set to yes/y/1/true to enable zram. Zram is a compressed ram disk.

zram_size=
    Set the ammount of memory per zram device.

zram_count=
    Set the ammount of zram devices.

zram_streams=
    Set the ammount of compression streams.

zram_alg=
    Compressor algorithm for zram, Linux currently supports lzo, lz4, zstd, zlo-rle and zl4hc.

zram_prio=
    Set the swap priority for zram devices.

The following options are available in the "swapfc" section:

swapfc_enabled=
    Whether swapfc is enabled, set to yes/y/1/true to enable swapfc. Swapfc stands for "swap file chunked" and dynamically allocates new swap files when memory is running low and removes its swap files when not in use.

swapfc_force_use_loop=
    Whether swapfc should always create swap files on loopback devices.

swapfc_frequency=
    The frequency in seconds swapfc should run at.

swapfc_chunk_size=
    Size of the swap files created by swapfc.

swapfc_max_count=
    Maximum number of swap files swapfc should create (note that linux by defaults only supports 32).

swapfc_min_count=
    Minimum number of swap files swapfc should create on startup. Defaults to 0 to only allocate swap files when running lon free memory.

swapfc_free_ram_perc=
    Ammount of memory free (in percent) when swapfc creates a new swap file. (Note that this applies only to the first swap file.)

swapfc_free_swap_perc=
    Ammount of swap free (in percent) when swapfc creates a new swap file.

swapfc_remove_free_swap_perc=
    Ammount of swap free (in percent) when swapfc removes a swap file.

swapfc_priority=
    The priority given to swapfiles created by swapfc (decreasing by one for every swap file created). When at 0 it skips to -2. Max 32767.

swapfc_path=
    Path to folder where swapfc creates its swap files.

The following options are only for loop devices.

swapfc_nocow=
    Whether to disable CoW on swap file.

swapfc_directio=
    Whether to use direct_io.

swapfc_force_preallocated=
    Whether to preallocated files.

The following options are available in the "swapd" section:

swapd_auto_swapon=
    Whether to automatically find and activate all swap devices.

swapd_prio=
    Priority for devices found by swapd_auto_swapon.

AUTHOR
Vilgot Fredenberg <vilgot@fredenberg.xyz>

SEE ALSO
systemd-swap(8)