# zram settings...
# SPDX-License-Identifier: GPL-2.0-only

# load zram kernel module on start?
load_on_start=yes

# unload zram kernel module on stop?
unload_on_stop=yes

# Number of devices.
# This value is also passed to the kernel module on modprobe.
num_devices=2

# For each device, specify the following variables
# Omitting them is the same as specifying them as empty: It uses defaults
# type0, type1, ... are the variables for the types (see below)
# size0, size1, ... are the variables for the sizes (in MB)
# mlim0, mlim1, ... are the variables for the maximal uncompressed memory (MB)
# back0, back1, ... are the variables for the backup device (paths)
# icmp0, icmp1, ... are the flags (nonempty = true) whether incompressible
#                   pages are written to the backup device (requires back*)
# idle0, idle1, ... are the flags (nonempty = true) whether idle pages are
#                   written to the backup device (requires back*)
# wlim0, wlim1, ... set the writeback_limit for idle pages (implies idle*)
# maxs0, maxs1, ... are the variables for the maximal (parallel) streams
# algo0, algo1, ... are the variables for the compression algorithms
# para0, para1, ... are the variables for the algorithm parameters
# flag0, flag1, ... are the variables for the flags
# labl0, labl1, ... are the variables for the label name (if you want some)
# uuid0, uuid1, ... are the variables for the UUID (if you want to force it)
# args0, args1, ... are the variables for additional arguments to zram-init
#                   (args0, args1, ... are eval'd, so quote correspondingly!)
# notr0, notr1, ... are the flags (nonempty = true) for "do not trim (discard)"
# (set notr* to a nonempty value only for linux-3.14 or earlier or when you
# are prepared to waste a lot of memory for a possibly slight speed increase)
#
# The following are ignored for type swap but not for the other types:
# blck0, blck1, ... are the variables for the blocksize (ext2, ext4)
# irat0, irat1, ... are the variables for the byte/inode ratio (ext2, ext4)
# inod0, inod1, ... are the variables for the inode number (ext2, ext4)
# opts0, opts1, ... are the variables for the mount options
# mode0, mode1, ... are the variables for the directory mode
# owgr0, owgr1, ... are the variables for the directory owner:group
#
# If the size is 0 (or empty) the device is ignored by the script.
#
# Available types:
# "swap"  The device is initialized as a swap device.
#         The flags variable specifies the priority (16383 if empty).
#         Use "-" in the flags variable for the default priority (-1)
# "/..."  The device is mounted on /...
#         The flags variable specifies the type (ext2, ext4, btrfs, or xfs;
#         default is ext4)
# "-"     The filesystem (specified by flags as above) is created in
#         /dev/zram$NUM but not mounted
# Devices with other types are ignored by the script
#
# Only variables with numbers  0 ... num_devices-1  are used by the script.

# swap - 500M (or a fourth of available memory if uncommenting)
type0=swap
flag0= # The default "16383" is fine for us
size0=512
#size0=`LC_ALL=C free -m | awk '/^Mem:/{print int($2/4)}'`
mlim0= # no hard memory limit
back0= # no backup device
icmp0= # no incompressible page writing to backup device
idle0= # no idle page writing to backup device
wlim0= # no writeback_limit for idle page writing for backup device
notr0= # keep the default on linux-3.15 or newer
maxs0=1 # maximum number of parallel processes for this device
algo0=zstd # zstd (since linux-4.18), lz4 (since linux-3.15), or lzo.
           # Size: zstd (best) > lzo > lz4. Speed: lz4 (best) > zstd > lzo
para0= # No algorithm parameters
labl0=zram_swap # the label name
uuid0= # Do not force UUID
args0= # we could e.g. have set args0="-L 'zram_swap'" instead of using labl0

# /tmp - 2G
# If you use this, you should put zram-init into the boot runlevel,
# and services using /tmp should be in the default runlevel and/or have
# rc_need=zram-init in their /etc/conf.d/... file
type1=/tmp
flag1=ext4
size1=2048
mlim1= # no hard memory limit
back1= # no backup device
icmp1= # no incompressible page writing to backup device
idle1= # no idle page writing to backup device
wlim1= # no writeback_limit for idle page writing for backup device
blck1=1024 # the default blocksize of 4096
irat1= # bytes/inode ratio
inod1= # inode number
opts1="strictatime,nosuid,nodev,noexec" # e.g. "relatime" or "noatime" are also reasonable choices
mode1=1777
owgr1= # No reason to change the default "root:root"
notr1= # keep the default on linux-3.15 or newer
maxs1=2
algo1=zstd
para1="level=3" # algorithm-specific parameters such as compression level
labl1=tmp_dir
uuid1=
args1=

# /var/tmp - 1G
type2=/var/tmp
flag2=ext2
size2=1024
mlim2= # no hard memory limit
back2= # no backup device
icmp2= # no incompressible page writing to backup device
idle2= # no idle page writing to backup device
wlim2= # no writeback_limit for idle page writing for backup device
blck2= # the default blocksize is 4096
irat2= # bytes/inode ratio
inod2= # inode number
opts2=relatime # e.g. "noatime" or "strictatime" are also reasonable choices
mode2=1777
owgr2= # No reason to change the default "root:root"
notr2= # keep the default on linux-3.15 or newer
maxs2=1
algo2=zstd
para0= # No algorithm parameters
labl2=var_tmp_dir
uuid2=
args2=

# Artificial example with btrfs
# (Not actually used here: variables are overridden afterwards by other values)
type3=- # Only format the filesystem but actually do not mount it
flag3=btrfs
size3=1024
maxs3=1
algo3=zstd
labl3=zbtrfs
uuid3=
args3=

# swap - 500M
# With current kernels, Instead of adding an additional swap device,
# you better increase the size and maxs value of the first swap device.
# Thus, the following makes only sense for older kernels not supporting maxs.
# For this reason, the following is not used by the default (num_devices=3).
type3=swap
flag3=
size3=512
maxs3=1
algo3=zstd
labl3=zram_swap2
uuid3=
args3=
