{"id":48461380,"url":"https://github.com/raspberrypi/rpi-swap","last_synced_at":"2026-04-07T02:01:26.124Z","repository":{"id":348898347,"uuid":"1077472555","full_name":"raspberrypi/rpi-swap","owner":"raspberrypi","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-16T10:05:18.000Z","size":80,"stargazers_count":11,"open_issues_count":6,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-03T14:56:17.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raspberrypi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-16T09:47:19.000Z","updated_at":"2026-04-03T09:10:34.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/raspberrypi/rpi-swap","commit_stats":null,"previous_names":["raspberrypi/rpi-swap"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/raspberrypi/rpi-swap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Frpi-swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Frpi-swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Frpi-swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Frpi-swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raspberrypi","download_url":"https://codeload.github.com/raspberrypi/rpi-swap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Frpi-swap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31496769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"online","status_checked_at":"2026-04-07T02:00:07.164Z","response_time":105,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-04-07T02:01:06.159Z","updated_at":"2026-04-07T02:01:26.115Z","avatar_url":"https://github.com/raspberrypi.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rpi-swap\n\nModern swap management for Raspberry Pi systems, designed to replace `dphys-swapfile` with a more flexible and efficient approach.\n\n## What is rpi-swap?\n\nThe `rpi-swap` package provides intelligent swap configuration that adapts to your Raspberry Pi's memory and storage setup. It offers multiple swap mechanisms and integrates seamlessly with systemd's modern service management.\n\n### Key Features\n\n- **Dynamic sizing**: Automatically calculates optimal swap size based on available RAM and storage\n- **Multiple swap types**: Supports compressed RAM swap (zram), file-based swap, or hybrid combinations\n- **Early boot integration**: Swap is available immediately during the boot process when memory pressure is highest\n- **Storage-aware**: Intelligently chooses swap mechanisms based on your storage type (SD card vs USB/SSD)\n- **systemd integration**: Full integration with systemd's swap.target for reliable service dependencies\n- **Zero-configuration**: Works out of the box with sensible defaults for most Raspberry Pi setups\n\n## How it Works\n\nThe system offers four main swap mechanisms:\n\n**🗜️ Compressed RAM Swap (zram)**\nUses a portion of your RAM to create compressed swap space. Ideal for systems with limited storage or SD cards where you want to minimise write wear. The system automatically optimises kernel settings to reduce latency on compressed swap devices.\n\n**💾 File-based Swap**\nTraditional swap file on disk storage. Best for systems with fast storage like USB drives or SSDs where you want maximum swap capacity.\n\n**🔄 Hybrid (zram + file)**\nCombines both approaches - compressed RAM swap for immediate needs, with writeback storage that allows zram to occasionally move idle pages to disk. This frees up precious zram space for active use while reducing SD card wear through infrequent writes, making it particularly beneficial on memory-constrained systems booting from SD cards. Kernel settings are automatically optimised for low-latency operation with compressed swap devices.\n\n**🚫 No Swap (none)**\nCompletely disables swap functionality. Useful for systems with abundant RAM or specialised applications where swap is not desired. Any existing swap files will be automatically removed.\n\n## What's Included\n\n### rpi-swap (main package)\nThe core swap management system that:\n- Automatically detects your system's memory and storage configuration\n- Creates and manages swap devices during early boot\n- Provides writeback capabilities to occasionally move idle pages from compressed RAM to file-backed storage\n- Replaces the functionality of `dphys-swapfile` with a more modern approach\n\n### rpi-loop-utils (supporting package)\nInfrastructure for reliable loop device management:\n- Creates stable, persistent names for loop devices based on their backing files\n- Ensures loop devices can be reliably referenced in systemd units and scripts\n- Provides the foundation for file-based swap functionality\n\n## Why Replace dphys-swapfile?\n\nWhile `dphys-swapfile` has served Raspberry Pi well, modern systems benefit from:\n\n- **Better memory utilisation**: zram compression uses spare CPU cycles to make better use of your available RAM\n- **Reduced storage wear**: Especially important for SD card longevity\n- **Faster swap performance**: Compressed RAM swap is much faster than disk-based swap\n- **Automatic performance tuning**: Kernel parameters are optimised for low-latency operation with zram devices\n- **Modern systemd integration**: Full integration with systemd's swap.target and service dependencies\n- **Multiple swap mechanisms**: Choose the best approach for your specific hardware and use case\n- **Hybrid capabilities**: Advanced writeback features to optimise memory usage over time\n\n## Configuration\n\nFor most users, rpi-swap works automatically with no configuration required.\n\nAdvanced configuration is available through configuration drop-ins as documented in `swap.conf(5)` and will typically be managed through `raspi-config` in future Raspberry Pi OS releases.\n\n### Making Configuration Changes\n\n**⚠️ Important: After making any changes to swap configuration, you must reboot your system for the changes to take effect.**\n\nWhile `systemctl daemon-reload` will regenerate the systemd units, it won't stop existing swap units or start new ones. The swap generator runs during early boot when memory pressure is minimal - attempting to reconfigure active swap later can cause system instability.\n\nConfiguration files are located at:\n- `/etc/rpi/swap.conf` - Main configuration file\n- `/etc/rpi/swap.conf.d/*.conf` - Drop-in configuration files (recommended for local changes)\n\nFor examples and detailed configuration options, see `man swap.conf`.\n\n## System Requirements\n\n- Raspberry Pi running a systemd-based Linux distribution\n- systemd-zram-generator package (automatically installed as dependency)\n- Modern kernel with zram support (standard in Raspberry Pi OS)\n\n## Status\n\nThis package is designed to be included by default in future Raspberry Pi OS releases as the standard swap management solution, providing better performance and reliability than the current `dphys-swapfile` approach.\n\n---\n\n*For technical documentation, see the included manual pages: `man rpi-swap-generator` and `man swap.conf`*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraspberrypi%2Frpi-swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraspberrypi%2Frpi-swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraspberrypi%2Frpi-swap/lists"}