1ZRAM-GENERATOR.CONF(5)        File Formats Manual       ZRAM-GENERATOR.CONF(5)
2
3
4

NAME

6       zram-generator.conf  -  Systemd  unit  generator  for zram swap devices
7       (configuration)
8

SYNOPSIS

10       /usr/lib/systemd/zram-generator.conf
11       /usr/local/lib/systemd/zram-generator.conf
12       /etc/systemd/zram-generator.conf
13       /run/systemd/zram-generator.conf
14
15       /usr/lib/systemd/zram-generator.conf.d/*.conf
16       /usr/local/lib/systemd/zram-generator.conf.d/*.conf
17       /etc/systemd/zram-generator.conf.d/*.conf
18       /run/systemd/zram-generator.conf.d/*.conf
19

DESCRIPTION

21       These files configure devices created by  zram-generator(8).  See  sys‐
22       temd.syntax(5) for a general description of the syntax.
23

CONFIGURATION DIRECTORIES AND PRECEDENCE

25       The   default   configuration  doesn´t  specify  any  devices.  Consult
26       /usr/share/zram-generator/zram-generator.conf.example  for  an  example
27       configuration file.
28
29       When  packages  need  to  customize the configuration, they can install
30       configuration  snippets   in   /usr/lib/systemd/zram-generator.conf.d/.
31       Files  in  /etc/  are reserved for the local administrator, who may use
32       this logic to override the  configuration  files  installed  by  vendor
33       packages. The main configuration file is read before any of the config‐
34       uration directories, and has the lowest precedence; entries in  a  file
35       in  any configuration directory override entries in the single configu‐
36       ration file. Files in the *.conf.d/  configuration  subdirectories  are
37       sorted by their filename in lexicographic order, regardless of which of
38       the subdirectories they reside in. When multiple files specify the same
39       option,  for options which accept just a single value, the entry in the
40       file with the lexicographically latest name  takes  precedence.  It  is
41       recommended  to  prefix  all  filenames  in those subdirectories with a
42       two-digit number and a dash, to simplify the ordering of the files.
43
44       To disable a configuration file supplied by the vendor, the recommended
45       way  is  to place a symlink to /dev/null in the configuration directory
46       in /etc/, with the same filename as the vendor configuration file.
47
48       The generator understands the  following  option  on  the  kernel  com‐
49       mand-line:  systemd.zram[=0|1]. When specified with a true argument (or
50       no argument), the zram0 device will be created. Default options  apply,
51       but  may be overridden by configuration on disk if present. When speci‐
52       fied with a false argument, no zram devices will be created by the gen‐
53       erator.  This  option  thus  has higher priority than the configuration
54       files.
55

OPTIONS

57       Each device is configured independently in its [zramN] section, where N
58       is a nonnegative integer. Other sections are ignored.
59
60       Devices with the final size of 0 will be discarded.
61
62host-memory-limit=
63
64           Sets  the upper limit on the total usable RAM (as defined by MemTo‐
65           tal in /proc/meminfo, confer proc(5)) above which the  device  will
66           not be created.
67
68           This  takes  a  nonnegative  number,  representing  that  limit  in
69           megabytes, or the literal string none, which can be used  to  over‐
70           ride a limit set earlier.
71
72           Defaults to none.
73
74zram-size=
75
76           Sets  the size of the zram device as a function of MemTotal, avail‐
77           able as the ram variable.
78
79           Arithmetic operators (^%/*-+), e, π,  SI  suffixes,  log(),  int(),
80           ceil(),  floor(),  round(),  abs(), min(), max(), and trigonometric
81           functions are supported.
82
83           Defaults to min(ram / 2, 4096).
84
85compression-algorithm=
86
87           Specifies the algorithm used to compress the zram device.
88
89           This takes a literal string, representing the algorithm to use.
90           Consult /sys/block/zram0/comp_algorithm for  a  list  of  currently
91           loaded compression algorithms, but note that additional ones may be
92           loaded on demand.
93
94           If unset, none will be configured and the kernel´s default will  be
95           used.
96
97writeback-device=
98
99           Write  incompressible pages, for which no gain was achieved, to the
100           specified device under memory pressure.  This  corresponds  to  the
101           /sys/block/zramX/backing_dev parameter.
102
103           Takes   a   path   to  a  block  device,  like  /dev/disk/by-partu‐
104           uid/2d54ffa0-01 or /dev/zvol/tarta-zoot/swap-writeback.
105
106           If unset, none is used, and incompressible pages are kept in RAM.
107
108swap-priority=
109
110           Controls the relative swap priority, a value between -1 and  32767.
111           Higher numbers indicate higher priority.
112
113           If unset, 100 is used.
114
115mount-point=
116
117           Format  the  device with a file system (not as swap) and mount this
118           file system over the specified directory. When neither this  option
119           nor fs-type= is specified, the device will be formatted as swap.
120
121           Note that the device is temporary: contents will be destroyed auto‐
122           matically after the file system is unmounted (to release the  back‐
123           ing memory).
124
125fs-type=
126
127           Specifies how the device shall be formatted. The default is ext2 if
128           mount-point is specified, and swap otherwise. (Effectively, the de‐
129           vice   will   be   formatted  as  swap,  if  neither  fs-type=  nor
130           mount-point= are specified.)
131
132           Note that the device is temporary: contents will be destroyed auto‐
133           matically  after the file system is unmounted (to release the back‐
134           ing memory).
135
136           Also see systemd-makefs(8).
137
138options=
139
140           Sets mount or swapon options. Availability depends on fs-type.
141
142           Defaults to discard.
143
144
145

ENVIRONMENT VARIABLES

147       Setting ZRAM_GENERATOR_ROOT during parsing will cause /proc/meminfo  to
148       be    read    from   $ZRAM_GENERATOR_ROOT/proc/meminfo   instead,   and
149       {/usr/lib,/usr/local/lib,/etc,/run}/systemd/zram-generator.conf  to  be
150       read from $ZRAM_GENERATOR_ROOT/{/usr/lib,/usr/local/lib,/etc,/run}/sys‐
151       temd/zram-generator.conf.
152

EXAMPLES

154       The default configuration will yield the following:
155
156
157            zram device size
158                ^
159
160             4G>│               ooooooooooooo
161                │             o
162                │           o
163                │         o
164             2G>│       o
165                │     o
166                │   o
167           512M>│ o
168                0───────────────────────> total usable RAM
169                  ^     ^       ^
170                  1G    4G      8G
171
172
173
174       A piecewise-linear size 1:1 for the first 4G, then 1:2 above, up  to  a
175       max of 32G:
176         zram-size = min(min(ram, 4096) + max(ram - 4096, 0) / 2, 32 * 1024)
177
178
179            zram device size
180                ^
181            32G>|                                                oooooooooooooo
182                |                                            o
183            30G>|                                        o
184                |
185               /=/
186                |
187             8G>│                           o
188                │                       o
189                │                   o
190                │               o
191                │           o
192             4G>│       o
193                │     o
194                │   o
195             1G>│ o
196                0───────────────────────────────────||──────────────────────> total usable RAM
197                  ^     ^       ^               ^        ^       ^       ^
198                  1G    4G      8G             12G      56G     60G     64G
199
200
201

OBSOLETE OPTIONS

203memory-limit=
204
205           Compatibility alias for host-memory-limit.
206
207zram-fraction=
208
209           Defines  the scaling factor of the zram device´s size with relation
210           to the total usable RAM.
211
212           This takes a nonnegative floating-point  number  representing  that
213           factor.
214
215           Defaulted   to   0.5.   Setting  this  or  max-zram-size  overrides
216           zram-size.
217
218max-zram-size=
219
220           Sets the limit on the zram device´s size obtained by zram-fraction.
221
222           This  takes  a  nonnegative  number,  representing  that  limit  in
223           megabytes,  or  the literal string none, which can be used to over‐
224           ride a limit set earlier.
225
226           Defaulted  to  4096.  Setting  this  or   zram-fraction   overrides
227           zram-size.
228
229
230

REPORTING BUGS

232       https://github.com/systemd/zram-generator/issues
233

SEE ALSO

235       zram-generator(8), systemd.syntax(5), proc(5)
236
237       https://github.com/systemd/zram-generator
238
239       Linux  documentation  of  zram:  https://kernel.org/doc/html/latest/ad
240       min-guide/blockdev/zram.html
241       and the zram sysfs ABI:  https://kernel.org/doc/Documentation/ABI/test
242       ing/sysfs-block-zram
243
244       fasteval   documentation  for  the  entire  zram-size  arithmetic  DSL:
245       https://docs.rs/fasteval/0.2.4/fasteval/#the-fasteval-expres‐
246       sion-mini-language
247
248
249
250zram-generator developers        November 1973          ZRAM-GENERATOR.CONF(5)
Impressum