Has your smartphone started to slow down when multitasking? Applications suddenly close and the system issues warnings about low memory? The solution may be hidden in the creation Android started to slow down when multitasking? Applications suddenly close and the system issues warnings about low memory? The solution may lie in creation swap file (swap). This mechanism, borrowed from desktop OSes, allows you to use part of the internal memory or SD card as additional RAM (RAM). But before you start setting up, it is important to understand: swap to Android is not a panacea, but a temporary solution for devices with 1โ€“2 GB of RAM or outdated models.

B In this article we will look at:

  • ๐Ÿ”น What is a swap file and how it works Android.
  • ๐Ÿ”น Pros and cons using swap on mobile devices.
  • ๐Ÿ”น Step-by-step guide for devices with root-rights and without them.
  • ๐Ÿ”น Optimal settings size and location of the swap file.
  • ๐Ÿ”น How to remove swap file, if it did not help or caused problems.

We'll warn you right away: on modern flagships with 6+ GB RAM swap more often harms than helps - due to the slow read/write speed of flash memory compared to RAM. But for budget smartphones or tablets with Android 7โ€“10 this can be a salvation.

๐Ÿ“Š How much RAM does your Android device have?
1โ€“2 GB
3โ€“4 GB
5โ€“6 GB
8 GB or more

What is a page file and why do you need it on Android

A page file (swap) is a backup storage area that the operating system uses as a virtual RAM. When there is not enough physical RAM, Android moves little-used data there, freeing up resources for active processes. The technology has long been used in Linux (and Android built on its core), but on mobile devices it has nuances.

In practice, swap on Android works like this:

  1. The system monitors the load RAM.
  2. When a critical threshold is reached (usually 70โ€“80%) it transfers inactive processes to swap.
  3. If necessary, the data is loaded back into RAM, but this takes time and loads the drive.

The main difference from desktop PCs: on smartphones, swap is created not on fast SSD, but on slow eMMC/UFSmemory. Therefore using swap on devices with 4+ GB RAM often leads to the opposite effect - slowdown due to constant I/O operations.

๐Ÿ’ก

On Android 11+ Google has implemented its own technology zRAM (RAM compression), which is more efficient than swap. Check if it is enabled in the developer settings (Settings โ†’ System โ†’ For developers โ†’ zRAM).

Pros and cons of using swap on Android

Before creating a swap file, evaluate its advantages and risks. Swap is not always justified - especially on new ones devices.

Advantages Disadvantages
โœ… Increases the number of simultaneously running applications on weak devices. โŒ Accelerates wear of flash memory (especially on cheap smartphones with eMMC).
โœ… Allows you to "reanimate" old devices with 512 MBโ€“1 GB RAM. โŒ May cause lags during intensive use due to slow read/write speed.
โœ… Free solution (does not require purchasing a new one phone). โŒ Requires rootrights for full setup (without them efficiency is lower).
โœ… Useful for running "heavy" games (for example, Genshin Impact on weak devices). โŒ Not all applications work correctly with swap (crashes are possible).

You should be especially careful with swap on devices with SD cards. Even the class A2 does not guarantee stable operation - the random read/write speed (IOPS) of memory cards is several times lower than that of memory cards. built-in storage. If you still decide to use SD, choose models with support UHS-I and a capacity of at least 32 GB.

โš ๏ธ Attention: On some firmware (for example, MIUI or ColorOS) swap may conflict with built-in memory optimization mechanisms. Before setting, disable functions like "Accelerating games" or "Deep cleaning" in the battery settings.

Device preparation: what needs to be done before creating swap

For the page file to work correctly, complete the preliminary steps:

Check free space (minimum 1-2 GB)

Disable automatic memory cleaning in settings

Back up important data

Charge the phone to 50% or more

Install a file manager with root access (for example, Root Explorer)

-->

If you plan to use SD card data-i="132">For devices, format it in ext4 or f2fs (via TWRP or ADB).The file system FAT32/exFAT is not suitable - swap will not work on them. Also make sure that the card is not used for Adoptable Storage (built-in storage), otherwise the system will block access.

For devices without root the possibilities are limited. You can only create swap on SD card (if it is supported) or in the internal memory through the terminal, but without superuser rights the efficiency will be minimal. In most cases, it is better to consider alternatives:

  • ๐Ÿ”ธ Disable background processes manually (Settings โ†’ Applications โ†’ Running).
  • ๐Ÿ”ธ Use light versions of applications (Facebook Lite, Messenger Lite).
  • ๐Ÿ”ธ Enable zRAM in the developer settings (if available).
โš ๏ธ Attention: On Android 12+ Google has tightened its security policy, and many methods for creating swap without root have stopped working. If your device was updated over the air, check the kernel version using the command uname -a in the terminal - some custom kernels. block swap.

Creating a swap file on Android with root access

If you have root, the process of setting up swap is simplified. We will consider two methods: through the terminal and using specialized applications.

Method 1: Manually creating swap via terminal

This method is suitable for advanced users. You will need:

  • ๐Ÿ“ฑ A device with root and an unlocked bootloader.
  • ๐Ÿ’ป Terminal application (Termux or built-in ADB Shell).
  • ๐Ÿ“ File manager with root access (FX File Explorer, Solid Explorer).

Steps:

  1. Open a terminal and enter the command to create a swap file (for example, size 512 MB):
    su
    

    dd if=/dev/zero of=/sdcard/swapfile bs=1M count=512

  2. Configure access rights:
    chmod 600 /sdcard/swapfile
  3. Format the file as swap:
    mkswap /sdcard/swapfile
  4. Activate swap:
    swapon /sdcard/swapfile
  5. Check that swap works:
    free -m

    (should appear in the output line Swap with a non-zero value).

To enable swap automatically at boot, add the line /sdcard/swapfile none swap sw 0 0 to the file /etc/fstab (recommended via TWRP or Magisk).

How to check the speed of an SD card before creating a swap?

Use the application A1 SD Bench (free in Google Play). Optimal indicators for swap:

- Reading speed: โ‰ฅ20 MB/s

- Write speed: โ‰ฅ10 MB/s

- IOPS (4K random read/write): โ‰ฅ500

If your card does not reach these values, swap will slow down system.

Method 2: Applications for managing swap

To simplify the process, you can use specialized utilities:

  • ๐Ÿ”ง SwapEnabler (requires Magisk) - allows you to flexibly configure the swap size and priorities.
  • ๐Ÿ”ง Swapper for Root - supports automatic enable on boot.
  • ๐Ÿ”ง Kernel Adiutor โ€”advanced kernel settings, including swap.

Example settings in SwapEnabler:

  1. Install the module via Magisk Manager.
  2. Run the application and select Create Swap File.
  3. Specify the size (recommended 1โ€“2 GB for devices with 1โ€“2 GB RAM).
  4. Select location (internal memory or SD card).
  5. Activate swap and reboot the device.
๐Ÿ’ก

The optimal swap size is 1.5โ€“2 times the amount of RAM, but no more 2 GB (due to file system limitations Android).

Creating swap without root: possible options

Without superuser rights, a full-fledged swap cannot be configured, but there are workarounds. Their effectiveness is lower, and the risks are higher - for example, failures may occur when updating the system.

Method 1: Using an SD card (only for older versions Android)

This method worked on Android 5โ€“7, but on new versions it is often blocked. Procedure:

  1. Format SD card in ext4 via TWRP (if installed).
  2. Connect the phone to the PC and create a swap file via ADB:
    adb shell
    

    su -c "dd if=/dev/zero of=/storage/extSdCard/swapfile bs=1M count=1024"

    su -c "mkswap /storage/extSdCard/swapfile"

    su -c "swapon /storage/extSdCard/swapfile"

  3. Check the result with the command free -m.

On Android 8+ this method is most likely will not work due to restrictions SELinux and mounting policy SD cards. An alternative is to use applications like ROEHSOFT RAM-EXPANDER, but they require root for full operation.

Method 2: Emulate swap via zRAM

If swap cannot be configured, activate zRAM a compression technology RAMwhich is more effective than traditional swap:

  1. Enable developer mode: go in Settings โ†’ About phone and click on "Build number".
  2. Return to main settings, open "For developers".
  3. Find the option "zRAM" or "Memory compression" and activate it.
  4. Set the size of the compressed space (recommended 20โ€“30% from volume RAM).

zRAM does not require root on most firmware and does not load the drive, since it works directly with RAM. However, it is less efficient on devices with 1 GB RAM and lower.

โš ๏ธ Attention: On some devices (Samsung, Xiaomi) the zRAM option may be hidden. To unlock it, run the ADB command:
adb shell setprop persist.sys.zram.enabled true

After that, reboot the phone.

File optimization swap: size, location, kernel settings

Even a correctly created swap can work ineffectively if its parameters are not optimized.

1. Choosing the swap size

The size of the swap file depends on the size RAM and scenarios. usage:

RAM volume Recommended swap size Notes
512 MB - 1 GB 1โ€“1.5 GB Optimal for older smartphones (Samsung Galaxy S3, HTC One M7).
2 GB 512 MB - 1 GB A larger swap can cause lags due to slow memory.
3โ€“4 GB 256โ€“512 MB Swap is only needed to run heavy games (PUBG, Call of Duty).
6 GB or more Not recommended Swap will do more harm than good.

2. Swap file location

Location priority:

  1. Internal memory (/data) - the fastest option, but reduces free space.
  2. SD card (class A2/UHS-I) - suitable for devices with a small amount of built-in memory.
  3. External USB drive (via OTG) - highly not recommended due to low speed.

If you choose SD card, give preference to models with high IOPS (for example, Samsung EVO Plus or SanDisk Extreme). Avoid cheap cards without class markings - they will quickly fail.

3. Kernel settings for swap

For fine-tuning, use applications like Kernel Adiutor or FrancoKernel. data-i="284">โ€” determines how actively the system uses swap. Optimal value:

  • ๐Ÿ”น vm.swappiness โ€” determines how actively the system uses swap. Optimal value: 60โ€“80 (default 60).
  • ๐Ÿ”น vm.vfs_cache_pressure โ€” controls cache cleaning. Recommended 50โ€“100.
  • ๐Ÿ”น vm.dirty_ratio โ€” percentage of "dirty" memory pages at which disk writing begins. Optimal: 10โ€“20.

You should only change these parameters if you understand the consequences. Incorrect settings can lead to constant lags or even bootloop (loop loading).

๐Ÿ’ก

On devices with eMMC 5.0 and below swap reduces the service life of the drive by 10โ€“15% with intensive use. If the phone is older than 3 years, the risk is justified only for critical tasks.

How to delete the swap file if it is not needed

If swap did not bring the expected effect or caused problems, it must be disabled and deleted. depends on the creation method.

Disable swap via terminal

Run commands:

  1. Disable swap:
    su
    

    swapoff /path/to/swapfile

  2. Delete file:
    rm /path/to/swapfile
  3. Delete the entry from /etc/fstab (if added).

Deleting swap created through applications

For applications like SwapEnabler:

  1. Open the application and select "Disable Swap".
  2. Reboot the device.
  3. Delete the page file manually through the file manager.
  4. Deactivate the module in Magisk (if used).

After removing swap, check the free space and performance. If the system begins to work more stable, it means that swap was indeed redundant.

โš ๏ธ Attention: If after disabling swap the device stops booting, most likely the problem is a damaged swap file or a conflict with the kernel. Restore functionality via TWRPby deleting the file manually or rolling back the file. firmware.

Frequently asked questions

โ“ Is it possible to create a swap on Android without root?

Technically yes, but with serious limitations On Android 5โ€“7 you can try to create it. swap on SD card. data-i="324">โ“ What swap size to choose for a phone with 2 GB RAM? via ADB, but on new versions this is blocked. An alternative is to activate zRAM (does not require root). The effectiveness of swap without superuser rights is minimal.

โ“ What swap size should I choose for a phone with 2 GB RAM?

The optimal size is 512 MB - 1 GB. A larger volume may cause lags due to the slow read/write speed of flash memory, try 1 GB, but watch out. performance.

โ“ Will swap work on an A1 class SD card?

Technically yes, but the speed will be extremely low. For swap, class is recommended. A2 or UHS-I with a minimum write speed 10 MB/s. Class cards A1 are only suitable for storing files, but not for paging operations.

โ“ Is it possible to use swap on smartphones with eMMC 5.1?

It is possible, but with reservations. Memory eMMC 5.1 is faster eMMC 5.0, but it is still inferior UFS 2.0+If your device is new (released after 2018), it is better to refuse swap. in favor zRAM or optimization of background processes.

โ“ Why did the phone start to slow down after creating swap?

Probable reasons:

  • ๐Ÿ”ธ Swap size is too large (optimally - no more than 2 GB).
  • ๐Ÿ”ธ Slow SD card (lower class A2).
  • ๐Ÿ”ธ Conflict with built-in optimization mechanisms (for example, MIUI Optimization).
  • ๐Ÿ”ธ Incorrect kernel settings (vm.swappiness above 80).

Try to reduce swap or disable it completely.