1. Download our Official Android App: Forums for Android!

Root [Boost Mobile] RAM Swapping without Swapper2

Discussion in 'Android Devices' started by drewhill77, Sep 1, 2012.

  1. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    If your'e like me and don't need one more program taking up space on your phone you can enable RAM swap through any terminal manager.

    The following method will create a swapfile on your SD card...I use the SD card instead of /data because RAM swapping will increase the number of read/writes wherever the swapfile is located and I would rather have to replace my SD card than have my NAND go out:rolleyes: IF you want to use your internal memory you can replace /mnt/sdcard/ with /data/...

    What you need:
    Root
    Busy Box (I use 1.19)
    Terminal Manager (I use Smanager)
    Kernel capable of swapping (I'm using glitch)

    Open your terminal manager and enable SU if needed

    To create your swapfile
    Code (Text):
    1. # dd if=/dev/zero of=/mnt/sdcard/swapfile bs=1048576 count=X
    X is the size of your swapfile in MB...should only take a couple minutes.

    Now that you've got the swapfile on your SD we've got to turn it on
    Code (Text):
    1. # mkswap /mnt/sdcard/swapfile
    2. # swapon /mnt/sdcard/swapfile
    Ta-DA! you now have an active ram swap type "free" and you should see your active swap...but we're not done yet. Still have to enable it at boot:D

    Go to /etc/init.d/ and create file 99swapon (or whatever you want to name it) edit the file and type
    Code (Text):
    1. #!/system/bin/sh
    2. sleep 75
    3. swapon /mnt/sdcard/swapfile
    Depending on how fast your phone mounts your SD card you can reduce the sleep value to as low as 30.

    Reboot...open terminal...type free and you should see your swap listed.

    The default "swappiness" for android is 60 you can check this by typing
    Code (Text):
    1. cat /proc/sys/vm/swappiness
    To change this go to /etc/ and create a file named sysctl.conf edit the file and type
    Code (Text):
    1. vm.swappiness=X
    X is the level of swappiness and can be 0 - 100...the higher the number the more android uses swap. In your terminal type
    Code (Text):
    1. sysctl -p
    Output should show your new swappiness level...again to check this "cat /proc/sys/vm/swappiness" In order to have these settings applied at boot edit your 99swapon file and add
    Code (Text):
    1. sysctl -p
    Reboot...open terminal...type free to check swap is on...type cat /proc/sys/vm/swappiness to check your swappiness level.

    For those of you who don't want to actually have to type out all of that here are some scripts I wrote up to automate it all...made a 32M and 64M version for /mnt/sdcard and /data.

    Make Swapfile
    http://dl.dropbox.com/u/101517904/32m_swapfile_data.sh
    http://dl.dropbox.com/u/101517904/32m_swapfile_sdcard.sh
    http://dl.dropbox.com/u/101517904/64m_swapfile_data.sh
    http://dl.dropbox.com/u/101517904/64m_swapfile_sdcard.sh

    Activate Swap, Set Swappiness and Set at Boot
    http://dl.dropbox.com/u/101517904/data_swapon_boot.sh
    http://dl.dropbox.com/u/101517904/SD_swapon_boot.sh

    Enjoy!!:D

    A brief note on swapping - This does not actually extend you RAM...Android swapping only moves mapped in-active apps from memory to swapfile. To put it in simple terms bigger is not better...so create yourself a nice little 32M or 64M swapfile and set your swappiness to 100. Also minfree does not account for swap so you can get by with lower minfree values if you're using V6 supercharger.
     

    Advertisement

  2. Bone334

    Bone334 Member
    Rank:
    None
    Points:
    16
    Posts:
    73
    Joined:
    Jun 17, 2012

    Jun 17, 2012
    73
    9
    16
    Male
    Northwest Arkansas
    Awesome!! I was hoping for exactly what you have Thanks!
     
  3. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    added "swappiness" settings
     
  4. SelfElevated2

    SelfElevated2 Android Expert
    Rank:
    None
    Points:
    213
    Posts:
    1,335
    Joined:
    Jul 25, 2012

    Jul 25, 2012
    1,335
    527
    213
    Male
    Auto mechanic
    Baltimore, Maryland
    No offense there buddy but why would anyone do it this way? Swapper2 is less than a megabyte. It can place the swap file anywhere and will set you with a 256mb swap file in about 2 minutes.

    Do I even need to say more? Lol
    I mean it's neat and all yea. But not economic. Especially since there are alot of not savvy people on the forums that just Need the easiest way to do things
     
    zeke86 likes this.
  5. pamase201

    pamase201 Well-Known Member
    Rank:
    None
    Points:
    43
    Posts:
    235
    Joined:
    Mar 23, 2012

    Mar 23, 2012
    235
    41
    43
    Male
    tattoo artist
    jersey city new jersey
    question once i set up swapper2 do ihave to keep going back into it to free up ram
     
  6. SelfElevated2

    SelfElevated2 Android Expert
    Rank:
    None
    Points:
    213
    Posts:
    1,335
    Joined:
    Jul 25, 2012

    Jul 25, 2012
    1,335
    527
    213
    Male
    Auto mechanic
    Baltimore, Maryland
    No , there is a guide in the all things root guides section. . But this is still his thread about enabling swap with the terminal so Imma get outta here :D
     
  7. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    First off I'd like to point out that your thread http://androidforums.com/warp-all-things-root/604361-guide-zte-warp-swap-extra-ram.html
    has people puting their swapfile in /data (i.e. internal memory)...flash memory (aka nand, sdcard, etc.) has a limited number of read/writes and using swap will decrease the lifespan of whatever flash you place it on. I'd much rather buy a new SD card than a new phone. Granted that is simply what you've told people to do and Swapper2 does have the option to use the SD Card.

    Now for ease of use I would suggest Swapper2...however if you want more control over what's going on with your VM my method is not limited to 256M (although I see no reason to exceed that anyway lol), it enables sysctl.conf which actually gives more VM options than I listed (vm.dirty_ratio, vm.dirty_background_ratio and vm.vfs_cache_pressure) and you can add it directly to any rom release with just a little more scripting;)

    To answer your question...no. Once it's set up it should load on boot. Also this thread is actually about NOT using Swapper2...the thread you should've posted to is http://androidforums.com/warp-all-things-root/604361-guide-zte-warp-swap-extra-ram.html
     
    waterlord93 likes this.
  8. SelfElevated2

    SelfElevated2 Android Expert
    Rank:
    None
    Points:
    213
    Posts:
    1,335
    Joined:
    Jul 25, 2012

    Jul 25, 2012
    1,335
    527
    213
    Male
    Auto mechanic
    Baltimore, Maryland
    Actually your SD card has a limited number of read writes. Placing swap in data puts it in the system which is constantly read writing anyway. Everything you do does some r/rw in data. Not to mention system r/w is much faster than SD card.

    This method is like I said not user friendly. And thanks to down we now have kernels with swap file added into it and activated at startup. .also in DATA. Because the system is meant for constant r/w. SD is not


    Notice I'm not arguing for swapper2 but for placing swap in data. Because it's faster and internal memory was built for that
     
    waterlord93 likes this.
  9. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    It's really just a matter of preference lol...yes the internal memory is faster and designed for more read/writes but that number is still limited. The speed factor can be somewhat overcome by having a class 6 or higher sd card...and yes my sd card will wear out faster than internal memory but I would personally prefer to replace the SD card over replacing the phone.
     
    waterlord93 and Bone334 like this.
  10. StarScream2109

    StarScream2109 Android Expert
    Rank:
    None
    Points:
    313
    Posts:
    5,393
    Joined:
    Feb 29, 2012

    Feb 29, 2012
    5,393
    1,472
    313
    Male
    Air Commander
    Cybertron
    so we have 2 swap guides :) excellent one for people who want the easy way and people who want to do it this way :)
     
    waterlord93 likes this.
  11. downthemachine

    downthemachine Developer Incognito
    Rank:
    None
    Points:
    333
    Posts:
    2,940
    Joined:
    Dec 30, 2011

    Dec 30, 2011
    2,940
    1,727
    333
    Mobile Electronics Installer/Shop Manager
    Minnesota
    You can do the same thing off the data partition. Just change /mnt/sdcard/swapfile to /data/swapfile
     
  12. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    Added script downloads for those who don't want to type that much for 32M and 64M version for /mnt/sdcard and /data.
     
    waterlord93 and Bone334 like this.
  13. Bone334

    Bone334 Member
    Rank:
    None
    Points:
    16
    Posts:
    73
    Joined:
    Jun 17, 2012

    Jun 17, 2012
    73
    9
    16
    Male
    Northwest Arkansas
    Thanks again! I like being able to configure swap as I choose and most important no bloated apk with advertisments. Keep up the good work.
     
  14. k4jxo

    k4jxo Lurker
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Jul 14, 2012

    Jul 14, 2012
    7
    1
    6
    I am using a stock r.o.m. with glitch kernel and I can not locate the init.d file in the directory listed in this guide. i used es file explorer to search and was not able to find the file anywhere on my phone. if anyone could point me in the right direction as what what file i need to edit on a stock r.o.m. for this i would be very grateful
     
  15. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    You more than likely don't have init.d support activated...go to /system/etc and find "install-recovery.sh" if it doesn't exist then create it.

    if it already existed add this at the end of the file
    Code (Text):
    1. #init.d support
    2. busybos run-parts /system/etc/init.d/
    3.  
    4.  
    be sure to add a blank line at the end of the file

    if it didn't exist put this in there
    Code (Text):
    1. #!/system/bin/sh
    2. #init.d support
    3. busybox run-parts /system/etc/init.d/
    4.  
    5.  
    in /system/etc/ add a folder named "init.d" and place any bootscripts you want run there
     
    k4jxo likes this.
  16. downthemachine

    downthemachine Developer Incognito
    Rank:
    None
    Points:
    333
    Posts:
    2,940
    Joined:
    Dec 30, 2011

    Dec 30, 2011
    2,940
    1,727
    333
    Mobile Electronics Installer/Shop Manager
    Minnesota
    Make sure you have busybox installed. I prefer users use "busybox" via play store. Not the one that says installer after it. Install to xbin, also my opinion on where it should go
     
  17. k4jxo

    k4jxo Lurker
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Jul 14, 2012

    Jul 14, 2012
    7
    1
    6
    Thank you that fixed my problem:D
     
    Dm47021 likes this.
  18. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    Realized error in script to make swap active and fixed it...also updated guide and scripts to make swapfile write faster.
     
  19. jimsmith80

    jimsmith80 Android Expert
    Rank:
    None
    Points:
    213
    Posts:
    1,361
    Joined:
    Aug 22, 2012

    Aug 22, 2012
    1,361
    777
    213
    Male
    Phoenix AZ
    drewhill77: Thank you for this guide. I for one dislike using an app when one is not needed. Information like this is what helps to transform a noob into a developer.
     
    drewhill77 likes this.
  20. jimsmith80

    jimsmith80 Android Expert
    Rank:
    None
    Points:
    213
    Posts:
    1,361
    Joined:
    Aug 22, 2012

    Aug 22, 2012
    1,361
    777
    213
    Male
    Phoenix AZ
    I set this up my swap using adb so this may not be relevant to everyone, but I had to chmod 755 my "98swapon" to get things up and running correctly. I am going to experiment with sleep time 75 seems rather long. I'll post my results
     
  21. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    Thank you for your praise... I too am new to programming and scripting and just recently started developing my own ROM. When I saw the post about swapper2 I wanted to see if there would be a way of doing that 100% in the background and when I found it I decided to share it.

    Also at the time of writing this it took my phone nearly 75 seconds to mount the SD card after booting... I have since streamlined it and opted to to place the swapfile in /data. Even though that means more read/writes to my nand I figure something else will probably go out on my phone before it does lol.

    If you want to continue using the swapfile on SD card you can tweak the sleep time and run free from your console to see if it loaded or not...or you can add an if the file exists then swapon else sleep 5 function...
     
  22. jimsmith80

    jimsmith80 Android Expert
    Rank:
    None
    Points:
    213
    Posts:
    1,361
    Joined:
    Aug 22, 2012

    Aug 22, 2012
    1,361
    777
    213
    Male
    Phoenix AZ
    #!/system/bin/sh
    sleep 5
    swapon /data/swapfile
    sleep 5
    sysctl -p

    Here is my finial "98swapon" I had to add sysctl -p or swappiness returned to 60.
     
  23. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    If you're running it from /data you don't need the sleep command at all
     
  24. drewhill77

    drewhill77 Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    93
    Posts:
    662
    Joined:
    Aug 26, 2012

    Aug 26, 2012
    662
    206
    93
    Truck Driver (Local/Regional)
    Indianapolis, IN
    Lol...I just checked the file i posted for /data swapon and saw that the sleeping command was in there. I must have copied and pasted from the SD swapon and just changed the path. I'll fix that when I get home from work tonight and post a new 1.
     
  25. akira6968

    akira6968 Newbie
    Rank:
    None
    Points:
    16
    Posts:
    22
    Joined:
    Oct 7, 2012

    Oct 7, 2012
    22
    2
    16
    PC Repair, Cable Guy
    OK, so before finishing the entire instruction set above I had already gone and set my swap file size to a size I'm not going to admit to here...

    How can I go about changing the partition size, and then the swap setup? For example's sake, let's say I set it to 512MB....and I'm looking to change it to 128MB. I DO run a ton of shit on my phone, so even 256 might be appropriate, I'm not really sure, but I've noticed with much joy that my phone hasn't rebooted once since I did this XD

    Also, further argument for this method of setting swapfile up- I personally prefer, whenever possible, to know exactly (as much as I can understand) the process and effects of modifications to my stuff, and tighter control over what exactly happens. An app may decide to add something (like tracking, or something) I don't want, and I would never know until it is called out by someone who can deduce that stuff. Unlikely I'm sure, but still a valid (although admittedly ignorant) argument.
     

Share This Page

Loading...