Overview
When running resource-intensive Android workloads—such as compiling software in Termux, hosting chroot Linux containers, running heavy emulation, or multitasking across RAM-constrained devices—available physical RAM and zRAM can quickly become exhausted, triggering abrupt Low Memory Killer (LMK) process terminations.
Created by chkndrp, magisk-swapspace is a systemless swap space management utility for rooted Android devices. It provides an intuitive command-line interface (magiskswap) to allocate, format, activate, and manage persistent swap storage on internal flash memory.
Command Reference: magiskswap
Execute commands with root privileges inside Termux or an ADB shell:
su
magiskswap <COMMAND> <VALUE> [OPTIONS]
Common Commands
- Create Swap Space:
# Create a 4 GB swapfile, activate swapon, and persist across reboots magiskswap create 4 - Check Status:
Outputs active swap partition paths, total allocated size, and currently utilized swap bytes.magiskswap status - Tune Swappiness:
# View current kernel swappiness magiskswap swappiness show # Set kernel swappiness to 60 (values 0-200) magiskswap swappiness 60 - Remove Swap:
# Disable and delete the swapfile magiskswap remove # Disable swap while preserving the allocated file on disk magiskswap remove preserve
Flash Wear Consideration
Important: Modern Android devices use UFS or eMMC flash storage chips. Excessive and continuous paging to on-disk swapfiles can accelerate flash memory wear over extended lifespans. It is recommended to use moderate swappiness values and reserve swapfiles for specific memory-heavy scenarios rather than continuous thrashing.
Installation
- Download
magiskswapspace.zipfrom GitHub releases. - Flash the module in Magisk (v27.0+) or KernelSU (v0.9.4+).
- Reboot your device.
- Launch Termux, run
su -c magiskswap create <size_GB>, and verify withfree -m.
