Introduction
When it comes to Android customization, there are many things which people try out trying to improve performance of their devices. A simple method to do this is increasing the useable RAM through a SWAP file. However rooting is not required since an alternate method is available through the use of the Termux application which does not require root access. This tutorial will discuss on how to make a swap file on android via Termux without having superuser permission.
So basically a by the end of this tutorial you will be using part of your ROM or storage as Random Access Memory on your android.
Prerequisites:
Termux App
If you have not installed Termux already, install Termux from the Google Play Store or from F-droid this is to ensure you have the latest version.
Terminal Emulator
Learn some of the fundamental terminal emulator’s commands.
Steps to Create a Swap File
1. Install Required Packages:
Open Termux and install the necessary packages by executing the following commands:
pkg update && pkg upgradepkg install proot util-linux termux-tools
This ensures you have the necessary tools to create a swap file.
2. Create a Swap File Script:
Use a text editor within Termux to create a script named createswap.sh:
chmod +x createswap.sh
Think of the script as a set of instructions for the device. In this script, we'll be telling the system to create a swap file.
3. Save and Make Script Executable
nano—to save the script (Ctrl + x, y and enter).
Make the script executable with:
chmod +x createswap.sh
This is giving permission for the script to be executed.
4. Run the Script
Execute the script with
./createswap.sh
The script creates the swap file, which acts as additional virtual RAM.
5. Verify Swap File
Confirm that the swap file is active by running:
cat /proc/swaps
This command shows the Android device current swap usage.
Optional: Make Swap File Persistent
Consider adding the swap file activation into the boot up procedure if you would like it to be enabled after every restart.
1. Edit the bash.bashrc file
Open the file with a text editor:
nano $PREFIX/etc/bash.bashrc
2. Add Swap Activation Line
Insert the following line at the end of the file:
10
/data/data/com.termux/files/home/createswap.sh
3. Save and Exit
save the changes (ctrl + x, y and enter in nano).
How To Increase The RAM Size On Android
You can size the swap file on Termux by changing the count value for dd command in the script. The ‘count’ parameter dictates how many blocks are to be copied at a time, each being ‘bs’ in size. Here's how you can modify the script to set the size of the swap file:
Open the createswap.sh script using the text editor in Termux:
nano createswap.sh
512 times, size 1MB, /data/swapfile dd if=/dev/zero. It creates the swap file through this line.
Set the count to your desired size. Hence, if for instance you need a swap file of 1GB, change count=512 to count=1024. Set count=2048 for a 2GB swap file, and so forth.
dd if=/dev/zero of=/data/swapfile bs=1M count=1024
Ctrl + X; save your changes; Y and ENTER.
After making the changes, you can rerun the script to recreate the swap file with the new size:
./createswap.sh
It is also worth noting that any specified size will never be more than what your device can support. Besides, creating a big swap files can reduce performance as well as consume extra space on your disk. One should always make sure to keep track of their device’s resources and change the swap file size as needed.
If you don't know how to use Termux and want to still Upgrade your android ram watch this video
Conclusion
Congratulations! Congratulations! Creating a swapfile in your android system using Termux without root. It gives an option that other than a root is sought by the users who want to boost their gadget’s performance. Remember however that though this method increases multitasking ability is unlikely more beneficial than physical memory enlargement.
Always take care if you want to make higher-level changes in a system as mistakes an leave a brick in your hand.
Enjoyed this post? Never miss out on future posts on Tech Tutorials Hub by «following us on WhatsApp» or Download our App