[Script] swapconf - swap config

Search This thread

impactor

Senior Member
Jan 6, 2011
906
136
Kraków
Fufu, few more questions, if you will:
- does this script creates new swap on every boot, thus avoiding always using the same physical memory sectors which could cause increased chip wear?
- what is the actual wear degree we can expect. Would it decrease internal memory lifespan to a month, a year, 10 years, 100 years?
- is the "LEAVE=" parameter necessary if swap is on Data and not Cache partition?
 

Kuboslaw

Member
Mar 14, 2009
44
4
Hey, first of all I'd like to thank you for this great tool :) I've got one question. I made this swap file (50mb) on ext2 partition on sdcard. In terminal it said that swapping succesfuly started but when i checked the amount of RAM it is still on the same level. It is the same like with the ext2 partition that the device just can't show size properly or just something went wrong?
 

Erovia

Senior Member
Sep 16, 2012
818
262
You can check it from Terminal Emulator with the command free

There is a row for ram and for swap.
 

weaverinva

Senior Member
Apr 29, 2008
374
88
Harrisonburg, VA
I guess it should. You need zram/compcache enabled kernel and swap partition on the sdcard might be good.

Okay. I have the compcache ability. Do I have to have the SD parition? I think I might try to forgo that. The issue I have is that I don't think there is an open recovery script recovery for the A855. I use clockworkmod 2.5.0.2 which is a standard and works well.

How would I flash this or get this on my rom other than using OR process?

Finally, this is for extending internal RAM, right? Not the data partition for loading additional apps. I don't mind moving apps with Titanium to the SD card in .android_secure. That seems to work fine and be cleaner.

However I can't load larger application in memory of the A855. This seems to fit the bill and can be turned on and off appropriately.

Thank you for your comments.
 

mrvek

Senior Member
Feb 10, 2011
579
460
/home
Okay. I have the compcache ability. Do I have to have the SD parition? I think I might try to forgo that. The issue I have is that I don't think there is an open recovery script recovery for the A855. I use clockworkmod 2.5.0.2 which is a standard and works well.

How would I flash this or get this on my rom other than using OR process?

Finally, this is for extending internal RAM, right? Not the data partition for loading additional apps. I don't mind moving apps with Titanium to the SD card in .android_secure. That seems to work fine and be cleaner.

However I can't load larger application in memory of the A855. This seems to fit the bill and can be turned on and off appropriately.

Thank you for your comments.

You should be able to apply it with usual apply/choose update, it uses a common edify scripting language. Options that persist script from being deleted on rom update will probably not work on non-CM roms.
The other alternative is to extract swapconf script from zip and copy it manualy to /system/bin, set owner to root:shell and permissons to 755 (rwx-r-x-r-x).
Having separate swap partition could help but you can get by with swapping to sdcard instead. And yes, it extends available ram but is much slower than ram so you really shouldn't use to large swap file/partition for common tasks.
 
  • Like
Reactions: weaverinva

weaverinva

Senior Member
Apr 29, 2008
374
88
Harrisonburg, VA
You should be able to apply it with usual apply/choose update, it uses a common edify scripting language. Options that persist script from being deleted on rom update will probably not work on non-CM roms.
The other alternative is to extract swapconf script from zip and copy it manualy to /system/bin, set owner to root:shell and permissons to 755 (rwx-r-x-r-x).
Having separate swap partition could help but you can get by with swapping to sdcard instead. And yes, it extends available ram but is much slower than ram so you really shouldn't use to large swap file/partition for common tasks.

Thank you. That sounds like I can flash on Steel Droid which is CM 7 (2.3.7) derivative.

Sounds like a 30-100M might be okay. I read in another thread that they found that their 64M swap was only used to 30-42M.

I would think that swap partition and swap to sd card would be the same speed.
 

mrvek

Senior Member
Feb 10, 2011
579
460
/home
Thank you. That sounds like I can flash on Steel Droid which is CM 7 (2.3.7) derivative.

Sounds like a 30-100M might be okay. I read in another thread that they found that their 64M swap was only used to 30-42M.

I would think that swap partition and swap to sd card would be the same speed.

System uses as much as it needs. You can control how much would system prefer swap by using sysctl (eg. sysctl -w vm.swappiness=your_value (0-100))
Since both are on the same sdcard, read/write speed and performance is the same.
 
  • Like
Reactions: weaverinva

leolawliet

Senior Member
Aug 7, 2011
3,441
1,631
New York, NY
www.facebook.com
Is there any possibility of allowing me to test this for a different device that isn't on the compatible list? I like your work :)

1362500614007.png


Sent from my LG-E739 running PenberRom2 using Tapatalk 2
 

mrvek

Senior Member
Feb 10, 2011
579
460
/home
Is there any possibility of allowing me to test this for a different device that isn't on the compatible list? I like your work :)


Sent from my LG-E739 running PenberRom2 using Tapatalk 2

There is no "official" compatibility list :) I tested it only on Milestone 1 which I own, on CM7/9/10, where it worked.
Even though there is no license attached, you are welcome to use it and/or modifiy it to suit your needs ;)

Note: one feature that was never finished is allowing custom size of used swap on partition so not all of it is used (ie, if you created 200MB parition but would like to use e.g. 50MB). Should be easy to implement
Code:
busybox mkswap swap_block_device size_in_KB
 
Last edited:
  • Like
Reactions: leolawliet

leolawliet

Senior Member
Aug 7, 2011
3,441
1,631
New York, NY
www.facebook.com
There is no "official" compatibility list :) I tested it only on Milestone 1 which I own, on CM7/9/10, where it worked.
Even though there is no license attached, you are welcome to use it and/or modifiy it to suit your needs ;)

Note: one feature that was never finished is allowing custom size of used swap on partition so not all of it is used (ie, if you created 200MB parition but would like to use e.g. 50MB). Should be easy to implement
Code:
busybox mkswap swap_block_device size_in_KB

Thank you :D

I just extracted the scripts from the AROMA package and they ran fine, I can confirm that it works flawlessly with /data/ & /cache/ & /system/ on my device, the LG myTouch 4G [E739]

Thanks again :)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 25
    Description:
    A small command line tool to create, delete, enable or disable swap file on sdcard and autostart swap file or partition on boot (zRam (compcache) is configured through system Settings))


    Features:
    - Automatic detection of partitions and files: if you do not have a dedicated swap partition, script uses swapping to file - first on sd-ext and if that one does not exist then it swaps to sdcard. Swap partition takes precedence over files. This should work no matter if you have or do not have ext partition (for app2ext) on sd card.

    - create and delete swap file - you can test different sizes without rebooting

    - ability to start and stop swapping where ever it may be configured: biggest advantage of this is that you can stop swap if you have it on your /sdcard so you can use mass storage mode. Also, you can test various sizes for swap files or how your system works when swap is disabled, without need for a reboot

    - misc. activities: view status of swap partition/files and status of memory

    Usage:
    Code:
    Disable startup:    swapconf 0 -> disables startup script
    Enable startup:     swapconf 1 -> enables startup script
    Create swap file:   swapconf mkf size_in_MB -> creates swap file of specified size (e.g. swapconf mkf 30  for 30MB swap file)
    Remove swap file:   swapconf rmf -> removes previously created swap file
    Start swap:         swapconf start p|f -> starts swapping to partition (p) or file (f)
    Stop swap:          swapconf stop -> stops swapping whereever it may be started
    View swap status:   swapconf status -> view status of swaps and memory
    		
    NOTE: Enabling both swapping to partition and to file is not supported.
    If you have a dedicated swap partition on sdcard it will be used if enabled. Otherwise you need to configure swap file.

    The attachment is OpenRecovery flashable update zip. Simply apply update.
    Startup script should persist across new ROM updates until you do a factory reset (wipe data)

    Feedback is welcome ;)

    Changes for version 0.2:
    - relocated script from /data/local/bin to /system/bin: if your terminal app does not export /data/local/bin to PATH that should not be an issue anymore. Script should still persist across ROM updates [thanks to kabaldan for the tips :)], startup script should persist until you do a factory reset (or you delete/disable it ;)).
    - reworked script commands: previously you were not able to create swap file without enabling startup script
    - improved partitions detection
    - fixed a bug where you could not stop swapping to file if zRam was active
    - mics. fixes and cleanups

    Changes for version 0.2b:
    - fixed backup of swapconf script during ROM upgrade on CM10

    Notes:
    - script will not persist when changing different ROM versions, e.g. from CM7 to CM10
    - kabaldan and Skrilax_CZ have informed me that it is a bad idea to have active swap on sdcard's FAT32 partition unless there is an app that will disable swapping when the sd card is going to be mounted to PC. So far, the only issue I have noticed is that you can not mount USB mass storage mode until you turn off swap so I left that possibility enabled. The choice is yours (btw., it uses fat32 partition only if you have no dedicated swap partition or ext partition).
    5
    If the green LED is kept turned on, device stuck, it has nothing to do with any user space scripts that are scheduled to be executed later during boot.
    There are some 2ndboot issues to be solved yet...
    Until the green LED is turned off, no script could be executed - the green indicates that the current boot is still somewhere between the 2ndboot bootloader and the 2ndboot kernel running, init still not started yet...
    2
    with this script you can config your settings by using the terminal

    my script only aktivate swap and creates a swapfile (if needed), to config my script you must edit the script itself
    2
    Do you have /data/local/bin in your PATH? Or you always navigate to /data/local/bin?

    Try this:
    echo $PATH

    To see if /data/local/bin exists in your path, if not then:

    export PATH= $PATH:/data/local/bin

    after that you wont need "sh" or "./" before swapconf (and you will be able to execute swapconf cmd from everywhere)...

    Remember that this is not permanent PATH export, you need to do that everytime, as mrvek guided me, in terminal's settings there is an option to execute some commands on console startup (similar to .bash_profile) and you should put there "export PATH= $PATH:/data/local/bin" so you don't have to do that every time on console startup.

    Sent from my Milestone using xda app-developers app
    1
    Thanks a lot for the info. :)