INTRODUCTION
This document describes a procedure for installing Ubuntu 11.10 Oneiric Ocelot onto your Android device to run alongside an existing Android rom. My instructions assume you are running CyanogenMod 7. I will try to provide workarounds for other roms.
Ubuntu on a mobile device, running alongside Android, is somewhat difficult to use and is useless for most users. You should not attempt this procedure unless you have a need to run arbitrary Linux software from a mobile device. Many mobile computing needs can be met by installing remote access software on a traditional desktop computer. Conversely if you find the idea of having a general purpose Linux system in your pocket to be freaking awesome, whether you need it or not, please read on.
CAUTION
The following procedure assumes familiarity with Linux fundamentals, and basic familiarity with Android's Linux underpinnings. Data loss is possible, especially for the data on your SD card, so please make backups. Some commercial Android software is recommended, specifically Tasker and Better Terminal Emulator Pro. A large, fast SD card is also recommended. (I <3 my PNY 32 GB class 10 card)
Some optional steps are proposed that may interfere with how your Android device manages its SD card. You may be required to manually run a script before certain Android features, like mounting your device's SD card on a desktop PC via USB cable, will function properly.
Each step will have, whenever possible, a recommended procedure and one or more alternative procedures. If the recommended procedure doesn't work for you, the alternative procedure might require some research, manual-page reading, or other outside assistance to accomplish.
Shell commands should be executed on a root shell on your Android device. Use the built-in Terminal Emulator, ConnectBot in local mode, Better Terminal Emulator Pro, "adb shell" from a connected PC, or your favorite terminal emulator.
OVERVIEW
Too long; didn't read? Here's a quick summary of the steps involved:
Partition your SD card, creating a 2 GB or 4 GB Linux partition
Confirm the new partition is mounted at /sd-ext
Unpack http://cdimage.ubuntu.com/ubuntu-core/daily/current/oneiric-core-armel.tar.gz to /sd-ext
Create an empty file /sd-ext/.nomedia
Edit /system/etc/init.d/05mountsd to bind proc, dev, and sys to /sd-ext
Optionally edit /system/etc/init.d/05mountsd to bind /data, /system, and /cache to /sd-ext/mnt
Prepare a script to open a chroot shell with correct environment variables
Update /etc/apt/sources.list and /etc/resolv.conf according to your preference
Overwrite /sbin/start with /sbin/true
Copy or link important files into /etc and /lib
Initialize the package manager and begin downloading packages
(optional) Integrate Ubuntu services with Tasker profiles
STEP 1: Partition your SD Card
While a basic Ubuntu system can be installed in as little as 200 MB of disk space, many software packages require more space. Also many Linux tasks require unusual file attributes, permissions, or types, which cannot be placed on your SD card's regular FAT32 / VFAT file system.
Recommended: Use an existing Ubuntu system, or even an Ubuntu live CD, and a USB card reader to repartition your SD card without losing any data. Be sure the first primary partition remains FAT32 / VFAT, and create a second primary partition of type ext3 or ext4.
Alternative 1: Use any desktop system to back up all of the data on your SD card, either with a card reader or using your Android device. Use your phone's recovery partition to destructively repartition your SD card with a 2 or 4 GB ext3 or ext4 partition, and NO swap partition. Then copy your SD card contents back to your SD card.
Alternative 2: If you don't want to partition your SD card, you can create large empty files on your SD card and mount those. Some of the later steps will work differently and you may have to improvise.
Create large empty files on your SD card to contain your Ubuntu filesystem: dd if=/dev/zero of=/mnt/sdcard/UBUNTU.IMG bs=32768 count=65536
Identify a free loopback device number that isn't currently in use and won't likely be occupied by Android Apps2SD in the future: ls /dev/block
Create a new loop device for your file. Note the first number is the loop filename number you observed wasn't in use (at least a few dozen higher than the highest number you see), then a b and a 7, and then a number one less than the filename number. For example: mknod /dev/block/loop200 b 7 199
Associate the loop device with your new empty file: losetup /mnt/block/loop200 /mnt/sdcard/UBUNTU.IMG
Find which versions of mkfs are on your system: ls /system/xbin/mkfs*
Using whatever version you have (ext4 or ext3 preferred, but ext2 is acceptable) run: mkfs.ext# /dev/block/loop200
Save these commands in a script for later use. The dd and mkfs commands were only used this once, but the mknod and losetup commands will have to be run manually from a script each time you boot your phone.
STEP 2: Mount your Linux Partition
To avoid causing problems for your Android system, we shouldn't tamper with any of Android's critical files or directories. We will mount our Linux partition in a new directory that Android isn't using. With any luck, our rom already contains scripts that will automatically mount this for us.
Recommended: If you have partitioned your SD card and you are running CyanogenMod 7, use a root shell or file manager to confirm /sd-ext contains at least a directory called lost+found. If lost+found is present in /sd-ext then this step is done and you should continue to step 3.
Alternative 1: Use a root shell to navigate to /etc/init.d and look for a file called 05mountsd. If that file doesn't exist, you may need to create it or use another alternative method. If it does exist, run it with ./05mountsd and observe any error messages. If fsck or mount are failing because the filesystem type doesn't match what was expected, you can edit the file and change the filesystem type in the script.
Hint: you can do a quick search-and-replace using sed and a regular expression:
Code:
mv 05mountsd 05mountsd-old
cat 05mountsd-old | sed -e s/ext3/ext4/ > 05mountsd
diff 05mountsd-old 05mountsd
#changes look good to you? then proceed:
rm 05mountsd-old
ls -al
chown root.shell 05mountsd
chmod 750 05mountsd
#adapt owner (root), group (shell) and permissions (-rwxr-x---) to match the other files in that directory
Alternative 2: If your rom doesn't create, or attempt to mount, anything called /sd-ext you might have to create your own mount point.
Code:
mount -o remount,rw /system
mkdir /system/sd-ext
mount -o remount,ro /system
Then, in the following steps, replace any reference to /sd-ext with /system/sd-ext.
STEP 3: Install the Base System
Recommended: Download this file: http://cdimage.ubuntu.com/ubuntu-core/daily/current/oneiric-core-armel.tar.gz (Should be under 32 MB, and is the only potentially-insecure download required because the file is unsigned.)
Store it on your SD card somewhere, like in /mnt/sdcard/download/. (If you use your Android device's browser, it will probably land there automatically.)
If you're nervous about making a mistake, double-check your system partition is read-only:
Code:
mount | grep -v block/dm- | grep \(rw
#If anything there looks like it shouldn't be read-write, make it read-only:
mount -o remount,ro /system
Open a root shell and navigate to /sd-ext. Use pwd (present working directory) to confirm you really are in /sd-ext. Then go ahead and unpack:
Code:
tar zxvf /mnt/sdcard/download/oneiric-core-armel.tar.gz
STEP 4: Create a .nomedia file
Android may try to scan your Linux partition for images, videos, and pictures. The Linux partition contains many files and directories and this scan can take a long time. To avoid these lengthy scans, we will add a file to the Linux partition that blocks well-behaved Android services from scanning.
Recommended: Use a root shell to navigate to /sd-ext. Create the file and set its permissions:
Code:
echo > .nomedia
chown root.root .nomedia
chmod 644 .nomedia
STEP 5: Bind /proc, /dev, and /sys to the Linux partition
Recent versions of Linux provide a way to clone a partition, so when changes are made to one copy of the partition the changes take effect immediately in the other copy. We will use this to make the /proc, /dev, and /sys partitions used by Android available in our Linux partition as well.
This is necessary because when we run Ubuntu we will be using chroot (change root) to make /sd-ext the only filesystem Ubuntu can see. Ubuntu will need to be able to see /proc, /dev, and /sys, as well as some of the files in /etc, /vendor/lib, and /system/lib. We will meet some of these needs with mount --bind
Additionally we will need these bindings to be recreated every time the /sd-ext partition is mounted. So we will add some commands to the run-parts script that mounts /sd-ext, located at /etc/init.d/05mountsd.
Recommended: Open a root shell and navigate to /etc/init.d, and use a text editor to open 05mountsd.
Near the end of the file you should see some commands that operate on /sd-ext:
Code:
$BB chown 1000:1000 $SD_EXT_DIRECTORY;
$BB chmod 770 $SD_EXT_DIRECTORY;
Edit the chmod command and change the permission mask number from 770 to 775, which grants non-root users the ability to read the contents of that directory. Then add the following commands immediately after the chown and chmod commands already present:
Code:
$BB mount --rbind /dev /sd-ext/dev
$BB mount --rbind /proc /sd-ext/proc
$BB mount --rbind /sys /sd-ext/sys
STEP 6: (OPTIONAL) Bind /system, /data, and /cache to /sd-ext
This step is optional, and provides a way to operate on Android system files from within Ubuntu. If you're concerned about a stray command destroying your Ubuntu system and you want to make sure it doesn't take any Android system files with it, you should skip this step.
Recommended: Open a root shell and navigate to /sd-ext/mnt, and create some directories which will serve as mount points:
Code:
pwd
# you should be in /sd-ext/mnt
mkdir -m 700 system data cache
chown root.root system data cache
ls -al
# Each of system, data, and cache should show drwx------ and root for both owner and group
Then navigate to /etc/init.d and edit 05mountsd. Add the following under the existing mount --rbind commands you added earlier:
Code:
$BB mount --rbind /system /sd-ext/mnt/system
$BB mount --rbind /data /sd-ext/mnt/data
$BB mount --rbind /cache /sd-ext/mnt/cache
STEP 7: Prepare a script to open a chroot shell with proper environment variables
Now you will need an easy way to create a first process, a shell, in the new environment you've created. This shell will start life in a different world than regular Android shell processes live in: it will use a different root filesystem and will be able to see different files and directories, and it will have access to a vast number of full-featured programs and services.
We will be using the Bourne Again Shell, bash. We will launch bash with a program called env, which sets some environment variables and then launches a program with that new environment. Finally, we will be launching env with a program called chroot, which changes the root filesystem seen by a program before it launches it.
Option 1: Better Terminal Emulator Pro: I don't want to say "recommended" because it involves buying software that's not really necessary. I'm partial to Better Terminal Emulator Pro because it seems to have more available options (compared to the built-in Terminal Emulator) and it doesn't kill your shell unexpectedly when network connectivity changes (unlike ConnectBot). I'm not affiliated with the author of that software. Also, after I bought that I stopped looking for alternative shells, so there may exist other alternative shells that work better for this.
Use Better Terminal Emulator Pro and add the commands necessary for starting your chroot shell to BTEP's options. Once you do this, BTEP will essentially be a dedicated Ubuntu console for you, and may be difficult to use for other tasks.
My settings are:
Shell: Android Shell
Command Line: /system/bin/sh
Initial Command:
Code:
/system/xbin/chroot /sd-ext /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM=linux /bin/bash -l; exit
clear
Start as root: yes
Option 2: Terminal Emulator, and a shell script: Open a root shell and create a file:
Code:
#!/system/bin/sh
/system/xbin/chroot /sd-ext /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM=linux /bin/bash -l
exit
Save the file with whatever name you like, perhaps "ubuntu", and put it somewhere in your path. You could add it to /system/bin: mount -o remount,rw /system; mv ubuntu /system/bin/ubuntu; mount -o remount,ro /system
Option 3: ConnectBot: I don't recommend ConnectBot for this because, while it does offer "local" connection types, if your connectivity changes (even wifi to cell) it will close your "connection" immediately.
That said: create a new connection with type local, and give it the following initial command:
Code:
su -
/system/xbin/chroot /sd-ext /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM=linux /bin/bash -l; exit
clear
STEP 8: Update /etc/apt/sources.list and /etc/resolv.conf
Ubuntu uses a package manager which automatically finds, downloads, verifies, and installs software for you. The package manager requires a list of trusted repositories which contain binaries built for ARM CPUs, like the one in your Android device.
FIXME: Later I'll discuss the pros and cons of each of these selections. For now I'll just provide my sources.list file.
Open your Ubuntu shell, using the method from step 7, and issue the following commands:
Code:
echo nameserver 8.8.8.8 > /etc/resolv.conf
# you can use a nameserver of your choice if you like.
echo nameserver 8.8.4.4 >> /etc/resolv.conf
# notice the >> instead of > which means we're appending, not overwriting.
apt-get install nano
# follow the prompts - say yes if it asks if you want to proceed.
nano -w /etc/apt/sources.list
And here are the contents of my sources.list file, containing binary sources for ARM CPUs:
Code:
deb http://ports.ubuntu.com/ubuntu-ports/ oneiric main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ oneiric-security main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ oneiric-updates main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ oneiric-backports main restricted universe multiverse
deb http://archive.canonical.com/ oneiric partner
deb http://archive.canonical.com/ oneiric-security partner
deb http://archive.canonical.com/ oneiric-updates partner
deb http://archive.canonical.com/ oneiric-backports partner
STEP 9: Overwrite /sbin/start with /sbin/true
Nothing too complicated here. Some Ubuntu packages install services, which the system will usually want to automatically start and end when the system boots and shuts down.
However, on an Android device Android is responsible for booting and shutting down the system, and it doesn't know much about Ubuntu services.
Later (FIXME: when?) we'll discuss how to use an Android program like Tasker to more intelligently manage Ubuntu services. But for now, we need to trick Ubuntu's package installation scripts into believing it has successfully started a service. We will use a useless program called true, which does nothing and reports that it was successful, in place of a program called start, which will be unable to start a service because it has no access to Android's init system.
Open your Ubuntu shell and do this: cp /sbin/true /sbin/start
STEP 10: Copy or link important files into /etc and /lib
FIXME: I haven't finished this section yet. Some of my software remains broken until I fix this.
STEP 11: Initialize the package manager and begin downloading packages
Now we can begin using our Ubuntu system's package manager to install any other packages we might need.
Open your Ubuntu shell and do the following:
Code:
apt-get update
# This will take a short while, and will download updated software catalogs from each of the update servers
apt-get upgrade
# This looks for updates to any currently-installed packages. There aren't many packages installed so this should be quick.
apt-get install PACKAGE NAMES GO HERE
Then keep using apt-get install to install whatever you need.
Here are some common packages and package sets:
ubuntu-dev-tools: development tools including a compiler and linker
tightvncserver: simple X server you can connect to with androidVNC
FIXME: I need to put a lot more here.
Sorry for bumping old threat, but I am kind of stuck. Everything goes fine, but when I try to create the script in BTEP (and android terminal) I am getting segmentation fault in both of them.
Checked for syntax errors 100 of times. I am using CM6 froyo 2.2 on Motorola milestone. SD card has 2 gb of ext3 partition mounted in /sd-ext.
*EDIT*
Reflashed CM 7 latest and same thing happens. Segmentation Fault.
This is a tutorial for setting up crontab on Samsung Galaxy Note II. This is intended for native unix users to be able to use cron on their phones for scheduling various tasks such as reminders, backups, scheduled reboots, wifi on-off, etc.
Installation Instructions:
What you need:
Rooted Galaxy Note II with latest busybox installed
Ability to run scripts at startup [not required if you are willing to manually start crond every time you reboot.]
Step 1: Create a directory /data/root, and create a text file name root inside it. Your cron entries should go inside /data/root/root.
Step 2: Download the attached crontab.sh and place it in your mobile phone. You need to execute this script on startup. So if you have /etc/init.d folder, please it there. If you dont, you should contact your dev to check if your rom supports executing user scripts on startup.
Step 3: Understanding the (attached) script.
Any unix program including crontab references a users details from the /etc/passwd file. So we create a passwd file with root user's credentials. (Android does not have this by default).
Crontab is a compiled binary that looks for sh shell in the directory /bin/sh - a standard for unix. Unfortunately bin directory is inside /system in our phones, so we symlink it.
Set Timezone. TZ variable is sources by crontab to know the local timezone. Please modify the script to set it according to your location.
And finally, crond -c /data/root will start cron daemon on your phone sourcing crontab files from /data/root directory.
Step 4: Write your crontab file (Below is a typical crontab file). Please visit this link for an awesome tutorial on crontab.
Code:
[B][email protected]:/data/root # cat /data/root/root[/B]
# Script to make sure crontab is running
* * * * * echo "Crontab last ran on `date`" >> /storage/sdcard0/.crontab
# Script to backup whatsapp databases at 5 am everyday.
0 5 * * * cp /data/data/com.whatsapp/databases/* /storage/extSdCard/backups/whatsapp/
### FREQUENTLY ASKED QUESTIONS ###
How to make sure it is working
In terminal - type pgrep -l crond (lower case L). If it return a process id and command name, crontab is running. If you see more than one "crond" running, it is likely that executed your script twice. kill the other script using command kill -9 <process id>
[*]My tasks are executing twice
Please re-read FAQ #1.
[*]It stopped working after i rebooted my phone.
You are probably not executing this script on startup. Reread this thread properly again.
kkoolpatz said:
This is a tutorial for setting up crontab on Samsung Galaxy Note II. This is intended for native unix users to be able to use cron on their phones for scheduling various tasks such as reminders, backups, scheduled reboots, wifi on-off, etc.
Installation Instructions:
What you need:
Rooted Galaxy Note II with latest busybox installed
Ability to run scripts at startup [not required if you are willing to manually start crond every time you reboot.]
Step 1: Create a directory /data/root, and create a text file name root inside it. Your cron entries should go inside /data/root/root.
Step 2: Download the attached crontab.sh and place it in your mobile phone. You need to execute this script on startup. So if you have /etc/init.d folder, please it there. If you dont, you should contact your dev to check if your rom supports executing user scripts on startup.
Step 3: Understanding the (attached) script.
Any unix program including crontab references a users details from the /etc/passwd file. So we create a passwd file with root user's credentials. (Android does not have this by default).
Crontab is a compiled binary that looks for sh shell in the directory /bin/sh - a standard for unix. Unfortunately bin directory is inside /system in our phones, so we symlink it.
Set Timezone. TZ variable is sources by crontab to know the local timezone. Please modify the script to set it according to your location.
And finally, crond -c /data/root will start cron daemon on your phone sourcing crontab files from /data/root directory.
Step 4: Write your crontab file (Below is a typical crontab file). Please visit this link for an awesome tutorial on crontab.
Code:
[B][email protected]:/data/root # cat /data/root/root[/B]
# Script to make sure crontab is running
* * * * * echo "Crontab last ran on `date`" >> /storage/sdcard0/.crontab
# Script to backup whatsapp databases at 5 am everyday.
0 5 * * * cp /data/data/com.whatsapp/databases/* /storage/extSdCard/backups/whatsapp/
### FREQUENTLY ASKED QUESTIONS ###
How to make sure it is working
In terminal - type pgrep -l crond (lower case L). If it return a process id and command name, crontab is running. If you see more than one "crond" running, it is likely that executed your script twice. kill the other script using command kill -9 <process id>
[*]My tasks are executing twice
Please re-read FAQ #1.
[*]It stopped working after i rebooted my phone.
You are probably not executing this script on startup. Reread this thread properly again.
Click to expand...
Click to collapse
Interresting indeed,
Will digg this based on your informations, thank you
thx, can confirm it`s working on cm7.
I want to make a script which will allow me to mount (mount bind) one folder to another folder.
I need this way to work with my navigation and to switch maps folder.
When I try with adb shell this commands - everything is fine:
Code:
mount -o rbind /mnt/sdcard/Sygic/Maps.NT /mnt/sdcard/Sygic/Maps
Next I made a script:
Code:
#!/system/bin/sh
#umount -l /sdcard/Sygic/Maps
mount -rw -o rbind /mnt/sdcard/Sygic/Maps.NT /mnt/sdcard/Sygic/Maps
am start -a com.sygic.aura -n com.sygic.aura/com.sygic.aura.SygicNaviActivity
exit 0
That point forward started problems - can't start this script, never mind if it's on SDCard or /system/app or where else (perm. rw-r-r-)
After that tried SManger - won't work neither like executable as root or script as root
Last try was to make brand new script within SManger, made it simplest like only one row:
Code:
mount -o rbind /mnt/sdcard/Sygic/Maps.NT /mnt/sdcard/Sygic/Maps
or
Code:
/sbin/mount -o rbind /sdcard/Sygic/Maps.NT /sdcard/Sygic/Maps
but w/o success
I need help, how to make this mount within script, will prefer SM Widget to start one or another mount.
Need advice, thanks to anyone !
You may have applied V6 Supercharger to your phone. And after reboot, you stuck at the boot splash. Reboot once and V6 Supercharger install script tell you that you aren't supercharged. Here is how to fix it. (If you get looped in boot animation, this is NOT your fix. Sorry!)
Depend on your rom, you may have to do one of following:
Open the (rooted) File Manager, open the directory /etc/init.d/ and open file 99SuperCharger. OR
Turn on ADB on your phone, use your computer to pull the file /etc/init.d/99Supercharger by running
Code:
adb pull /etc/init.d/99SuperCharger
Edit the file at the almost bottom of the file, change the following code:
Code:
if [ "`ps | grep -m 1 [a]ndroid`" ]; then HellzYeah;
else HellzYeah &; fi;
To look like this:
Code:
if [ "`ps | grep -m 1 [a]ndroid`" ] || [ $1 = "bypass" ]; then HellzYeah;
else
rm $bootloopcookie
$0 bypass &
fi;
Depend on what you have done on step 1, do the following:
If you use (root) file manager, save the file. Grant the superuser permission if needed. Then browse to /data and delete file !!SuperChargerBootLoopMessage.log. Don't worry if it's not exist.
If you use your computer to edit your file, run the following command:
Code:
adb root
adb remount
abd push /path/of/99SuperCharger /etc/init.d/99SuperCharger
adb shell
And inside the adb shell, run:
Code:
chmod 755 /etc/init.d/99SuperCharger
rm /data/!!SuperChargerBootLoopMessage.log
exit
Don't worry if file /data/!!SuperChargerBootLoopMessage.log doesn't exist.
And that's it! The V6 Supercharger bootscript is worked as it's designed to. Thanks to zeppelinrox to make this great script.
For one who want to know some technical info (and my assumption of the cause), wait me until tomorow and i'll explain how i found it. read on:
In order to run script in /etc/init.d at boot, the line like this is inserted in init.rc:
Code:
on boot
...
# Start the init.d service
exec /system/bin/sysinit
(In case of cm - for example)
But, what does the /system/bin/sysinit do? Just this:
Code:
#!/system/bin/sh
export PATH=/sbin:/system/sbin:/system/bin:/system/xbin
/system/bin/logwrapper /system/xbin/run-parts /system/etc/init.d
And this is the real source of problem. For some reason run-parts with logwrapper doesn't move on when you run a shell script function in background. If you scroll up in file 99SuperCharger, you'll found that "HellzYeah" is actually a function. And when it's execute in a boot process, "HellzYeah" will wait for boot process to continue. But run-parts (and the whole boot process) is waiting for the script to finish. You see? A deadlock!
The workaround is to execute function in the other way. What my modification do is re-executing the script with the parameter "bypass" in the background. This way, run-parts will not wait for it anymore. Then, when the script is re-executed, it will detect that it's called with the parameter "bypass". It'll run the function "HellzYeah", wait for boot process to finish, and, when the boot process is finished, supercharge your phone!
(if anyone is reading this, please inform zeppelinrox about this problem. I'm not able to post on the development forum yet.)
(This is my first post in xda. Hopefully it's helpful)
Hi Guys, Im Here To Share You My Guide About Reducing Lag At Realtime. But First Heres The Requirements
Note: Use This If You Dont Have Battery Issues. This Method Is Only For Gaming And Multitasking.
Requirements
-An Android Device Running With 4.0.x And Above(Not Sure If Will Work On GB)
-Root Permission
-Busybox Stable Build(Higher Version Is Recommended)
-Terminal Emulator Or Script Manager App From Play Store
-A Custom Recovery Like ClockWorkMod Or Team Win Recovery Project
-Droidedit App From Play Store
Click to expand...
Click to collapse
Instructions
1. Reboot To Recovery Mode
2. Backup Your Device Using Recovery
3. After Backing Up Your Phone, Open DroidEdit App From App Drawer
4. Write The Following Line On DroidEdit App:
Code:
#!/system/bin/sh
mount -o rw,remount /system 2>/dev/null
mount -o rw,remount rootfs 2>/dev/null
mount -o rw,remount / 2>/dev/null
cat >> /system/bin/kill_lag <<EOF
#!/system/bin/sh
# Lag Reducer
while true; do
echo 3 >> /proc/sys/vm/drop_caches;
sleep 2
echo 2 >> /proc/sys/vm/drop_caches;
done;
EOF
chmod 755 /system/bin/kill_lag 2>/dev/null
chown 0:0 /system/bin/kill_lag 2>/dev/null
nohup /system/bin/kill_lag &
exit 0
5. Save It At The Root Of Your Sdcard Then Named It As kill_lag.sh
6. Open Script Manager App
7. Find The kill_lag.sh at /sdcard
8. Tap kill_lag.sh Then Tap Su Icon, Last, Tap Run
9. Wait Then Done
Click to expand...
Click to collapse
Compatibility
This Method Will Work On Any Android Device Unless You Have Root
Note
To All Users, Dont Copy This Guide With Out My Permission.
Thanks To
-Busybox Developers For BusyBox
-All Devs Here At XDA And Also You, Users
-Unix
Setting drop_caches to 3 then back to 2 to free pagecache is a bit of a myth.
It will obviously free some RAM, but it will also spike up the CPU because there's a load as cache is being rebuilt. Ideally drop_cache doesn't need to played with, or at least not a lot (once a day?) otherwise you're just going to trade the false sense of "performance" for battery life.