Zram Magisk — Disable

Here’s a detailed technical write-up on disabling ZRAM using Magisk, covering what ZRAM is, why you might want to disable it, and step-by-step methods to do so safely.


How to Verify it Worked

To confirm that ZRAM has been successfully disabled:

  1. Enable USB Debugging and connect your phone to a PC.
  2. Open a command prompt/terminal and type:
    adb shell
    su
    cat /proc/swaps
    
  3. Result:
    • If ZRAM is enabled, you will see an entry looking like: /dev/block/zram0 ....
    • If ZRAM is disabled, the output should be empty (blank).

Alternatively, you can check free memory using the command free -m or cat /proc/meminfo and look for the "Swap" line; it should show 0 total.

3. Prerequisites: Root and Magisk

Before proceeding, ensure your device meets the following:

Warning: Modifying kernel memory parameters can lead to boot loops if done incorrectly. Always have a backup of your boot image or a way to disable Magisk modules via Safe Mode. disable zram magisk


Alternatively, disable the zram kernel module (if built as module)

6. Re-enabling ZRAM

To revert:

Or, create a simple Magisk module that re-enables it (or just rely on system defaults after removal).

Introduction: What is ZRAM and Why Would You Want to Disable It?

ZRAM is a feature of the Linux kernel (which powers Android) that creates a compressed block device inside your RAM. When your system runs out of physical memory, it compresses old or less-used pages and stores them in this ZRAM space instead of writing them to the slower internal storage (swap file).

In theory, ZRAM is a lifesaver for devices with 2GB–4GB of RAM, allowing more apps to stay open. However, in practice—especially on custom ROMs, gaming-focused setups, or high-RAM devices (8GB+)—ZRAM can cause overheating, CPU throttling, lag, and battery drain due to the constant compression/decompression cycle. Here’s a detailed technical write-up on disabling ZRAM

This is where Magisk—the systemless rooting interface—comes in. Using Magisk, we can disable ZRAM entirely without modifying the system partition. But be warned: Disabling ZRAM on a low-RAM device will cause apps to crash and reload frequently.

Who is this guide for?


Step 1: Verify Your Current ZRAM Status

Open your terminal emulator and type:

su
cat /proc/swaps

You will see output similar to:

Filename                                Type            Size    Used    Priority
/dev/block/zram0                        partition       2097152 102400  100

If you see /dev/block/zram0 (or zram1, etc.), ZRAM is active. The Size is in kilobytes (e.g., 2097152 KB = 2GB).

Alternatively, check ZRAM size with:

cat /sys/block/zram0/disksize

Make a note of the size—you may want to re-enable it later.


Boot loop after installing module

  1. Reboot to Safe Mode (Magisk modules are disabled).
  2. Remove or disable the problematic module via Magisk app.
  3. Alternatively, delete the script from /data/adb/service.d/ using TWRP or ADB.