Active Topics

 



Notices


Reply
Thread Tools
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#1
Current version: 1.2
---

ereswap 1.2 was just queued into uploading to extras-devel. Changelog:

1.2
  • Fix to another issue preventing system from boot (tried to save reswap stat on optfs, before it's mounted...)
  • Another try to add busybox-power as dependency

1.1
  • Fix for method of validating swap, that could lead to non-bootable device (via faulthy /etc/event.d/rcS-late)
  • Program's folder changed to "/home/user/.config/ereswap/config". Config and rcS-late's adjusters now live there. Changed, due to popular request.
  • Program's executables changed from "ereswap.sh" and "freswap.sh" to "ereswap" and "freswap". Changed, due to popular request.
  • Depends on busybox-power

1.0
  • Initial release.

ereswap is a set of scripts, allowing to detect swap fragmentation and to refresh it. by re-enabling swap, when needed (or doing the latter no matter of conditions, if user decide to).

Swap fragmentation starts to occur, when total number of megabytes written during swap's life time exceed it's maximum size. Until that, swap is written in purely sequential manner (blocks that are no longer needed, are marked as free, but never used) - hoever, after reaching end of swap space, previously used (freed) blocks are rewritten, using new content. This mean no longer writing sequentially, causing massive slowdowns, to already slow (compared to RAM) swap. A workaround to this is to disable and enable swap again - linuxswap filesystem content doesn't live through restarts, and once re-enabled, is written sequentially again.

ereswap achieve it, by counting - via iostat - number of megabytes saved to swap partition during runtime (*not* current swap usage) and comparing it to adjacent numbers during last reswap (or boot). If it's higher than set value, swap is re-enabled, and user informed via Maemo notification system. In case of failure, the same notification system is used to inform user about step, that created problems. Location of swaps and it's sizes are fully configurable.

ereswap is terminal tool as-is, but user can easily create a .desktop shortcuts for it, invoke via QueenBeeconWidget, shortcutd, or any other way. ereswap is easily customizable and extendable - frontend for it could be easily written in any language supported by Maemo (should be trivial to do), also. It can be integrated into other programs with minimum effort required.

ereswap is licensed under terms of GPL (latest). It is provided as-is, without any warranty whatsoever. Using it, You're able to modify critical system components, responsible for booting device - doing it all on your risk. You've been warned.
---

To work properly, ereswap require existence of 2 swap partitions (on microSD or eMMC, all combinations allowed). For maximum performance of Maemo, using swap on microSD *only* and keeping backup, unused swap on eMMC is recommended - the later can be of default size (768 MB), or anything of 200MB or more (in case someone want to repartition and reclaim space for other partitions).
---

Usage:
After installation, edit:

Code:
/home/user/.config/ereswap/config
...providing locations for main swap, it's size, and backup swap. Then, run:

Code:
/home/user/.config/ereswap/adjust-rcS-late.sh
It will adjust Your "/etc/event.d/rcS-late", to - during boot - enable Your main swap and to reset Mb's-written-to-swap counter. This step must be done only once.

Now, at any time, invoke:

Code:
ereswap
...from terminal. It will check counter and inform You about amount of data left before hitting swap fragmentation (or any arbitrary value set in config file), or, how many Mb's after it You are. In second case, it will also re-enable swap.

To re-enable swap at any time, unconditionally, invoke:

Code:
freswap
...it's useful, if You're close to hit limit, and planning to do memory-hungry stuff.

If You ever change Your swap's location, just edit config file and invoke:

Code:
/home/user/.config/ereswap/update-rcS-late.sh
It will update Your rcS-late with respect to new swap locations and/or size.
---

Note about change done to rcS-late, after invoking adjust-rcS-late:

This script replaces line:

Code:
swapon -a || "Failed to enable paging partition"
...with a superior code, that tries to enable our main swap and in case of failure (for example, it's partition on microSD, and the latter got screwed), it enables backup swap. This approach ensures, that no reboot loop will occur, in case of swap failures - as long as user provide sane settings (using main and backup swap on, lets say, same microSD card isn't most failsafe solution, for example).

Patching rcS-late was thoroughly tested, yet, for maximum safety, backup it before adjusting.
---

Credits:

Thanks to shadowjk for swap refreshing concept and proof' implementation.
Thanks to Hurrian for pointing to a concept of backup swap mechanism in rcS-late, created by GameboyRMH.
Huge thanks for merlin1991, DocScrutinizer, Sicelo and everyone else answering my countless questions and providing working code samples on #maemo. Guys, You rox! Also, thanks to merlin1991 (again) and X-Fade, for help with proper packaging.
Especially huge thanks for Sc0rpius, for sitting with me for hours and working to fix sed's commands in update/adjust-rcS-late.sh scripts. I would be nowhere, without Your help!
---

FAQ:
---

Q: Something went wrong with my main swap, and backup swap got enabled. Why ereswap doesn't properly count Mb's to hit swap fragmentation?
A: It's by design - written data counter is *always* set to Your main swap. Using backup swap is just a failsafe, and everything is done to make You know about it, the sooner, the better. If You can't fix issue with main swap quickly, yet, you desperately need capabilities to refresh swap, either use freswap, or edit config, and enable Your backup swap as main.

Q: I changed my swap layout, so I wanted to run update-rcS-late.sh, but, by mistake, I've executed adjust-rcS-late.sh, on already patched rcS-late! Is my rcS-late damaged? will I get into bootloop, after reboot?
A: Scripts are written in an intelligent way, that should result on absolutely no problems, after executing on wrong version of rcS-late (i.e. trying to update stock rcS-late, or trying to patch already adjusted one) - script will end with exit 0 (success), but without commuting changes to file.

For maximum safety, You may want to restore rcS-late from backup, though. Also, I can't predict what will happen, if You use any of rcS-late patcher scripts on custom-modified rcS-late (one modified *not* by this program) - generally, You should be ok, as long as default swap enabling line wasn't changed, but be extra careful in such case.
---

First post will be updated when appropriate (with notes left as post, inside this thread). ereswap's wiki page is:
http://wiki.maemo.org/Ereswap
(courtesy of sixwheeledbeast).

/Estel
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!

Last edited by Estel; 2012-05-28 at 03:21.
 

The Following 39 Users Say Thank You to Estel For This Useful Post:
Posts: 1,163 | Thanked: 1,873 times | Joined on Feb 2011 @ The Netherlands
#2
Congratz, on your first package, Estel
Will test it later, probably tonight
 

The Following User Says Thank You to mr_pingu For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#3
Originally Posted by Estel View Post
Code:
/home/user/.ereswap/update-rcS-late.sh
It's better to keep scripts/executables/etc. outside of /home/user, as it's not touched during a reflash, unless you reflash emmc. Thus, after reflash user has the package's files but the package itself is not installed.

Cfg files can be left there as they do not occupy much space and it's nice to have ur cfg after reflash
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 

The Following 6 Users Say Thank You to marmistrz For This Useful Post:
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#4
@mr_pingu
Thank You In fact, it's 2nd package - Truecrypt was first, but I agree, as it was different case (code already provided).

@marmistrz
Good point. As it's rather minor issue, I'll add it to things needed adjusting with new version.

/Estel
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!
 

The Following User Says Thank You to Estel For This Useful Post:
Posts: 1,225 | Thanked: 1,905 times | Joined on Feb 2011 @ Quezon City, Philippines
#5
Cool scripts, definitely looking into finding a way to automate these on my phone.

BTW, I would suggest keeping the config in ~/.config/ereswap, if just to follow other programs.

Also, it'd be nicer if you named the scripts ereswap and freswap (remove .sh at the end) - it looks slightly cleaner, and it doesn't matter since they're chmod +x anyway.
__________________
N9 PR 1.3 Open Mode + kernel-plus for Harmattan
@kenweknot, working on Glacier for Nemo.
 
Posts: 293 | Thanked: 163 times | Joined on Jan 2012 @ beijing-islamabad
#6
i believe this is great script ,there have been a lot of swap memory issues ,i hope in future there will be such programmes which could easily save the swap memory by keeping the running processes intact and less swap consuming , will test it asap !
 
Posts: 372 | Thanked: 61 times | Joined on Jan 2012
#7
so this will reduce lags. i have no emmc. for this to work the first thing i need to do before install it from the repos is repartioning my emmc? :s

can anyone give me the link on how to do that.

i read the first post thoroughly. i know this is not for noobs like me. bt i understood that its gonna make my N900 more responsive and fast. my device is overclocked to 900 mhz ideal but sometimes it lags like hell. i dunno y. as N900 is my primary device. i need to make my device more responsive. so plz if anyone got angry by this post. i am sorry. just ignore it then. but for others. plz be normal and help me if possible to do this.
 

The Following 2 Users Say Thank You to Mohammed Muid For This Useful Post:
Posts: 2,290 | Thanked: 4,134 times | Joined on Apr 2010 @ UK
#8
Originally Posted by Mohammed Muid View Post
my device is overclocked to 900 mhz ideal but sometimes it lags like hell.
You need to backup and reflash your device.
__________________

Wiki Admin
sixwheeledbeast's wiki
Testing Squad Subscriber
- mcallerx - tenminutecore - FlopSwap - Qnotted - zzztop - Bander - Fight2048 -


Before posting or starting a thread please try this.
 
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#9
Originally Posted by Mohammed Muid View Post
so this will reduce lags. i have no emmc. for this to work the first thing i need to do before install it from the repos is repartioning my emmc? :s

can anyone give me the link on how to do that.

i read the first post thoroughly. i know this is not for noobs like me. bt i understood that its gonna make my N900 more responsive and fast. my device is overclocked to 900 mhz ideal but sometimes it lags like hell. i dunno y. as N900 is my primary device. i need to make my device more responsive. so plz if anyone got angry by this post. i am sorry. just ignore it then. but for others. plz be normal and help me if possible to do this.
after how much time does it lag?
are you using maxcpu (or something with similar name)
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 
Posts: 1,163 | Thanked: 1,873 times | Joined on Feb 2011 @ The Netherlands
#10
Seems to working fine, however got one minor issue/bug

Code:
~/.ereswap $ sudo gainroot
Root shell enabled


BusyBox v1.20.0 (Debian 1.20.0power1) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/home/user/.ereswap # ereswap.sh
cat: can't open 'reswap.stat': No such file or directory
Not needed, we have  735  MB left.
/home/user/.ereswap #
However, it functions very nice judging from conky
__________________
N900 loaded with:
CSSU-T (Thumb)
720p recording,
Pierogi, Lanterne, Cooktimer, Frogatto
N9 16GB loaded with:
Kernel-Plus
--
[TCPdump & libpcap | ngrep]
--
donate
 

The Following 4 Users Say Thank You to mr_pingu For This Useful Post:
Reply

Tags
ereswap, fragmentation, microsd, swappiness, swaps


 
Forum Jump


All times are GMT. The time now is 05:56.