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.
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:
- The system monitors the load RAM.
- When a critical threshold is reached (usually
70โ80%) it transfers inactive processes to swap. - 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
zRAMin 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:
- Open a terminal and enter the command to create a swap file (for example, size
512 MB):sudd if=/dev/zero of=/sdcard/swapfile bs=1M count=512 - Configure access rights:
chmod 600 /sdcard/swapfile - Format the file as swap:
mkswap /sdcard/swapfile - Activate swap:
swapon /sdcard/swapfile - Check that swap works:
free -m(should appear in the output line
Swapwith 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:
- Install the module via Magisk Manager.
- Run the application and select
Create Swap File. - Specify the size (recommended
1โ2 GBfor devices with1โ2 GB RAM). - Select location (internal memory or SD card).
- 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:
- Format SD card in
ext4via TWRP (if installed). - Connect the phone to the PC and create a swap file via ADB:
adb shellsu -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" - 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:
- Enable developer mode: go in
Settings โ About phoneand click on "Build number". - Return to main settings, open "For developers".
- Find the option "zRAM" or "Memory compression" and activate it.
- 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 trueAfter 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:
- Internal memory (
/data) - the fastest option, but reduces free space. - SD card (class
A2/UHS-I) - suitable for devices with a small amount of built-in memory. - 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(default60). - ๐น
vm.vfs_cache_pressureโ controls cache cleaning. Recommended50โ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:
- Disable swap:
suswapoff /path/to/swapfile - Delete file:
rm /path/to/swapfile - Delete the entry from
/etc/fstab(if added).
Deleting swap created through applications
For applications like SwapEnabler:
- Open the application and select "Disable Swap".
- Reboot the device.
- Delete the page file manually through the file manager.
- 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.swappinessabove80).
Try to reduce swap or disable it completely.