[SCRIPT][UPDATED 01.26.14] Enable Ram Swap & Create a Swap File with |=~>SwapItOn<~=|

clnzx2

Senior Member
Sep 17, 2007
471
196
0
Have you at least read along?
Plus you have posted zero concrete info/output.

This isn't ESP Developers.
I posted my issue and defiant 7 posted some questions /ideas of which I responded to and did not get an answer. Yes i have read the entire thread. I have attached a screenshot that shows exactly what I have already said. I also tried swapon /data/media/0/swapfile with the same results

Sent from my Galaxy Nexus using Tapatalk 4 Beta
 

Attachments

defiant07

Senior Member
Feb 26, 2013
410
496
0
Umm... Easier way to get free space...

Code:
freemb=`busybox df -m | grep $storage | awk '{print $((NF-2))}'`
TY yet again...Zep and his famous one liners...you're like the Rodney Dangerfield of bash, lol :laugh:.

If so, do:

swapon /data/media/0/swapfile
I go to sleep and you solve all my problems :p. I'm getting tired of saying it, but...thanks, your efforts are most appreciated.

Hey it works now. I reflashed v4, ran swapit to create the swapfile then swapon /data/media/0/swapfile and no more errors. Free command also shows swap being used. Thanks so much zep and of course defiant07. :)

Sent from my GT-P7500 using Tapatalk HD
nice glad to hear it...I will edit and attach a new test version to this post sometime today, which should fix this jb related issue and give the script full functionality...it seems jb migrates data to /data/media/0.
##### Uploaded TEST_2, Which Should Help With Some JB Related Swapon Errors :fingers-crossed: #####
I'm fairly optimistic about this and hope it will be the next official update; so here's a rough draft of the change log:
  • should be more compatible with jb roms via the new ability to choose where the required files will be made - thanks to Zep
  • new method of detecting storage location and some optimization of code - thanks to Zep
  • added V6 SuperCharger style 'power shift' scripts aka "Super Stupendous Switch Swap Scripts" (ahh...gotta love alliteration) for: swapon, swapoff, swappiness=0, swappiness=20, swappiness=40, swappiness=60, swappiness=80, swappiness=100
  • improved dialog
 

Attachments

Last edited:
  • Like
Reactions: eushaun99

defiant07

Senior Member
Feb 26, 2013
410
496
0
I posted my issue and defiant 7 posted some questions /ideas of which I responded to and did not get an answer. Yes i have read the entire thread. I have attached a screenshot that shows exactly what I have already said. I also tried swapon /data/media/0/swapfile with the same results

Sent from my Galaxy Nexus using Tapatalk 4 Beta
Sorry...went to sleep.

So swapon /data/media/0/swapfile worked? No errors? Swap is working?

If yes, then see my above reply to @eushaun99.
 

clnzx2

Senior Member
Sep 17, 2007
471
196
0
Sorry...went to sleep.

So swapon /data/media/0/swapfile worked? No errors? Swap is working?

If yes, then see my above reply to @eushaun99.
Swap does not work with that command either. The swap file is created but not enabled. And no worries on not responding injustice saying i had provided some info. Glad you responded and don't care how long it took lol. Thanks

Sent from my Galaxy Nexus using Tapatalk 4 Beta
 

zeppelinrox

Senior Member
Dec 21, 2010
9,374
21,587
0
IN THE FREAKIN' OP
TY yet again...Zep and his famous one liners...you're like the Rodney Dangerfield of bash, lol :laugh:.


I go to sleep and you solve all my problems :p. I'm getting tired of saying it, but...thanks, your efforts are most appreciated.


nice glad to hear it...I will edit and attach a new test version to this post sometime today, which should fix this jb related issue and give the script full functionality...it seems jb migrates data to /data/media/0.
You're welcome.
I like a challenge lol

Well if the sdcard search comes up empty, you don't have to use that /0 folder and just just /data instead but it's don't matter really.

So you can do something like:

Code:
storage=`busybox mount | awk '/vold/&&/sdcard/{print $3}' |  awk 'NR==1'`
if [ ! "$storage" ]; then storage=/data; fi
Or you can go nuts and if there is an external sdcard found, give the user a choice to use the sdcard or /data (/data is faster than an ext sdcard BUT of course is a tad riskier)

So that would look like:

Code:
storage=`busybox mount | awk '/vold/&&/sdcard/{print $3}' |  awk 'NR==1'`
if [ "$storage" ]; then
    echo " Pick (e)xternal sd card  or (d)ata partition? "
    read location
    case $location in
      e|E);;
      d|D)storage=/data;;
        *)Learn how to type!;;
    esac
else storage=/data
fi
Using a Samsung Galaxy Nexus (toro) running uxylon jb 4.2.2

I tried the commands posted to find storage location and got these results...

Sent from my Galaxy Nexus using Tapatalk 4 Beta
/system or /data or /cache don't show up?

Also do su first, just in case.

Googling the function error indicates that the kernel doesn't support it so do:

Code:
su
cat /proc/cpuinfo
Just to be sure
 
  • Like
Reactions: defiant07

defiant07

Senior Member
Feb 26, 2013
410
496
0
Swap does not work with that command either. The swap file is created but not enabled. And no worries on not responding injustice saying i had provided some info. Glad you responded and don't care how long it took lol. Thanks

Sent from my Galaxy Nexus using Tapatalk 4 Beta
That output from the mount command looks straight funny style to me for the reasons noted by Zep.

If the vTEST_2, which I will post after I give it a test run, does not work for you (note: I doubt it will work since you seem to lack /data): look around on your device and there should be at least one other place where all the contents of /storage/emulated/legacy are mirrored. Give me the name(s) of the mirrored location(s) and if worse comes to worse I can make a custom version that should work with your rom (the script would only require marginal revisions).
 

clnzx2

Senior Member
Sep 17, 2007
471
196
0
That output from the mount command looks straight funny style to me for the reasons noted by Zep.

If the vTEST_2, which I will post after I give it a test run, does not work for you (note: I doubt it will work since you seem to lack /data): look around on your device and there should be at least one other place where all the contents of /storage/emulated/legacy are mirrored. Give me the name(s) of the mirrored location(s) and if worse comes to worse I can make a custom version that should work with your rom (the script would only require marginal revisions).
My fake SD card is mirrored at
/mnt/sdcard/
/sdcard/
/data/media/0/
/storage/emulated/0/
/storage/emulated/legacy/
/storage/sdcard0/

Tried swapon at all those paths and get function not implemented

Sent from my Galaxy Nexus using Tapatalk 4 Beta
 

defiant07

Senior Member
Feb 26, 2013
410
496
0
My fake SD card is mirrored at
/mnt/sdcard/
/sdcard/
/data/media/0/
/storage/emulated/0/
/storage/emulated/legacy/
/storage/sdcard0/

Tried swapon at all those paths and get function not implemented

Sent from my Galaxy Nexus using Tapatalk 4 Beta
Although I'm not 100% certain, I am fairly confident that it is an issue with your kernel being that swapon gave that error for all those locations (unless there is some other undiscovered location).

Your kernel thinks it is capable of swap being that 'swap' or 'swp' is listed under 'features'/you pass the test at the beginning of the script, but for whatever reason swapon and swapoff are not properly implemented in the kernel.

I would advise talking with the maker of your rom/kernel. Are there other users of your rom that have successfully enabled swap via some other script, an app, or command/terminal based method?
 

clnzx2

Senior Member
Sep 17, 2007
471
196
0
Although I'm not 100% certain, I am fairly confident that it is an issue with your kernel being that swapon gave that error for all those locations (unless there is some other undiscovered location).

Your kernel thinks it is capable of swap being that 'swap' or 'swp' is listed under 'features'/you pass the test at the beginning of the script, but for whatever reason swapon and swapoff are not properly implemented in the kernel.

I would advise talking with the maker of your rom/kernel. Are there other users of your rom that have successfully enabled swap via some other script, an app, or command/terminal based method?
Switched kernels and used /data/media/0/

And it finally works! lol. Thanks for all the help.

Sent from my Galaxy Nexus using Tapatalk 4 Beta
 

defiant07

Senior Member
Feb 26, 2013
410
496
0
Switched kernels and used /data/media/0/

And it finally works! lol. Thanks for all the help.

Sent from my Galaxy Nexus using Tapatalk 4 Beta
Awesome...I am glad to hear it :good:.

Did you try TEST_2? It is attached to post #43. When it asks you to choose location, choose /data and it should be fully functional for you :fingers-crossed:.
 

eushaun99

Senior Member
Feb 8, 2013
2,014
970
193
21
Subang Jaya
Awesome...I am glad to hear it :good:.

Did you try TEST_2? It is attached to post #43. When it asks you to choose location, choose /data and it should be fully functional for you :fingers-crossed:.
Test 2 working fine here...no more errors finally :p

Thanks again for all you've done and I'm sure you will continue to improve this script further as time pass. Another thanks for giving me credits although I didn't really do much. :D

I have another question if you don't mind. You said in v6 swappiness is set to 20. So if I set a different value here wouldn't it conflict or something?

Sent from my GT-P7500 using Tapatalk HD
 
  • Like
Reactions: defiant07

defiant07

Senior Member
Feb 26, 2013
410
496
0
Test 2 working fine here...no more errors finally :p

Thanks again for all you've done and I'm sure you will continue to improve this script further as time pass. Another thanks for giving me credits although I didn't really do much. :D

I have another question if you don't mind. You said in v6 swappiness is set to 20. So if I set a different value here wouldn't it conflict or something?

Sent from my GT-P7500 using Tapatalk HD
Yeah, finally :p.

The most credit for this update should really go to Zep. I know very little about jb and wrongly assumed basic things like storage location names and filesystems were more or less standardized across different android versions...wish I had a jb device or there was a decent jb rom for my current device. I believe in giving credit where credit is due and it's nice as well as useful having a good tester.

I suppose technically it is conflicting (the same property is being set twice with different values during each boot process and the last one sticks), but its not really a problem if the swappiness you chose in swapit is sticking after a reboot. If after a reboot it's set to 20 search the 99SC (and KAK too if you use that...swappiness is applied in there too if I recall correctly) for swappiness and change it to your desired value (you could do this too if you don't want them to be 'conflicting'...they'd just be redundant). Or if you wanted to you could delete
Code:
echo "$(cat /data/swappinessvalue.txt)" > /proc/sys/vm/swappiness
from my init.d script and edit V6/KAK/etc so some other script set swappiness during boot; this would eliminate conflict and redundance.
 
Last edited:
  • Like
Reactions: eushaun99

defiant07

Senior Member
Feb 26, 2013
410
496
0
Released v5...major update.

Should now be jb compatible and added 'shift' scripts. Note: JB users will probably have to select data partition for their swap file location.

Also note v5 is the same as vTEST_2, so anyone on that version need not update.

v5
  • should now be compatible with jb roms via the new ability to choose where the required files will be made - thanks to @zeppelinrox
  • new method for detecting storage location and some optimization of code - thanks to @zeppelinrox
  • added V6 SuperCharger style 'power shift' scripts aka "Super Stupendous Switch Swap Scripts" (ahh...gotta love alliteration) for: swapon, swapoff, swappiness=0, swappiness=20, swappiness=40, swappiness=60, swappiness=80, swappiness=100
  • improved dialog
 
Last edited:

zeppelinrox

Senior Member
Dec 21, 2010
9,374
21,587
0
IN THE FREAKIN' OP
Switched kernels and used /data/media/0/

And it finally works! lol. Thanks for all the help.

Sent from my Galaxy Nexus using Tapatalk 4 Beta
That's nice.
But not surprising.

The issue isn't actually fixed because the script assumed the other kernel is fine.

If you had done the cat /process/cpuinfo command with the other kernel, that output would have been informative.
 

clnzx2

Senior Member
Sep 17, 2007
471
196
0
That's nice.
But not surprising.

The issue isn't actually fixed because the script assumed the other kernel is fine.

If you had done the cat /process/cpuinfo command with the other kernel, that output would have been informative.
With the other kernel when i did that command swp was listed. That's who initially I ruled out the kernel

Sent from my Galaxy Nexus using Tapatalk 4 Beta

---------- Post added at 04:41 PM ---------- Previous post was at 04:34 PM ----------

Released v5...major update.

Should now be jb compatible and added 'shift' scripts. Note: JB users will probably have to select data partition for their swap file location.

Also note v5 is the same as vTEST_2, so anyone on that version need not update.
V5 works as it should. Thanks again.

Sent from my Galaxy Nexus using Tapatalk 4 Beta
 

sanpedro_bonita

Senior Member
May 29, 2013
68
19
0
Really love this swap, but everytime I reboot end of bootloop.. any solution? My phone is ram 512mb, I make 350mb swap,50 values.

Sent from my HTC Explorer A310e using xda premium
 

defiant07

Senior Member
Feb 26, 2013
410
496
0
Really love this swap, but everytime I reboot end of bootloop.. any solution? My phone is ram 512mb, I make 350mb swap,50 values.

Sent from my HTC Explorer A310e using xda premium
First let me say sorry for any inconveniences my script has caused you.

I highly doubt any of those settings you mention are the cause of the bootloop. The problem lies in the init.d script, Z99SwapOn. There maybe two things in it that I can think of that maybe the problem:

(1) it contains a while loop - if this is the problem, I am not sure how to fix it because the script needs a means to wait for the swapfile to be found.

(2) it contains a sleep command - if this is the problem, Open Z99SwapOn with a text editor and towards the end there is a sleep 1 command, replace that line with
Code:
echo "waiting" > $LOG
A pretty much guaranteed solution would be to delete Z99SwapOn and then each time after you reboot you could use the 'shift' scripts to turn on swap and set swappiness, although 50 is not one of the shift scripts options...you'd have to use 40 or 60.

===EDIT===
Also did you wipe cache and dalvik before rebooting? It's a long shot, but it could help avoid bootloops.
 
Last edited:
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone