ZRAM-GENERATOR(8)
π ZRAM-GENERATOR(8) β like, the system manager's manual bestie π
okay so this is the page for zram-generator, from the System Manager's Manual (section 8, iykyk) β strap in π
β¨ NAME β¨
zram-generator β a systemd unit generator for zram swap devices πΈ
β¨ SYNOPSIS β¨
/usr/lib/systemd/system-generators/zram-generator TARGET_DIR [2RGET_DIR 3RGET_DIR]
/usr/lib/systemd/system-generators/zram-generator --setup-device DEVICE
/usr/lib/systemd/system-generators/zram-generator --reset-device DEVICE
(and yes, 2RGET_DIR and 3RGET_DIR are literally written like that in the original, no cap β not a typo we invented, we're just passing it along fr fr π)
β¨ DESCRIPTION β¨
so zram-generator is a generator that creates systemd units to format and use compressed RAM devices β either as swap or as a file system. that's the whole vibe π
the generator gets invoked by systemd all early at boot, and then it does this:
- reads configuration files from
{/etc,/lib}/systemd/zram-generator.conf[.d]β seezram-generator.conf(5)for the deets; - generates
systemd.swap(5)and/orsystemd.mount(5)units into TARGET_DIR and connects them toswap.targetorlocal-fs.targetas appropriate; - makes sure the zram module is loaded and creates the requested devices.
the generator does absolutely nothing if it's run inside a container (as determined by systemd-detect-virt(8) --container). like, it just clocks out π«₯
the generator also understands the kernel command-line option systemd.zram. see zram-generator.conf(5) for details.
setting the ZRAM_GENERATOR_ROOT environment variable makes the generator run in test mode, in which case containerisation is ignored and step 3 is skipped. for the ramifications of ZRAM_GENERATOR_ROOT on config handling, see zram-generator.conf(5).
generated dev-zramN.swap units depend on systemd-zram-setup@zramN.service, which will:
- read configuration files from
{/etc,/lib}/systemd/zram-generator.conf[.d](seezram-generator.conf(5)for details); - set the desired compression algorithm, if any β and if the current kernel doesn't understand the specified algorithm, a warning is issued, but execution continues (resilient queen π);
- set the desired blockdev size and format it as swap with
systemd-makefs(8).
generated path-to-mount-point.mount units depend on systemd-zram-setup@zramN.service. the effect is similar to what happens for swap units, but of course they're formatted with a file system π
when the unit is stopped, the zram device is reset β freeing memory and allowing the device to be reused. recycling icon β¨
zram-generator implements systemd.generator(7).
π¦ Applying config changes π¦
this generator is invoked in early boot, and the devices it configures get created very early too, so the easiest way to apply config changes is to... simply reboot the machine π iconic, low-effort, works.
nevertheless, sometimes it may be useful to add new devices or apply config changes at runtime. applying new configuration means restarting the units, and that in turn means recreating the zram devices. which means:
file systems are temporarily unmounted and their contents lost, and pages are moved out of the compressed swap device into other memory. π like, be so serious before you do this.
if that's acceptable, systemctl restart systemd-zram-setup@zramN or systemctl restart systemd-zram-setup@* may be used to recreate a specific device or all configured devices. (if the device didn't exist, restart will create it β surprise, it's a feature π)
if the way the device is used (e.g. the mount point or file system type) is changed, systemctl daemon-reload needs to be called first to recreate systemd units. and if a device or mount point is removed from configuration, the unit should be stopped before calling daemon-reload. otherwise, systemd will not know how to stop the unit properly. no cap, order matters here fr fr π
β¨ REPORTING BUGS β¨
found a bug? tell on it here: https://github.com/systemd/zram-generator/issues ππ
β¨ SEE ALSO β¨
also:
https://github.com/systemd/zram-generator- Linux documentation of zram:
https://kernel.org/doc/html/latest/admin-guide/blockdev/zram.html - and the zram sysfs ABI:
https://kernel.org/doc/Documentation/ABI/testing/sysfs-block-zram
okay that's the whole page bestie, go configure some compressed RAM, you're gonna slay πβ¨πΈ
November 2024 β mwah, that's the date and this page is ZRAM-GENERATOR(8), signing off π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: zram-generator 1.2.1-160000.2.2 Β· MIT
- opensuse-leap 16.0: zram-generator 1.2.1-160000.2.2 Β· MIT
- opensuse-leap 16.0: zram-generator 1.2.1-160000.2.2 Β· MIT
- opensuse-leap 16.0: zram-generator 1.2.1-160000.2.2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms