[SWAP] Swap on Internal * v0.5 alpha *

Search This thread

impactor

Senior Member
Jan 6, 2011
906
136
Kraków
SWAP on internal
Extend your RAM with very quick internal SWAP
v0.5 alpha​



For the moment, the script is confirmed to work only on ROMs with the chinese x-part (or data2ext) by Atroy script only (read at the end of this post for alternative).
The only ROM I am aware of using this script out of the box is the excellent MIUI XJ x-part.
However, I intend to develop a non-loop based version shortly. It should will be compatible with most ROMs, so stay tuned.


What and Why
I decided to make a script that places the swap file on internal memory. Many people place it on SD card, but to me it seems somewhat pointless, as it hardly offers sufficient performance.
However, placing it on the internal memory makes it a much more interesting concept, because it has much better random read/write performance than even the fastest SD cards.


Warning: placing SWAP on internal memory will subject it to frequent read/write operations which in theory shortens lifespan of internal memory chip which you cannot replace. This is because flash memory has limited number of write/read cycles to it. So, consider yourself warned.


HOWEVER:
1 - although true, in reality I have been unable to find any case of this actually affecting anyone's phone. There is very limited amount of data documenting real-life effect of that process, but most likely your device will be long gone before the internal memory will show any signs of wear.
2 - the script recreates the swap file on each boot using different physical blocks of memory - this means not the same blocks are always used. More on this in 'Do it right' section.



Do It Right

1. 16-32 MB of swap should suffice. If you think you need more, you are probably wrong. NEVER use all available internal space. The larger the proportion difference between swap size and total free space on the internal data partition, the more breathing space your internal memory gets, as this allows the swap file to be moved around upon every reboot, which, in turn, will make it use the same blocks more rarely, and thus extending memory chip lifespan.

2. Get rid of bloat you don't use from the system partition, ie: ringtones, live wallpapers, useless system apps. Then create a custom
hboot with smaller system partition and larger data partition. You can do it using this (also attached to this post).

3. Play around with swappiness parameter. Still, the default set by the script should serve you well. But if you are paranoid, you can use it to further decrease how often system will write to swap.


Removal
Disable execution flag on the scipt in /system/etc/init.d and delete swap.img from internal data directory (on x-part scripts it is /mnt/asec/mtddata/ )



v0.5 alpha
* first public release
* loop device version only


x-part Impacted script (80% chance of rendering your ROM unbootable)
I attached a data2ext script which should offer better performance and battery life than some other a2sd scripts.
You are free to try and flash it on your ROM, but there is a good chance it won't boot any more - this is a very alpha version and I am not working on it at the moment.
Do not post complaints about it here. I only want to hear from you if it works!
 

Attachments

  • swap-internal_v0.5a-xpart.zip
    196.8 KB · Views: 177
  • x-part_impacted_v0.1_alpha.zip
    3.8 MB · Views: 86
  • cutom_hboot_maker.zip
    998.8 KB · Views: 86
Last edited:

Androidmarketuser

Senior Member
Oct 21, 2010
330
203
This sounds really good to my ears :good:
I will keep an eye on it.
Edit:
A small question:
So is it possible to use this for any rom if you are using data2ext for it?
Or atm only for miui xj?
 
Last edited:

impactor

Senior Member
Jan 6, 2011
906
136
Kraków
A small question:
So is it possible to use this for any rom if you are using data2ext for it?
Or atm only for miui xj?
You have to use Atroy's data2ext, which is virtually impossible to obtain because it was developed as part of chinese MIUI rom and never released as a separate script.

However, I have been working on it and I am attaching an alpha version of my adaptation of this script to the first post
Let me know if it works, but there is a good chance your ROM will not boot any more.
 
  • Like
Reactions: Androidmarketuser

Androidmarketuser

Senior Member
Oct 21, 2010
330
203
However, I have been working on it and I am attaching an alpha version of my adaptation of this script to the first post
Let me know if it works, but there is a good chance your ROM will not boot any more.

Thanks for your answer :)
I tried to install it on CM10 by vj but it didn't work. Here are my steps:
Wiped everything except sd
Installed rom, then data2ext script and finally the swap script.
I'm on a ext4 partition if it matters.
I think (not really sure) one script has created two folders: /data/ and /data-app/ on sdcard.
Or did I just install it the wrong way?

Edit: The problem was as you expected that it stucked at HTC bootlogo.
 

Androidmarketuser

Senior Member
Oct 21, 2010
330
203
If you want to try x-part script, then do not flash swap script until you confirm the x-part rom works.
Try with some GB rom. Maybe you'll have more luck.

I'll try it out that way on JB first (I am addicted to the new design, can't go back:crying:), if it doesn't work I will try it out with 2.3 anyway.

---------- Post added at 08:45 PM ---------- Previous post was at 08:31 PM ----------

Ok on JB the data2ext script doesn't seem to work, I can't boot.
I will try it out later with a GB rom, propably EuroSkank
 

vasili_defy

Senior Member
Feb 10, 2011
548
89
Custom hboot maker link from thalasmus blog is dead!
Can someone plz attach it here! :confused:

Sent from my HTC Desire using xda app-developers app
 

topgeardave

Senior Member
Aug 5, 2011
1,430
603
Don't have swap on internal! The number of read/writes will just kill your nand by creating loads of bad blocks.
Just my 2 cents

Kind Regards
Dave
 

topgeardave

Senior Member
Aug 5, 2011
1,430
603
And pray tell, apart from hearsay, what else do you have to support the claim that it will occur within foreseeable lifetime of the device?
I'd love to learn.

After flashing ROMs on my Desire for nearly 2 years I'm starting to get bad blocks on my nand. Having a swap partition on internal would accelerate the process of getting more bad blocks. That's what I think anyway. Check your recovery.log for bad blocks next time you wipe your phone.
Kind Regards
Dave :)


Sent from my HTC Sensation using xda app-developers app
 

impactor

Senior Member
Jan 6, 2011
906
136
Kraków
After flashing ROMs on my Desire for nearly 2 years I'm starting to get bad blocks on my nand. Having a swap partition on internal would accelerate the process of getting more bad blocks. That's what I think anyway. Check your recovery.log for bad blocks next time you wipe your phone.
Kind Regards
Dave :)
Thanks for the heads-up. But I gave a clear warning about in the first post. After two years, my desire has 4 bad blocks, which amounts to less than 0.5mb of internal space (less than 0.1%). Everyone should make a concious decision about using internal swap.

It will degrade the memory chip, yes, but is the degradation significant enough to care? Everyone has to decide for himself.
 
Last edited:

Balino

Senior Member
Mar 3, 2011
1,720
593
29
Gaeta
Thanks for the heads-up. But I gave a clear warning about in the first post. After two years, my desire has 4 bad blocks, which amounts to less than 0.5mb of internal space (less than 0.1%). Everyone should make a concious decision about using internal swap.

It will degrade the memory chip, yes, but is the degradation significant enough to care? Everyone has to decide for himself.

how can I check if it's running on my rom...?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    SWAP on internal
    Extend your RAM with very quick internal SWAP
    v0.5 alpha​



    For the moment, the script is confirmed to work only on ROMs with the chinese x-part (or data2ext) by Atroy script only (read at the end of this post for alternative).
    The only ROM I am aware of using this script out of the box is the excellent MIUI XJ x-part.
    However, I intend to develop a non-loop based version shortly. It should will be compatible with most ROMs, so stay tuned.


    What and Why
    I decided to make a script that places the swap file on internal memory. Many people place it on SD card, but to me it seems somewhat pointless, as it hardly offers sufficient performance.
    However, placing it on the internal memory makes it a much more interesting concept, because it has much better random read/write performance than even the fastest SD cards.


    Warning: placing SWAP on internal memory will subject it to frequent read/write operations which in theory shortens lifespan of internal memory chip which you cannot replace. This is because flash memory has limited number of write/read cycles to it. So, consider yourself warned.


    HOWEVER:
    1 - although true, in reality I have been unable to find any case of this actually affecting anyone's phone. There is very limited amount of data documenting real-life effect of that process, but most likely your device will be long gone before the internal memory will show any signs of wear.
    2 - the script recreates the swap file on each boot using different physical blocks of memory - this means not the same blocks are always used. More on this in 'Do it right' section.



    Do It Right

    1. 16-32 MB of swap should suffice. If you think you need more, you are probably wrong. NEVER use all available internal space. The larger the proportion difference between swap size and total free space on the internal data partition, the more breathing space your internal memory gets, as this allows the swap file to be moved around upon every reboot, which, in turn, will make it use the same blocks more rarely, and thus extending memory chip lifespan.

    2. Get rid of bloat you don't use from the system partition, ie: ringtones, live wallpapers, useless system apps. Then create a custom
    hboot with smaller system partition and larger data partition. You can do it using this (also attached to this post).

    3. Play around with swappiness parameter. Still, the default set by the script should serve you well. But if you are paranoid, you can use it to further decrease how often system will write to swap.


    Removal
    Disable execution flag on the scipt in /system/etc/init.d and delete swap.img from internal data directory (on x-part scripts it is /mnt/asec/mtddata/ )



    v0.5 alpha
    * first public release
    * loop device version only


    x-part Impacted script (80% chance of rendering your ROM unbootable)
    I attached a data2ext script which should offer better performance and battery life than some other a2sd scripts.
    You are free to try and flash it on your ROM, but there is a good chance it won't boot any more - this is a very alpha version and I am not working on it at the moment.
    Do not post complaints about it here. I only want to hear from you if it works!
    1
    A small question:
    So is it possible to use this for any rom if you are using data2ext for it?
    Or atm only for miui xj?
    You have to use Atroy's data2ext, which is virtually impossible to obtain because it was developed as part of chinese MIUI rom and never released as a separate script.

    However, I have been working on it and I am attaching an alpha version of my adaptation of this script to the first post
    Let me know if it works, but there is a good chance your ROM will not boot any more.
    1
    Custom hboot maker link from thalasmus blog is dead!
    Can someone plz attach it here! :confused:
    Attached.