chkndrp

magisk-swapspace

2.4guide

This module allows for creating a persistent swap space on android

★47 stars
•Performance & Kernel•by chkndrp•GPL-3.0•Updated Nov 1, 2025
Platforms:
✓ Magisk✓ KernelSU

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:
    magiskswap status
    Outputs active swap partition paths, total allocated size, and currently utilized swap bytes.
  • 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

  1. Download magiskswapspace.zip from GitHub releases.
  2. Flash the module in Magisk (v27.0+) or KernelSU (v0.9.4+).
  3. Reboot your device.
  4. Launch Termux, run su -c magiskswap create <size_GB>, and verify with free -m.