maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   additional swap file (https://talk.maemo.org/showthread.php?t=86752)

TMavica 2012-09-23 09:37

Re: additional swap file
 
swapon with count 2097152, the phone got unresponsive, but if set 1048756, then is fine for me...

death_jax 2012-09-23 09:49

Re: additional swap file
 
Quote:

Originally Posted by thedead1440 (Post 1270951)
No no you don't need any packages... All these are system commands...

also if you read what you downloaded you would know they are bash scripts so you either leave them without any file extension or rename them to .sh

Yes, I know that are bash scripts, for this reason I ask if I should rename them before chmod (but why aren't directly in .sh instead of .txt? :D).. however, mkswap and swapon/swapoff aren't recognized (are not found)..

EDIT: They are /sbin/mkswap, /sbin/swapon and /sbin/swapoff..

TMavica 2012-09-23 10:02

Re: additional swap file
 
Quote:

Originally Posted by death_jax (Post 1270967)
Yes, I know that are bash scripts, for this reason I ask if I should rename them before chmod (but why aren't directly in .sh instead of .txt? :D).. however, mkswap and swapon/swapoff aren't recognized (are not found)..

/sbin/swapon, /sbin/swapoff, /sbin/mkswap

death_jax 2012-09-23 10:03

Re: additional swap file
 
Quote:

Originally Posted by TMavica (Post 1270974)
/sbin/swapon, /sbin/swapoff, /sbin/mkswap

We wrote at the same time :D

PS: Ok, now the only problem is sudo installation.
Didn't I can create swap file only from devel-su root user?

thedead1440 2012-09-23 10:13

Re: additional swap file
 
devel-su is sufficient...

death_jax 2012-09-23 10:15

Re: additional swap file
 
Quote:

Originally Posted by thedead1440 (Post 1270979)
devel-su is sufficient...

Ok perfect, at work to swap now :D

PS: My "real" swap (that is in ram) is always free (255 of 255 MB).. I think that the extra swap doesn't change the speed for me :D :D

PS2: How can I add /sbin/mkswap, /sbin/swapon and /sbin/swapoff to system var, because the scripts uses mkswap, swapon and swapoff instead of that described above?

EDIT: Until solution for PS2 request, I edited scripts with /sbin/ before swapon/swapoff command and now works.. in fact drop cache show me 2303 of 2303 MB free :D :D

thedead1440 2012-09-23 10:38

Re: additional swap file
 
see when you do the swap part yourself u need to use it with /sbin but once you copied the script to /etc you don't need to use /sbin the system works this way ;)

death_jax 2012-09-23 10:51

Re: additional swap file
 
Quote:

Originally Posted by thedead1440 (Post 1270990)
see when you do the swap part yourself u need to use it with /sbin but once you copied the script to /etc you don't need to use /sbin the system works this way ;)

Ok, this should be true with swap-add.conf, but doesn't work with setswap0 and rmswap0 because when I run one of them show me swapon or swapoff: not found.
Only if I modify them with /sbin/ before, they works.

thedead1440 2012-09-23 11:04

Re: additional swap file
 
Yes correct...The setswap0 and rmswap0 are not copied into etc so that's why you need to use /sbin

For swap-add.conf its in /etc so no need the /sbin

Also I personally find it easier to swapon/off on-demand instead of using the setswap0 and rmswap0 files as the file too is 1 line of command and to run the sh script you also need to type one line of command...

Ofcourse you can also do it in such a way that create 2 .desktop files that do swapon/off...the exec can be /sbin/swapon(off) and you are set ;)

death_jax 2012-09-23 11:10

Re: additional swap file
 
Quote:

Originally Posted by thedead1440 (Post 1271002)
Yes correct...The setswap0 and rmswap0 are not copied into etc so that's why you need to use /sbin

For swap-add.conf its in /etc so no need the /sbin

Also I personally find it easier to swapon/off on-demand instead of using the setswap0 and rmswap0 files as the file too is 1 line of command and to run the sh script you also need to type one line of command...

Ofcourse you can also do it in such a way that create 2 .desktop files that do swapon/off...the exec can be /sbin/swapon(off) and you are set ;)

Yes, It's an idea :cool:

PS: But why swapon/swapoff scripts in firts post are incorrect? It would be better correct them for who want to try this tweak?

rainisto 2012-09-23 12:41

Re: additional swap file
 
I made more advanded tutorial howto enable the unused mtd partition as swap. With this method you can freely still use the mass-storage mode.

Disclaimer: you can brick your device if you don't have opensh and don't follow instructions carefully.

RM696-21-3_PR_001:~# devel-su
RM696-21-3_PR_001:~# opensh
RM696-21-3_PR_001:~# accli -I |grep tcb-sign
aegis-enabler::tcb-sign <--- If grep doesn't find this line then you have to STOP and not go further.
RM696-21-3_PR_001:~# free
total used free shared buffers
Mem: 1008648 803080 205568 0 33580
-/+ buffers: 769500 239148
Swap: 262136 54012 208124
RM696-21-3_PR_001:/# cp /etc/init/enable-swap.conf /tmp/enable-swap.conf
RM696-21-3_PR_001:/# vi /tmp/enable-swap.conf
# make editions on 2 lines that is mentioned in my earlier patch that I posted here. http://pastebin.com/raw.php?i=8rS81vUX
RM696-21-3_PR_001:/# cp /tmp/enable-swap.conf /etc/init/enable-swap.conf
RM696-21-3_PR_001:/# export A=`sha1sum /tmp/enable-swap.conf |cut -b1-40`;
RM696-21-3_PR_001:/# perl -pi -w -e 's#40 (.*) A(.*)enable-swap#40 $ENV{A} A$2enable-swap#smg' /var/lib/aegis/refhashlist
RM696-21-3_PR_001:/# accli -c tcb-sign -F /var/lib/aegis/refhashlist -i /var/lib/aegis/refhashlist
RM696-21-3_PR_001:/# /usr/sbin/validator-init; aegis-loader;echo 1 > /sys/kernel/security/validator/flush
RM696-21-3_PR_001:~# reboot
# wait system to reboot and login again:
RM696-21-3_PR_001:~# free
total used free shared buffers
Mem: 1008648 478264 530384 0 24040
-/+ buffers: 454224 554424
Swap: 444664 0 444664


As you can see after reboot you have about 530MB free ram which is 256MB more than before, and swap file is now the 450MB mtd partiotion which was previously unused by the device.

I'm not going to make comparision if onenand mtd partition is faster than mass storage flash partition. If pages are cached in either flash its going to be a bit slower than ramz.

Performance benefit of this is that you have 256MB more ram to play with, and if your not running over 15 apps simultaneously then most likely this increased amount of ram will make your device faster, since its more unlikely that system needs to page your background apps in swap :)

death_jax 2012-09-24 08:25

Re: additional swap file
 
Quote:

Originally Posted by rainisto (Post 1271033)
I made more advanded tutorial howto enable the unused mtd partition as swap. With this method you can freely still use the mass-storage mode.

Disclaimer: you can brick your device if you don't have opensh and don't follow instructions carefully.

RM696-21-3_PR_001:~# opensh
RM696-21-3_PR_001:~# free
total used free shared buffers
Mem: 1008648 803080 205568 0 33580
-/+ buffers: 769500 239148
Swap: 262136 54012 208124
RM696-21-3_PR_001:/# cp /etc/init/enable-swap.conf /tmp/enable-swap.conf
RM696-21-3_PR_001:/# vi /tmp/enable-swap.conf
# make editions on 2 lines that is mentioned in my earlier patch that I posted here.
RM696-21-3_PR_001:/# cp /tmp/enable-swap.conf /etc/init/enable-swap.conf
RM696-21-3_PR_001:/# export A=`sha1sum /tmp/enable-swap.conf |cut -b1-40`;
RM696-21-3_PR_001:/# perl -pi -w -e 's#40 (.*) A(.*)enable-swap#40 $ENV{A} A$2enable-swap#smg' /var/lib/aegis/refhashlist
RM696-21-3_PR_001:/# accli -c tcb-sign -F /var/lib/aegis/refhashlist -i /var/lib/aegis/refhashlist
RM696-21-3_PR_001:/# validator-init; aegis-loader;echo 1 > /sys/kernel/security/validator/flush
RM696-21-3_PR_001:~# reboot
# wait system to reboot and login again:
RM696-21-3_PR_001:~# free
total used free shared buffers
Mem: 1008648 478264 530384 0 24040
-/+ buffers: 454224 554424
Swap: 444664 0 444664


As you can see after reboot you have about 530MB free ram which is 256MB more than before, and swap file is now the 450MB mtd partiotion which was previously unused by the device.

I'm not going to make comparision if onenand mtd partition is faster than mass storage flash partition. If pages are cached in either flash its going to be a bit slower than ramz.

Performance benefit of this is that you have 256MB more ram to play with, and if your not running over 15 apps simultaneously then most likely this increased amount of ram will make your device faster, since its more unlikely that system needs to page your background apps in swap :)

To avoid bricking the phone, is it possible to explain "make editions on 2 lines that is mentioned in my earlier patch that I posted here."?
And after applying this tweak, how is possible to return to ramz?

thedead1440 2012-10-07 12:12

Re: additional swap file
 
rainisto,

Thanks for your method! I just did a re-flash so switched over to using the mtd block for swap...Since I'm in open mode I had to make the 2 editions and it was done...

However, I would like to know what happens to the ramzswap0 that existed before? It doesn't look to be added into the RAM as my RAM memory usage is quite similar to what it was before...death_jax has also confirmed he got the same...



Thanks!

thedead1440 2012-10-11 15:24

Re: additional swap file
 
bumping to get rainisto's attention :D

rainisto 2012-10-11 18:36

Re: additional swap file
 
if you applied patch successfully after reboot there is no ramzswap0 anymore, if nothing has changed then most likely you didn't follow the steps right. (and if you want things to work without reboot, you actually need to patch 3 lines)

If you want to return to ramzswap0 just reverse apply the patch.

thedead1440 2012-10-12 02:58

Re: additional swap file
 
my output of free:

Code:

~# free
            total        used        free      shared      buffers
Mem:      1008108      888448      119660            0        40448
-/+ buffers:            848000      160108
Swap:      422136        13560      408576


So swap has certainly changed as I mentioned earlier...I just meant that the free RAM you had after doing the same is it due to doing this or due to you rebooting your phone...


When I use drop cache to free all, my free increases to:

Code:

# sh /opt/dropcache-mdn/bin/dropcache.sh --3
~# free
            total        used        free      shared      buffers
Mem:      1008108      650764      357344            0          640
-/+ buffers:            650124      357984
Swap:      422136        13560      408576


So the only difference between your total output compared to mine is:

you have additional 22528kB swap and 540kB RAM...

I understand what you mean on ramzswap0...

rainisto 2012-10-12 04:45

Re: additional swap file
 
Well it is what it should be, maybe I should explain a bit more if people don't understand the change:

N9 has 1024MB RAM in the device which is valid in both cases.

By default if you don't edit the script, when device boots up, it reserves 256MB of it as ramzswap0, so effectively your device has 768MB of RAM for your application pages and 256MB of swap for compressed pages.

With the edited script you have 1024MB of RAM for your application pages and 422MB of swap for encrypted compressed pages.

You do the math.

PS. running dropcache makes your fileaccess operations slower, so you shouldn't really use that one unless you want to slow your device down.

death_jax 2012-10-12 11:25

Re: additional swap file
 
Quote:

Originally Posted by rainisto (Post 1279561)
Well it is what it should be, maybe I should explain a bit more if people don't understand the change:

N9 has 1024MB RAM in the device which is valid in both cases.

By default if you don't edit the script, when device boots up, it reserves 256MB of it as ramzswap0, so effectively your device has 768MB of RAM for your application pages and 256MB of swap for compressed pages.

With the edited script you have 1024MB of RAM for your application pages and 422MB of swap for encrypted compressed pages.

You do the math.

PS. running dropcache makes your fileaccess operations slower, so you shouldn't really use that one unless you want to slow your device down.

Thanks for explanation; but with the above you mean that if before the tweak I had about 500MB of free RAM and after the tweak (and reboot) I always had about 500MB, is it normal and makes it sense?

PS: Why (and how) DropCache can slow down the device?

rainisto 2012-10-12 12:10

Re: additional swap file
 
Yes it is normal. It just means that linux system uses more of the free ram in filecache, ie making your load times faster (it automaticly uses less ram for files if free amount drops to certain levels).

Linux holds the most recently used files in the ram cache so subsequential loads of the same files are really fast, if you use dropcache it drops the recently used files out of the ram, and thus if apps loads some files, it needs to access the flash vs ram to load the file, ie it makes loading slower (also affects application startup times). So in short people using dropcache are just newbies :)

For further reading you should read this: http://www.linuxatemyram.com/

death_jax 2012-10-12 12:52

Re: additional swap file
 
Quote:

Originally Posted by rainisto (Post 1279702)
Yes it is normal. It just means that linux system uses more of the free ram in filecache, ie making your load times faster (it automaticly uses less ram for files if free amount drops to certain levels).

Linux holds the most recently used files in the ram cache so subsequential loads of the same files are really fast, if you use dropcache it drops the recently used files out of the ram, and thus if apps loads some files, it needs to access the flash vs ram to load the file, ie it makes loading slower (also affects application startup times). So in short people using dropcache are just newbies :)

For further reading you should read this: http://www.linuxatemyram.com/

Ok I know it, I thought there was other reasons.. however, I use DropCache, for example, after a game, because with this one the ram fills up fastly :D, and also because I would not do again that game immediately (therefore it is useless to remain in ram)

Akkumaru 2012-10-29 13:34

Re: additional swap file
 
What is the 2 editions?

thedead1440 2012-10-29 13:52

Re: additional swap file
 
Quote:

Originally Posted by Akkumaru (Post 1287083)
What is the 2 editions?

http://pastebin.com/raw.php?i=8rS81vUX from the second page...

Be careful with what you do!

Akkumaru 2012-10-29 13:53

Re: additional swap file
 
Quote:

Originally Posted by thedead1440 (Post 1287089)
http://pastebin.com/raw.php?i=8rS81vUX from the second page...

Be careful with what you do!

I've been on that page, can you post a screenshot of your enable-swap.conf?

death_jax 2012-10-29 14:09

Re: additional swap file
 
Quote:

Originally Posted by Akkumaru (Post 1287090)
I've been on that page, can you post a screenshot of your enable-swap.conf?

You should edit (part of) two lines in the enable-swap.conf file:

  • if [ $ramsize -gt 1000000 ]; then

    to

    if [ $ramsize -gt 1100000 ]; then

  • swappart=`sed -n -e '/swap/s/mtd\([0-9]\).*/\1/p' /proc/mtd` || true

    to

    swappart=`sed -n -e '/var/s/mtd\([0-9]\).*/\1/p' /proc/mtd` || true

thedead1440 2012-10-29 14:10

Re: additional swap file
 
Caution:

I am not responsible for your actions: http://pastebin.com/EE9GTBNV

Akkumaru 2012-10-29 14:18

Re: additional swap file
 
Thanks thedead1440 and death_jax! It worked!

ThraxZzz 2012-10-29 14:31

Re: additional swap file
 
still work after a reboot?

Akkumaru 2012-10-29 14:32

Re: additional swap file
 
I NEED URGENT HELP, validator-init NOT FOUND?

thedead1440 2012-10-29 14:32

Re: additional swap file
 
Quote:

Originally Posted by ThraxZzz (Post 1287117)
still work after a reboot?

If you use open mode it does...If you use normal mode and have inception you can use rainisto's full method to make it stick even after a reboot or use aegisctl and refhashlist...


edit:

my current free:

Code:

~# free
            total        used        free      shared      buffers
Mem:      1008108      753528      254580            0        12972
-/+ buffers:            740556      267552
Swap:      422136      164016      258120


ThraxZzz 2012-10-29 14:37

Re: additional swap file
 
Shall try this tomorrow,bed is calling me now :p Goodnight (asian)

thedead1440 2012-10-29 14:37

Re: additional swap file
 
Quote:

Originally Posted by ThraxZzz (Post 1287123)
Shall try this tomorrow,bed is calling me now :p Goodnight (asian)

Yup but its 2237 only :p

Anyway good luck with it :D

ThraxZzz 2012-10-29 14:39

Re: additional swap file
 
Haha! Gotta wake up early :p

hah! Thanks,will post results soon :)

thedead1440 2012-10-29 14:39

Re: additional swap file
 
Quote:

Originally Posted by Akkumaru (Post 1287119)
I NEED URGENT HELP, validator-init NOT FOUND?

oops you screwed the earlier step most probably...

Akkumaru 2012-10-29 14:43

Re: additional swap file
 
If I reboot will this brick my phone?

thedead1440 2012-10-29 14:49

Re: additional swap file
 
Quote:

Originally Posted by Akkumaru (Post 1287129)
If I reboot will this brick my phone?

A reboot now will give you device not working error which can be repaired I think only either via fix malf state or by reflash...

Akkumaru 2012-10-29 14:53

Re: additional swap file
 
Wait a second, I tried the reboot command, and it doesn't work.

thedead1440 2012-10-29 14:54

Re: additional swap file
 
Akkumaru,

repeat the steps again calmly and you should be fine :)

Oh and you are doing all this in opensh right?

Akkumaru 2012-10-29 14:56

Re: additional swap file
 
Yes i am, but reboot doesn't work either.

thedead1440 2012-10-29 14:57

Re: additional swap file
 
Quote:

Originally Posted by Akkumaru (Post 1287137)
Yes i am, but reboot doesn't work either.

do /sbin/reboot

Akkumaru 2012-10-29 15:07

Re: additional swap file
 
I will redo all steps, will post result.


All times are GMT. The time now is 00:08.

vBulletin® Version 3.8.8