Jump to content

Welcome to CyanogenMod

Welcome to our forum. Like most online communities you must register to post, but don't worry this is a simple free process that requires minimal information for you to signup. Be a part of the CyanogenMod Forum by signing in or creating an account. You can even sign in with your Facebook or Twitter account.
  • Start new topics and reply to others
  • Subscribe to topics and forums to get automatic updates
  • Get your own profile and make new friends
  • Download files attached to the forum.
  • Customize your experience here
  • Share your CyanogenMod experience!

Swap Enable/Disable


86 replies to this topic

#1 -Stevo-

  • Members
  • 1,297 posts
  • LocationSalt Lake City, Utah
  • Country:us
  • Device Model:HTC Vision G2
  • MOD Version:CM7.0.0-RCX
  • Recovery Image:ClockworkMod

Posted 30 May 2010 - 04:36 PM

SwapScriptv2.1.1
Flash from Recovery
Compatible with 2 and 3 partition layouts (ext(fat+ext+swap) and no ext(fat+swap))
http://www.mediafire...qdvxh7sos5svcvc
or
http://www.sendspace.com/file/h66oap

This script adds commands to terminal:

swapscriptv2
bootswapv2
swap-off
bootswap-off
vmtweaks
vmtweaks-boot

swapscriptv2 - you will be asked what partition layout you are using as well as swappiness, optional vm settings prompted

bootswapv2 - you will be asked what partition layout you are using as well as swappiness, and an init script will be placed for swap at boot time, optional boot time vm settings prompted

swap-off turns off active swap partition (error for parition not in use is normal)

bootswap-off removes bootswap init file.

vmtweaks allows changing settings for vfs_cache_pressure and page-cluster, some people have reported success in reducing these values.

vmtweaks-boot allows changing settings for vfs_cache_pressure and page-cluster and applying them at boot.

Let me know if there are any problems with the new script.


SwapScript: (v1)
Flash from Recovery
fat32+ext+swap or swap on /dev/block/mmcblk0p3
http://www.mediafire...bnc79k6pkespzbj

fat32+swap no ext or swap on /dev/block/mmcblk0p2
http://www.mediafire...b3ykdk3r21js96q

This script adds several commands to terminal:

swapon10
swapon20
swapon30
swapon40
swapon50
swapon60
swapon70 
swapon80 
swapon90 
bootswap10 
bootswap20
bootswap30
bootswap40
bootswap50
bootswap60
bootswap70 
bootswap80 
bootswap90 
swap-off
bootswap-off

Instructions
swaponXX (20,30,40,50,60) - will result in swap being turned on with a swappiness of XX
bootswapXX (20,30,40,50,60) - will enable swap at boot time with a swappiness of XX (no usuerinit.sh needed)
swap-off - Turns running swap off.
bootswap-off - removes init swap script from boot. (see above notes for removal if you used the newer script)

SWAPFILE CREATOR:
http://www.mediafire...yr7w2yd5sfobyte

For anyone interested in testing different swap sizes and swappiness or those with no partition other than the standard fat, I threw together a swapfile script allowing for several common configurations. Similar to my swapscript after flashing from recovery a number of new commands will become available in terminal:

Instructions
First create a swap file on your sdcard or sd-ext partition:

swapfileXX (size 12,24,36,64,96,128 on sdcard fat partition)
extswapXX (size 12,24,36,64,96,128 on sdcard ext partition)

Then set swappiness:

swpXX (XX is swappiness in increments of 10 up to 90)
errors in script are normal, script references both fat and ext locations, will fix this next update

swapfile-off (stop swap file in use)
errors in script are normal, script references both fat and ext locations, will fix this next update
clearswapfile (stops swap file and removes all swap files created)
errors in script are normal, script references both fat and ext locations, will fix this next update

Swapfile at boot ONLY SUPPORTED FOR SWAPFILE ON EXT:

bootswapfileXX (XX is swappiness in increments of 10 up to 90)
bootswapfil-off - removes bootswap

SwapFileScript:
http://www.mediafire...yr7w2yd5sfobyte


How to tell if swap is currently in use:

in terminal emulator or adb shell type 'free' with no 's and press enter

if there is a number in the space that says swap you have swap enabled.

Edited by -Stevo-, 09 October 2010 - 06:41 AM.


#2 Tony319

  • Members
  • 2 posts
  • Device Model:|2|
  • MOD Version:CM 5.0.7
  • Recovery Image:Cyanogen

Posted 01 June 2010 - 04:06 AM

I'm pretty good with everything about my myTouch, the only thing I don't get fully is the idea of the EXT swap. I know it allows A2SD but I really don't need that. So, since i don't use that option, would turning my swap off be a good idea? I'm not sure how all the values (20, 30, etc.) would affect performance. Mine's pretty fast most of the time so I don't know the advantages/disadvantages.

#3 petermikhail

  • Members
  • 15 posts
  • Twitter:peter_mikhail
  • Device Model:|1|2|
  • MOD Version:CM 5.0.8 T1
  • Recovery Image:Amon_RA

Posted 07 June 2010 - 01:44 AM

anyway to set it more then 60 like say 90 or 96

#4 parkenshaw

  • Members
  • 59 posts
  • LocationBrooklyn
  • Country:us
  • Device Model:|2|
  • MOD Version:6.0
  • Recovery Image:Amon_RA

Posted 07 June 2010 - 04:22 AM

Nah, works well, deems somethin went wrong when I downloaded the file, had to get a fresh copy and re-flash.

#5 wulfn

  • Members
  • 3 posts
  • Device Model:|2|
  • MOD Version:5.0.7
  • Recovery Image:Cyanogen

Posted 08 June 2010 - 03:44 AM

Having problems when trying to enable it. keeps saying permission denied

cannot create /sys/class/leds/blue/brightness: permission denied.


Sorry, first time trying to enable swap

#6 smashman42

  • Donators
  • 161 posts
  • Twitter:smashman42
  • LocationTownsville, Queensland, Australia
  • Country:au
  • Device Model:LG Optimus 2X P990
  • MOD Version:CM7 Nightlies or self-kangs
  • Recovery Image:ClockworkMod

Posted 08 June 2010 - 04:45 AM

Had you run "su" first?

Btw Stevo, the no ext swap-off script is (was?) pointing to partition 3 not 2.

#7 -Stevo-

  • Members
  • 1,297 posts
  • LocationSalt Lake City, Utah
  • Country:us
  • Device Model:HTC Vision G2
  • MOD Version:CM7.0.0-RCX
  • Recovery Image:ClockworkMod

Posted 08 June 2010 - 04:51 AM

View Postsmashman42, on 08 June 2010 - 04:45 AM, said:

Had you run "su" first?

Btw Stevo, the no ext swap-off script is (was?) pointing to partition 3 not 2.

thanks for catching that. updated it.

#8 smashman42

  • Donators
  • 161 posts
  • Twitter:smashman42
  • LocationTownsville, Queensland, Australia
  • Country:au
  • Device Model:LG Optimus 2X P990
  • MOD Version:CM7 Nightlies or self-kangs
  • Recovery Image:ClockworkMod

Posted 08 June 2010 - 05:11 AM

bootswap-off has the same single digit typo, I've only got my phone atm, if I had my laptop with adb I'd fix it myself.

Shell scripts I can do from ubuntu experience, I don't know how to make flashable zips yet

#9 wulfn

  • Members
  • 3 posts
  • Device Model:|2|
  • MOD Version:5.0.7
  • Recovery Image:Cyanogen

Posted 08 June 2010 - 05:27 AM

View Postsmashman42, on 08 June 2010 - 04:45 AM, said:

Had you run "su" first?

Btw Stevo, the no ext swap-off script is (was?) pointing to partition 3 not 2.

Whoops, my bad. Haha, thax seems it fixed it

#10 dinky

  • Donators
  • 62 posts
  • Country:au
  • Device Model:|1|
  • MOD Version:6-RC1
  • Recovery Image:Amon_RA

Posted 10 June 2010 - 03:26 AM

Stevo, you are truly amazing, and next to Cyanogen, my android hero. Thanks so much for all your awesome scripts... it has made using this device a joy. Wiping my ext partition shortly (no need for it on my sdcard), and using your script to replace the userinit.sh file I'd placed on my ext partition to enable swap. Thanks again matey!

#11 noinoi2424

  • Members
  • 31 posts
  • Device Model:|2|
  • MOD Version:5.0.7
  • Recovery Image:Amon_RA

Posted 10 June 2010 - 02:57 PM

View Post-Stevo-, on 30 May 2010 - 04:36 PM, said:

If you have an EXT-Partition+Swap:
Attachment SwapScript-signed.zip

If you are using ONLY a swap partition and NO-EXT:
Attachment SwapScript-noext-signed.zip

This script adds several commands to terminal:

swapon20
swapon30
swapon40
swapon50
swapon60
bootswap20
bootswap30
bootswap40
bootswap50
bootswap60
swap-off
bootswap-off

swaponXX (20,30,40,50,60) - will result in swap being turned on with a swappiness of XX
bootswapXX (20,30,40,50,60) - will enable swap at boot time with a swappiness of XX (no usuerinit.sh needed)
swap-off - Turns running swap off.
bootswap-off - removes init swap script from boot.


hi! just wondering, what is this gonna do with my G1? does it make it faster? how about the JIT on or off? let me know. thank you...

#12 Ed Boy

  • Donators
  • 11 posts
  • Twitter:ed_rapley
  • LocationBristol, UK
  • Country:uk
  • Device Model:|2|
  • MOD Version:5.0.8 x
  • Recovery Image:Amon_RA

Posted 11 June 2010 - 12:42 PM

View Postnoinoi2424, on 10 June 2010 - 02:57 PM, said:

hi! just wondering, what is this gonna do with my G1? does it make it faster? how about the JIT on or off? let me know. thank you...

There is an amazing website which could help you in future: it's called Google and it holds the answers to all these questions and more!

Swap stores info for the your system to retrieve; for example some people find web pages are kept in memory more successfully and don't have to reload when switching between windows in the browser; the downside is it shortens the life of your SD card.

There is a good post about JIT and it's costs/benefits here.

#13 dinky

  • Donators
  • 62 posts
  • Country:au
  • Device Model:|1|
  • MOD Version:6-RC1
  • Recovery Image:Amon_RA

Posted 11 June 2010 - 01:01 PM

So now I've got swap working, and this nifty little blue led to prove it... ok guys, how do I turn the light off. I'm assuming it's there to tell me I'm shortening the life of my sdcard, but I can live with that and prefer not to have a constant reminder. Is there an easy way to disable it, or do I need to hack Stevos script. Thanks.

#14 dinky

  • Donators
  • 62 posts
  • Country:au
  • Device Model:|1|
  • MOD Version:6-RC1
  • Recovery Image:Amon_RA

Posted 11 June 2010 - 01:11 PM

View Postdinky, on 11 June 2010 - 01:01 PM, said:

So now I've got swap working, and this nifty little blue led to prove it... ok guys, how do I turn the light off. I'm assuming it's there to tell me I'm shortening the life of my sdcard, but I can live with that and prefer not to have a constant reminder. Is there an easy way to disable it, or do I need to hack Stevos script. Thanks.


Right, use bootswap and reboot. Great script!

#15 parkenshaw

  • Members
  • 59 posts
  • LocationBrooklyn
  • Country:us
  • Device Model:|2|
  • MOD Version:6.0
  • Recovery Image:Amon_RA

Posted 11 June 2010 - 01:54 PM

Some people have been specifying that swap on leads to a good slow-down... But I have to admit, its made my G1 feel a whole lot zippier, decided to leave it on. Great work on the scripts.

#16 chucktdriscoll

  • Members
  • 106 posts
  • Twitter:chucktdriscoll
  • LocationWinter Park, FL
  • Country:us
  • Device Model:Samsung Vibrant
  • MOD Version:Cyanogenmod 7 Test
  • Recovery Image:ClockworkMod

Posted 11 June 2010 - 02:07 PM

View Postparkenshaw, on 11 June 2010 - 01:54 PM, said:

Some people have been specifying that swap on leads to a good slow-down... But I have to admit, its made my G1 feel a whole lot zippier, decided to leave it on. Great work on the scripts.

The trade off is slower access to ram (swap on) or re-loading apps into ram frequently (swap off). The gains you'll see will depend mostly on how much real ram your phone has and how many apps you use often. Little ram or lots of apps will benefit from swap more that lots of ram or few apps.

#17 TheGenericAsian

  • Members
  • 23 posts
  • LocationAustin, TX
  • Country:us
  • Device Model:Samsung Vibrant
  • MOD Version:CM7 Nightly
  • Recovery Image:ClockworkMod

Posted 12 June 2010 - 06:24 PM

I fixed the Wiki article so it tells you (hopefully) useful things. http://wiki.cyanogen...p_and_Compcache

#18 renn9420

    Android FTW!

  • Donators
  • 41 posts
  • LocationCalifornia
  • Country:us
  • Device Model:T-Mobile G2/Vision
  • MOD Version:Latest Cyanogen
  • Recovery Image:ClockworkMod

Posted 04 July 2010 - 12:48 AM

Is it possible to release a version with a swap and bootswap of 10?

#19 fsr678

  • Members
  • 3 posts
  • Device Model:|2|
  • MOD Version:CM 5.0.08
  • Recovery Image:Cyanogen

Posted 08 July 2010 - 03:33 AM

I installed this and tried swap using a swap partition. I decided to not use swap.

Do I..or should I..remove this script or is it ok to just leave it on the system? I don't plan on using it but have no idea how to go about removing it.

Thank you!

#20 motoman234

    Wam! bam! thank you mam

  • Donators
  • 147 posts
  • Twitter:mototy234
  • LocationTulsa,OK
  • Country:us
  • Device Model:HTC Inspire 4G
  • MOD Version:CM-7
  • Recovery Image:ClockworkMod

Posted 14 July 2010 - 02:28 AM

@Stevo,

Would it be possible to make this delightful script for cm6. It makes life a lil easier :)