{"id":13442266,"url":"https://github.com/systemd/zram-generator","last_synced_at":"2025-03-20T13:33:10.886Z","repository":{"id":32915381,"uuid":"144772332","full_name":"systemd/zram-generator","owner":"systemd","description":"Systemd unit generator for zram devices","archived":false,"fork":false,"pushed_at":"2024-04-09T12:24:49.000Z","size":289,"stargazers_count":520,"open_issues_count":7,"forks_count":49,"subscribers_count":16,"default_branch":"main","last_synced_at":"2024-04-14T06:06:39.627Z","etag":null,"topics":["systemd-generator","zram-devices"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/systemd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-14T21:08:56.000Z","updated_at":"2024-06-08T18:10:00.502Z","dependencies_parsed_at":"2024-01-14T04:34:44.071Z","dependency_job_id":"fb79e34f-e81a-46e3-b6c3-fb7dfc2deff3","html_url":"https://github.com/systemd/zram-generator","commit_stats":{"total_commits":209,"total_committers":23,"mean_commits":9.08695652173913,"dds":0.5645933014354068,"last_synced_commit":"de03a24814a1761d68195871a1855c14cf9c9b9f"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemd%2Fzram-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemd%2Fzram-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemd%2Fzram-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemd%2Fzram-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/systemd","download_url":"https://codeload.github.com/systemd/zram-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244619264,"owners_count":20482389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["systemd-generator","zram-devices"],"created_at":"2024-07-31T03:01:43.703Z","updated_at":"2025-03-20T13:33:10.872Z","avatar_url":"https://github.com/systemd.png","language":"Rust","funding_links":[],"categories":["HarmonyOS","Rust","others"],"sub_categories":["Windows Manager"],"readme":"# `systemd-zram-setup@.service` generator for zram devices\n\n\u003ca href=\"https://repology.org/project/zram-generator/versions\"\u003e\n    \u003cimg align=\"right\" src=\"https://repology.org/badge/vertical-allrepos/zram-generator.svg?exclude_sources=site\u0026exclude_unsupported=1\" alt=\"Packaging status\"\u003e\n\u003c/a\u003e\n\nThis generator provides a simple and fast mechanism to configure swap on `/dev/zram*` devices.\n\nThe main use case is create **swap** devices, but devices with a file system can be created too, see below.\n\n### Configuration\n\nA default config file may be located in /usr.\nThis generator checks the following locations:\n* `/run/systemd/zram-generator.conf`\n* `/etc/systemd/zram-generator.conf`\n* `/usr/local/lib/systemd/zram-generator.conf`\n* `/usr/lib/systemd/zram-generator.conf`\n\n… and the first file found in that list wins.\n\nIn addition, \"drop-ins\" will be loaded from `.conf` files in\n`/etc/systemd/zram-generator.conf.d/`,\n`/usr/lib/systemd/zram-generator.conf.d/`, etc.\n\nThe main configuration file is read before any of the drop-ins and has\nthe lowest precedence; entries in the drop-in files override entries\nin the main configuration file.\n\nSee systemd.unit(5) for a detailed description of this logic.\n\nSee `zram-generator.conf.example` for a list of available settings.\n\n### Swap devices\n\nCreate `/etc/systemd/zram-generator.conf`:\n\n```ini\n# /etc/systemd/zram-generator.conf\n[zram0]\nzram-size = ram / 2\n```\n\nA zram device will be created for each section. No actual\nconfiguration is necessary (the default of `zram-size = min(ram / 2, 4096)` will be\nused unless overriden), but the configuration file with at least one\nsection must exist.\n\n### Mount points\n\n```ini\n# /etc/systemd/zram-generator.conf\n[zram1]\nmount-point = /var/compressed\n```\n\nThis will set up a /dev/zram1 with ext2 and generate a mount unit for /var/compressed.\n\nIn case you want this path to be user-writable, since util-linux v2.39 you can use\n```ini\n[zram1]\noptions = X-mount.mode=1777\n```\n(and/or the relevant `X-mount.{owner,group}=` arguments, cf. mount(8)).\n\nOtherwise, you can use the following \"high-quality hack\":\nfor the above example, create an\noverride for `systemd-zram-setup@zram1.service`, for example with `systemctl edit`,\ncontaining the following (note the sticky bit as required for [/var]/tmp):\n\n```ini\n[Service]\nExecStartPost=/bin/sh -c 'd=$(mktemp -d); mount \"$1\" \"$d\"; chmod 1777 \"$d\"; umount \"$d\"; rmdir \"$d\"' _ /dev/%i\n```\n\n### Rust\n\nThe second purpose of this program is to serve as an example of a systemd\ngenerator in rust.\n\n### Installation\n\nIt is recommended to use an existing package:\n\n* Fedora: `sudo dnf install zram-generator-defaults` (or `sudo dnf install zram-generator` to install without the default configuration)\n* Debian: For Debian 12 Bookworm or later, install `systemd-zram-generator` from the official Debian repos. For earlier Debian releases, packages are provided by nabijaczleweli, see https://debian.nabijaczleweli.xyz/README.\n* Arch: `sudo pacman -S zram-generator` (or https://aur.archlinux.org/packages/zram-generator-git/ for the latest git commit)\n\nTo install directly from sources, execute `make build \u0026\u0026 sudo make install NOBUILD=true`:\n* `zram-generator` binary is installed in the systemd system generator directory (usually `/usr/lib/systemd/system-generators/`)\n* `zram-generator(8)` and `zram-generator.conf(5)` manpages are installed into `/usr/share/man/manN/`, this requires [`ronn`](https://github.com/apjanke/ronn-ng).\n* `units/systemd-zram-setup@.service` is copied into the systemd system unit directory (usually `/usr/lib/systemd/system/`)\n* `zram-generator.conf.example` is copied into `/usr/share/doc/zram-generator/`\nYou need though create your own config file at one of the locations listed above.\n\nTo install and configure with puppet [puppet-zram_generator](https://github.com/voxpupuli/puppet-zram_generator) is available.\n\n#### tl;dr\n\n- Install `zram-generator` using one of the methods listed above.\n- Create a `zram-generator.conf` config file.\n- Run `systemctl daemon-reload` to create new device units.\n- Run `systemctl start /dev/zram0` (adjust the name as appropriate to match the config).\n- Call `zramctl` or `swapon` to confirm that the device has been created and is in use.\n\nOnce installed and configured, the generator will be invoked by systemd early at boot,\nthere is no need to do anything else.\n\n### Testing\n\nThe tests require either the `zram` module to be loaded, or root to run `modprobe zram`.\n\nSet the `ZRAM_GENERATOR_ROOT` environment variable to use that\ninstead of `/` as root.\n\nThe \"{generator}\" template in `units/systemd-zram-setup@.service.d/binary-location.conf`\ncan be substituted for a non-standard location of the binary for testing.\n\n### Authors\n\nWritten by Zbigniew Jędrzejewski-Szmek \u0026lt;\u003czbyszek@in.waw.pl\u003e\u0026gt;,\nIgor Raits \u0026lt;\u003ci.gnatenko.brain@gmail.com\u003e\u0026gt;, наб \u0026lt;\u003cnabijaczleweli@nabijaczleweli.xyz\u003e\u0026gt;, and others.\nSee https://github.com/systemd/zram-generator/graphs/contributors for the full list.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemd%2Fzram-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsystemd%2Fzram-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemd%2Fzram-generator/lists"}