2

I'm using non-rooted phone, how do I disable swap with ADB using swapoff?

It says

swapoff: Needs 1 argument (see "swapoff --help")

Here is swapoff --help

usage: swapoff swapregion

Disable swapping on a given swapregion.

Where to find swapregion?

1
  • 2
    swapoff cannot be run without root (CAP_SYS_ADMIN to be more precise). Commented Jul 17, 2023 at 5:04

2 Answers 2

4

Most Android devices do not have a swap area like typical operating systems do. Instead, Android manages memory differently, using techniques such as zRAM and low-memory killers to manage memory allocation among processes

Having said that, swap may be created by magisk or related modules. To see if it's there:

# cat /proc/swaps
Filename            Type        Size    Used    Priority
/dev/block/vnswap0  partition   2097148 1472552 -1

swapoff <block device path>
swapoff /dev/block/vnswap0

It will most likely give you a resource busy error. Have to run it at boot-time.

Useful references: Stack Overflow - Swapon failed trying to enable zram.

1

At least since Pie, it may be possible to disable swap with:

adb shell settings put global zram_enabled 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .