How to SWAP for tattoo - Click Android Development

Warning : It can (and will) shorten SD or NAND lifespan.
A little tutorial for those who want to try swap on their tattoo without decreasing the life of their sd card.
Download the file attached here, or here.
And then do this :
Code:
adb shell "mkdir /data/swap"
adb push swapfile.swp /data/swap
adb shell
mkswap /data/swap/swapfile.swp
losetup /dev/block/loop0 /data/swap/swapfile.swp
swapon /dev/block/loop0
free ( to check if its running)
If you want to use it on the SD :
Code:
adb push swapfile.swp /sdcard/
adb shell
mkswap /sdcard/swapfile.swp
losetup /dev/block/loop0 /sdcard/swapfile.swp
swapon /dev/block/loop0
free ( to check if its running)
Keep in mind you must do losetup and swapon after each reboot.
Have been testing it for a while. No problems till now and delivers a very noticeable speed increase.

Thank you very much igstoian.
I'm gonna use it in my ROM if you don't mind.

Great that I can help.
Also post your experience with it. How is the speed gain?

Maybe this is a dumb question, but is it possible to enable swap even if my phone does not have custom boot.img??
I've rooted it, but not permanently (after a reboot I have to run the exploit again and I don't want to take the risk to brick it).
/Edit: WTF?! It's blazing fast Thank you!

Then you have to run the exploit and enable swap on every reboot if you want it...

You are actually using the data partitions for swap? And you think that increases SD card life? Sure it does, but what about the NAND flash that our data partition is, and has poorer life anyway than the damn 10 buck SDcard!?

eyegor said:
You are actually using the data partitions for swap? And you think that increases SD card life? Sure it does, but what about the NAND flash that our data partition is, and has poorer life anyway than the damn 10 buck SDcard!?
Click to expand...
Click to collapse
right
guess it's still too hard to change internal storages

It would be better to use a swap partition? A file is not the same as a partition.
Testing, swap file in system memory:
-a full day of use, the swap is 3 mb.
-30 programs loading into memory, the swap is less than 4 mb of use.
The use made is at least equal to a partition could increase. Or helping the compcache (I haven´t compcache)

It doesnt matter if its a file or a partition. you write files to a partition or you write info to a file. its still writing and its the read-write cycles that damages memory, not the amount of files being written.

lgstoian said:
Warning : It can (and will) shorten SD or NAND lifespan.
A little tutorial for those who want to try swap on their tattoo without decreasing the life of their sd card.
Download the file attached here, or here.
And then do this :
Code:
adb shell "mkdir /data/swap"
adb push swapfile.swp /data/swap
adb shell
mkswap /data/swap/swapfile.swp
losetup /dev/block/loop0 /data/swap/swapfile.swp
swapon /dev/block/loop0
free ( to check if its running)
If you want to use it on the SD :
Code:
adb push swapfile.swp /sdcard/
adb shell
mkswap /sdcard/swapfile.swp
losetup /dev/block/loop0 /sdcard/swapfile.swp
swapon /dev/block/loop0
free ( to check if its running)
Keep in mind you must do losetup and swapon after each reboot.
Have been testing it for a while. No problems till now and delivers a very noticeable speed increase.
Click to expand...
Click to collapse
Thankyo lgstoian for this how-to
Only a question:
Can I push swapfile.swp in /cache directory instead /data?
/chache has more space free

I guess you can. I haven't tryed it yet. But as it has been said in the thread it's preferable to use the sd and not any internal memory.

Wow, thank you, really speed improvement!
How to make it permanent? We have to modify init.rc in boot image?

Do you have to modify init.rc to make it permanent ? :/

Why not just use swapper?
http://code.google.com/p/a-swapper/
P

Thank you Paul : )

help
hello what we type and where type and what by type

paulobrien said:
Why not just use swapper?
...
P
Click to expand...
Click to collapse
Because not everyone flashed his tattoo and has a custom ROM, so for the folks who have to use the m7 exploit everytime after a reboot, the method lgstoian presented is the only choice
Greets

I have formatted a swap partition on my sdcard. How to use it??

Interesting. However, using swap on SD makes your SD Card unable to unmount. Internal Flash is better, 16MB on my end and I see no damage yet. And the swap is full too (16MB used, 0MB free!)

Yet. Exactly, no damage YET.
The nand flash uses a bad-block management system so i have no idea how one would notice it, i guess files getting corrupt and space being reduced.
Anyway, the only phones running android that need swap are the G1 and 32B magic.
Those phones simply have too little RAM, using straight compcache is a lot better for the 32A Magic (it resides in RAM, thus no damage) and hence the tattoo has the same amount of RAM it is better for it as well

Related

Have Hero on my G1 but have questions?

I am liking the Hero software and will diff be putting it on my Mytouch when some figures out how to root that phone.
1. I thought I would have more internal mem from the G1 after I did the part on the memory card in console? Hero running laggy and I thought the apps would run from my memory card ?
2. Bluetooth, notification lights not working when I recieve texts?
3. Laggy laggy lol it's awsome software
FenderGuy said:
I am liking the Hero software and will diff be putting it on my Mytouch when some figures out how to root that phone.
1. I thought I would have more internal mem from the G1 after I did the part on the memory card in console? Hero running laggy and I thought the apps would run from my memory card ?
2. Bluetooth, notification lights not working when I recieve texts?
3. Laggy laggy lol it's awsome software
Click to expand...
Click to collapse
1. They should run from the SD if it is correctly set up. You should be running with a linux-swap partition also. JAC says to not use anything bigger than 32mb but I have mine at 128mb with swappiness at 60 and haven't seen a loading screen since first boot.
2. BT and LED are not working in any Hero build. JAC is getting closer to getting BT fixed, and I bet LED is next.
3. The lag should abate soon after adjusting you swap settings (The swappiness is set in the a2sd.sh file)
i did a fat32, ext2, and linux-swap part in the console
Please explain #3?
So you can abd pull the a2sd.sh and adjust the swappiness settings from there and push it back?
As for A2SD still using up space, I believe the phone needs to be restarted for apps to be moved to the ext partition.
How can I tell if the apps are running the sd card? I thought the JACHeroski 2.7.4 already had the swapper in it?
I have a 8gb sc card did this Fat32 6936 Ext2 7448 Linux-swap 7576
I did take the twitter and books marks widgets off the main screen seems to be quicker...I would like optimize my G1 so the rom runs smooth, so far i like the rom
FenderGuy said:
How can I tell if the apps are running the sd card? I thought the JACHeroski 2.7.4 already had the swapper in it?
I have a 8gb sc card did this Fat32 6936 Ext2 7448 Linux-swap 7576
I did take the twitter and books marks widgets off the main screen seems to be quicker...I would like optimize my G1 so the rom runs smooth, so far i like the rom
Click to expand...
Click to collapse
If you don't have ADB, then type in the terminal:
$su
#cp /system/bin/a2sd /sdcard
Open the file in a text editor from your computer and change the echo 30 > swappiness value to whatever swapiness you want (Mine is 60 but I have a bigger swap partition. If you only have a 32mb partition I would leave it at 30, but I would recomnmend having 64mb and changing it to 60 swappiness)
then save to file back to the root of you sd card and type in terminal again:
$su
#mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
#cp /sdcard/a2sd /system/bin/a2sd
#reboot
and your swap settings are updated !
Cool thanks, I am actually going to take the 8Gb out and put in a 1gb, I am going to be selling the phone soon. Will the 1GB work for the apps to sd transfer?
FenderGuy said:
Cool thanks, I am actually going to take the 8Gb out and put in a 1gb, I am going to be selling the phone soon. Will the 1GB work for the apps to sd transfer?
Click to expand...
Click to collapse
Yes and no. It will work, but very slowly. The stock 1gb card is very slow.
Having an issue with this process:
Open the file in a text editor from your computer and change the echo 30 > swappiness value to whatever swapiness you want (Mine is 60 but I have a bigger swap partition. If you only have a 32mb partition I would leave it at 30, but I would recomnmend having 64mb and changing it to 60 swappiness)
What file is it?
FenderGuy said:
Having an issue with this process:
Open the file in a text editor from your computer and change the echo 30 > swappiness value to whatever swapiness you want (Mine is 60 but I have a bigger swap partition. If you only have a 32mb partition I would leave it at 30, but I would recomnmend having 64mb and changing it to 60 swappiness)
What file is it?
Click to expand...
Click to collapse
/system/bin/a2sd
as stated earlier, yo copy it to your sd card
Code:
su
cp /system/bin/a2sd /sdcard
Then edit the file and save it back to the card
Then use this command to push it back, then reboot.
Code:
su
mount -o remount,rw /dev/block/mtdblock3 /system
cp /sdcard/a2sd /system/bin/a2sd
reboot
Just make sure that after you've edited it and want to save you don't save it as a text file, which would add .txt
AdrianK said:
/system/bin/a2sd
as stated earlier, yo copy it to your sd card
Code:
su
cp /system/bin/a2sd /sdcard
Then edit the file and save it back to the card
Then use this command to push it back, then reboot.
Code:
su
mount -o remount,rw /dev/block/mtdblock3 /system
cp /sdcard/a2sd /system/bin/a2sd
reboot
Just make sure that after you've edited it and want to save you don't save it as a text file, which would add .txt
Click to expand...
Click to collapse
Don't worry about running 2.7.4 until it's completely refined. I am running 2.7.3 with a 64 mg swap partition and it is SUPERFAST with 6 home screens being used, with widgets on them all:
Crappy video quality:
http://www.youtube.com/watch?v=KxLZOhUA3R0

app2sd with Cyanogen

after trying for a couple days i think i finally got all of the necessary components for the a2sd auto swap program to work on my phone, but i dont think it is working yet..
I partitioned my SD card (fat32 and ext2),
adb push c:\userinit\userinit.sh /system/sd ,
adb shell chmod 755 /system/sd/userinit.sh ,
adb shell reboot ,
the phone rebooted, but i think it is still saving apps to the phones hard drive.
also I entered cat /proc/ramzswap into my terminal console and it said that the good compression was at 71%
(since it said in the userinit.sh guide "To see if it is working enter: cat /proc/ramzswap in the terminal console app on the phone. You should have a XX% GoodCompress listed if it is working properly.")
any input would be apperciated
i am using cyanogen v3.6.8.1
shockaj said:
after trying for a couple days i think i finally got all of the necessary components for the a2sd auto swap program to work on my phone, but i dont think it is working yet..
I partitioned my SD card (fat32 and ext2),
adb push c:\userinit\userinit.sh /system/sd ,
adb shell chmod 755 /system/sd/userinit.sh ,
adb shell reboot ,
the phone rebooted, but i think it is still saving apps to the phones hard drive.
also I entered cat /proc/ramzswap into my terminal console and it said that the good compression was at 71%
(since it said in the userinit.sh guide "To see if it is working enter: cat /proc/ramzswap in the terminal console app on the phone. You should have a XX% GoodCompress listed if it is working properly.")
any input would be apperciated
i am using cyanogen v3.6.8.1
Click to expand...
Click to collapse
So are you trying to do a2sd, Swap, or both? If its just a2sd, its automatically done for you if you have partitioned card.
i am just trying to get a2sd.
i partitioned my phone using ubuntu and when i finished it said that the sd card was not formated but when i rebooted it the sd card was fine so im assuming its still patitioned..
shockaj said:
i am just trying to get a2sd.
i partitioned my phone using ubuntu and when i finished it said that the sd card was not formated but when i rebooted it the sd card was fine so im assuming its still patitioned..
Click to expand...
Click to collapse
Easiest way to check if its partitioned correctly is to goto recovery console.
Code:
parted /dev/block/mmcblk0
print
and it should display partitions on the SD card. If it doesn't look right to you...
How to partition your SD card from console (This requires the cyanogen recovery 1.3.1)
Example for my 8GB card.
Reboot and enter recovery (home+power) then go to console. Enter the below pressing "enter" after each line.
parted /dev/block/mmcblk0
print (to verfiy we know what size card we are dealing with. Mine was 8166 read below if yours is different)
rm 1 (if you had more than 1 partition you would want to rm them as well)
mkpartfs primary fat32 0 7526
mkpartfs primary ext2 7526 8166
quit
upgrade_fs
recovery
if your card isn't 8166 when you type print then you will need to modify those numbers to match your card size. You basically work back to figure out the totals. To figure it out, start with your cards total size. For example 8166 total Subtract 128 for swap (8038) minus 512 for ext (7526) the rest will go to fat32. Each partition starts where the other left off.
Click to expand...
Click to collapse
Toy around with the numbers if you want.
hi xsnipuhx
is there a way to chek the partition using command terminal from windows?
i have not been able to....
I have the latest cyanogen rooted firmware 1.6 and i want to have app2sd. Can i simply partition my sdcard to ext3 and re-install cyanogen? or is there more steps inbetween? thanks

How Do I move a certain app back to internal memory?

I have partitioned sd card and I have the hello im apk on the sd and I want it on my phone because it wont let me change my buddy pic it says please make sure your sd card is in the phone so Im going to try to put it back on internal storage to see if it works. So how do I move it? I parted with apps2sd but the app wont work with cyan 4.0.1 so how Do I move it?
Apps2sd is really an all or nothing proposition. You can't have one app on internal memory and the rest on the SD card.
If you want to get rid of apps2sd altogether I can tell you how to move everything back.
OTOH, if an app is complaining about the sd card it's probably talking about the fat32 partition that it wants to store images on. Is your fat32 close to being full or something?
on a side note im on cyan 4.0.1 I was at 3.6.8.1 when I used the apps2d app and now when I try to open it it says Oops! Looks like you need to go through the tutorial to set up apps to sd. Please go to blah blah blah why is it doing this
what do I have to do to get this app running gain I already haves apps going to sd.
The top part of Cyanogen's stable thread says not to use any other method of apps to sd because his has a script built in.
So. Stop fiddling with whatever apps2sd app you have.
go to terminal and type:
Code:
su
ls /dev/block/mm*
Tell me what you see. (And please take a moment to make your posts a little more readable, I'm having a hard time deciphering what you're asking/saying. )
what Am I suppost to do? I dont want to do it without knowing
open the application 'terminal emulator' -- this is like the dos 'command prompt' in windows or a term window in Linux
type 'su' and press enter -- this Switches User to root, or the administrator of the machine (your phone)
type 'ls /dev/block/mm*' -- 'ls' is 'list' directories. /dev is where all the devices are, block is hard-drive like devices (your internal memory and the sd card) and mm* is every block device that starts with 'mm....' which should be mmcblk0 (the sdcard), mmcblk0p1 (the fat32 partition) and mmcblk0p2 (the ext partition)
If the last exists, the cyanogen automatic apps2sd will have already moved all your applications there. If only one exists, it means you either formatted the whole SD card to ext2 for apps2sd (and left nothing fat32) or formatted none of it and your apps are already on your phone.
if your 'ls /dev/block/mm*' says that you have a mmcblk0p2, than run "ls /system/sd/app/*" and you should see a bunch of files ending in .apk. If so, then you have to undo apps2sd to get the Hello IM app back to internal memory.
Report back on the outputs of the above and further instructions will be provided.
Ok Iv done all that so how do I undo them and if so how will I get them back?
Tell me what all that said back when you typed it in. THEN I can tell you what to do.
I see all my apk files now what? I want to move that 1 app onto the phone memory and every other apk on the sd. Im ready for the next step.
I see a bunch of files ending in .apk now what?
Hmm. I just looked up 'Hello IM!' and see that it's a paid app.
So, we can move just paid apps to the internal memory and leave the free ones on the sd card.
if yes run the following in terminal emulator:
su
rm /data/app-private
mkdir /data/app-private
cp /system/sd/app-private/* /data/app-private
Copying the apps may not work and you may have to uninstall/reinstall, but when you install them they'll be on the internal memory.
Oh, but cyanogenmod will put them back on the sd card when you reboot, so if having the app on the internal memory does fix the problem, you'll have to edit the a2sd script.
The problem isn't that your apps are on the sdcard. The app itself doesn't know. Your partions may be out of whack or the app itself may just need to be reinstalled.
When your apps are on the sdcard they are on a different partition then what every app uses your sdcard for. Not sure if I wrote that where you can comprehend it or not...
wat do u mean out of wack
PsychoI3oy said:
If you want to get rid of apps2sd altogether I can tell you how to move everything back.
Click to expand...
Click to collapse
I've done some searching, and haven't found any way to do this that has worked for me. Could you please pass some of this info along?
Thanks.
HowTo - un-apps2sd (on CyanogenMod)
Ok, this is based on the assumption that you are running a Cyanogen rom. I'm sure it could be adopted for use on another one, but Cyanogen 4.0.x is what I'm running. You'll probably have to re-install any paid apps (app-private) but normal apps should run fine after this.
Instructions for use with adb:
Code:
adb remount
adb push a2sd.txt /system/bin/a2sd
adb shell
# rm /data/app
# mkdir /data/app
# cp /system/sd/app/* /data/app/
# rm /data/app-private
# mkdir /data/app-private
# cp -r /system/sd/app-private/* /data/app-private
# reboot
for terminal emulator, assuming the new a2sd.txt is on your sdcard:
Code:
mount -o rw,remount /system
mount -o rw,remount /data
cp /sdcard/a2sd.txt /system/bin/a2sd
and then continue the adb instructions from after 'adb shell'
after reboot you can confirm that it worked by running:
ls -l /system
from terminal emulator (no need to remount/su) and you should see 'app' and 'app-private' as directories (and not app -> /system/sd/app).
If you're running some other a2sd method, you'll have to edit/remove the script that's doing the linking, then delete the symlinks and copy back (should be similar to above).
The modified a2sd.txt attached just takes away the apps-to-sd part. Dalvik-cache is still run from /system/sd/ as are whatever other magical juicy bits he's got in there.
If you upgrade to another Cyanogen rom, the new version of a2sd will get pushed and everything will be moved back. The only way to get rid of it permanently would be to delete the ext2/3/4 partition on your sd card.
If you decide you want apps2sd again and don't want to upgrade, just put the a2sd.orig.txt back as /system/bin/a2sd and reboot, it'll automagically move everything back to the /system/sd/app on your ext partition.
I just did the un-apps2sd then put the original back and everything's fine (and was fine with un-apps2sd).
That should cover most things....
Thank you so much for the step by step instructions.
One minor correction, maybe, shouldn't there be a '/' at the end of the second to last line?
Also, for me I didn't copy over the modified a2sd.txt file. After I copied everything to internal I shutdown the phone and deleted the ext partition. All seems to be working well!
Thanks again.
daveerickson said:
Thank you so much for the step by step instructions.
One minor correction, maybe, shouldn't there be a '/' at the end of the second to last line?
Also, for me I didn't copy over the modified a2sd.txt file. After I copied everything to internal I shutdown the phone and deleted the ext partition. All seems to be working well!
Thanks again.
Click to expand...
Click to collapse
Trailing slashes are optional in most shells, including this one.
Glad it worked for you.
these doesn't seem to be working for 4.2.1, no a2sd file exists in /system/bin, maybe he moved it somewhere else, i'm trying to find it but i'm not being lucky.
any help?
No, he broke up the bits that were in a2sd and spread them across several files in /system/etc/init.d/
http://wiki.cyanogenmod.com/index.php/Removing_Apps2SD has the instructions now.

[Tweak] turning off journaling on your Thrill for faster IO

There is a risk of data loss with a random reboot or if you let your battery completely drain so backups.....
Turning off the journaling of ext 4 /data partition. Borrowed method from craiggomez discussed here https://docs.google.com/document/d/1bOFyLXsv1WYV3rGVI72wyeItHjmayQZN-KuwhfV4TyM/edit?pli=1
when used on the thrill it improves random read speed 10x and doubles random write speed.
Basically a lag reduction. In the event of an emergency, I did not make you try this.
Just for fun try running androbench on your /data partition and save those results for after.
open cwm, Run a backup (you know why you need these)
connect to computer via usb
open adb shell from command prompt in directory where adb is located (using vista or higher you can hold shift and right click inside the folder you have adb in and select "open command window here" to bring up dos prompt)
copy and paste these commands at command prompt after shell is started
e2fsck -f /dev/block/mmcblk0p8 (you man need to push enter a lot here depending on how jacked your file system is as this command checks and repairs your file system. If it asks for permission to fix something Keep hitting enter until its done (you can hold the button down if need be))
tune2fs -O ^has_journal -c 1 -i 1d -m 0 /dev/block/mmcblk0p8 (this step does the dirty work. Note that first O is a capital o and the second 0 is zero)
e2fsck -f /dev/block/mmcblk0p8 (this step checks the file system again because why not?)
this last step checks to make sure you did it right. If the output of the command does not include has_journal you are good to reboot.
tune2fs -l /dev/block/mmcblk0p8 | grep features
I would wait about 15-20 minutes and try to run androbench again to see how it compares.
If you dont like the results you can just boot back to cwm and restore from that backup I know you made before you started.
Thanks for this! I'll be sure to try it when I need to get some extra speed in my ROMs.
Will this improve speeds even with a UHS-1 class card? Or will you only see a real difference in lower speed SDs?
ima.monstaaa said:
Will this improve speeds even with a UHS-1 class card? Or will you only see a real difference in lower speed SDs?
Click to expand...
Click to collapse
This turns of the journaling function of the ext4 /data partition of your internalsd.
as a reference.
My androbench test of the /data before the mod is this
Sequential read 21.8 mb/s
Sequential write 4.73 mb/s
Random read 230.49 IOPS(4k) about .9mb/s
Random write 30.87 IOPS(4k) about .12mb/s
after disabling jounrnaling on my ext4 /data partiton
Sequential read 33.48 mb/s
Sequential write 8.08 mb/s
Random read 2762.06 IOPS(4k) about 10mb/s
Random write 74.77 IOPS(4k) about .29mb/s
Yeah I understand what it does, but I just wasn't sure if an already fast SD card would see an improvement since it most likely doesn't struggle as much with the journaling as a class 4 or lower would.
Sent from my LG-P920 using xda app-developers app
ima.monstaaa said:
Yeah I understand what it does, but I just wasn't sure if an already fast SD card would see an improvement since it most likely doesn't struggle as much with the journaling as a class 4 or lower would.
Sent from my LG-P920 using xda app-developers app
Click to expand...
Click to collapse
this has nothing to do with the removable sd card. If you can figure out what it will take to move the /data partition over to the removable sd from my experience it would greatly improve the random write times but probably halve the improvements made in random read time.
For example with /data moved to external class 10 sandisk ultra you might see random write as high as .8 but, random read would probably top out at 6mb/s instead of the 10 I am seeing from the internal sd. This would also introduce difficulty making usable backups of data.

[DEV-HINT] Implementing a swap partition or swap file for new and old bootloader

[DEV-HINT] Implementing a swap partition or swap file for new and old bootloader
Wikipedia defines swap file (or paging) as: "[..] use disk storage for data that does not fit into physical random-access memory (RAM)."
With CM10 or CM10.1 around, the 'about phone' screen usually shows 343 MB of usable RAM on the LG-P990, so one gets ideas. With CM9 it was a bit better, but still.... Take Chrome for example: nice to the eye, but not so nice to the RAM of devices that have been around a lot longer than the Nexus 4 with its whopping two Gigabytes. So what's the catch with swap? For example, a HDD swap partition on a PC offers some sort of relief when RAM is scarce by moving some parts of the RAM (pages) to the HDD and moving them back when it needs it. Of course, it comes for a price: performance! But it works. So why not using it on Android too? To hell with the fact that virtual RAM on the internal memory card is a lot slower than physical RAM, there are times when it would be just nice to have the extra megabytes at hand.
Were you a bit envious too when you saw that the 'new' partition layout that came with the ICS bootloader on our beloved LG-P990 had a swap partition included? Well, I was. I even changed to a customized layout to get one for a little while too... But that is not really necessary. Never was, actually. I came back to the original layout and old bootloader weeks ago. What still bugged me was the missing swap partition. CM10.1, CM10 or even CM9 could really use swap from time to time but commonly don't use it.
So, is there really a big difference between the two partition layouts? Yes, but regarding the swap it doesn't count. In fact, the situation for both user groups is pretty much the same: both do not use any kind of swap space whatsoever. First, there are the users with the new bootloader. They have the swap partition but actually don't make use of it. As compared with users with the old bootloader: they may not have the swap partition on their partition table but even they can easily implement a solution very similar to a standard swap partition: a swap file. Then they can benefit as well from some extra Megabytes in certain low memory situations. You don't have a swap partition/file in use yourself yet? In just a few minutes you can change that no matter what bootloader you have.
First you have to find out which bootloader/partition layout is on your LG-P990:
here is how you determine your bootloader/partition layout: reboot!
If you see a pink LG logo when the phone boots then you have the new bootloader/new partition layout (ICS)
If you see a white LG logo when the phone boots then you have the old bootloader / old partition layout(GB)
All commands used in the terminal are shown with a '$'-sign or '#'-sign (root). Copy just the commands without the signs to the terminal, unless stated otherwise.
New bootloader/partition layout (ICS) - Pink LG logo as splash screen - You have the old bootloader/partition layout? Skip to the second part below.
If you are using the new partition layout, then it is easy to use the swap mechanism. The 350MB swap partition is just waiting for you to be switched on.
Use 'adb shell' or the terminal:
check the situation with
Code:
$ free
Does it show 0 0 0 in the swap line? Then swap is not working at the moment and has to be switched on.
Use
Code:
$ su
to get superuser rights
Make the swap partition usable (Be extra careful! Triple-check the command!)
Code:
# mkswap /dev/block/mmcblk0p4
Switch it on
Code:
# swapon /dev/block/mmcblk0p4
Change swappiness to zero at runtime
Code:
# sysctl -w vm.swappiness=0
To keep the swap partition switched on, after reboot and even after flashing ROM updates
create the file /data/local/userinit.sh
Put these lines inside (with the '#' sign)
Code:
#!/system/bin/sh
swapon /dev/block/mmcblk0p4
sysctl -w vm.swappiness=0
swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left.
Save the file.
Now reboot.
Check it via adb shell or terminal if it is working.
Code:
$ free
The swap line should show that 350 MB are available (total/free).
Check the swappiness with
Code:
$ cat /proc/sys/vm/swappiness
It should show 0 now.
Testdrive your work. Start Chrome or a game or whatever uses a lot of RAM on your system. Use it heavily and then check the swap usage of your kernel again with a final
Code:
$ free
Just try it!
Old bootloader/partition layout (GB) - White LG logo as splash-screen
The task is to create a 128 MB Swap-File on the data partition. 128 MB seems enough since it is just for memory emergencies. And it's best to create it on the data partition and not on the sdcard because of the USB mass-storage support that would interfere with any swap file on sdcards. By the way, it doesn't format your data partition. It just makes your usable space of the data partition 128 MB smaller than it is right now. Basically, it creates an empty file with the fixed size of 128 MB and makes it usable as a swap 'partition'. It has the same functionality as a swap partition. And the same speed. And everything else. It just doesn't reside in its own partition. It is even better: when you don't want it anymore or change the size of it, just stop the swap-file with 'swapoff' and delete the file 'swapfile' in your data partition and it's gone for good. Immediately you can use the freed-up space for something else.
Use 'adb shell' or the terminal:
check the situation with
Code:
$ free
Does it show 0 0 0 in the swap line? Then it is not working at the moment and has to be switched on.
See with
Code:
$ df
whether there is enough free space left on /data. 200 MB or more should be free on /data. 128 MB will be used.
Get superuser rights
Code:
$ su
Optional: To see more interesting memory stats you can use
Code:
# cat /proc/meminfo
Now create the file named 'swapfile' with the size of 128 MB
Code:
# dd if=/dev/zero of=/data/swapfile bs=1024 count=128000
This can take a moment.
Limit the rights of the swapfile
Code:
# chmod 600 /data/swapfile
now set up the swapfile for swap usage
Code:
# mkswap /data/swapfile
Switch it on
Code:
# swapon /data/swapfile
Hint: switch off would be swapoff /data/swapfile
Now it is already working!
Tune it to your needs: we just want the swap file to be used in emergencies when there is no RAM left anymore and Android would turn Project Butter in Project Stutter.
Check the status of swappiness
Code:
# cat /proc/sys/vm/swappiness
Default is 60. That is much too high. swappiness=0 lets the kernel use the swap file only when there is no more physical RAM left.
Change it to zero
Code:
# sysctl -w vm.swappiness=0
With this sysctl command you can change the swappiness setting (0-100) on runtime.
If you want to make these settings permanent no matter if you reboot or even flash a ROM update without wiping data then
create the file /data/local/userinit.sh
Put these lines inside (with the '#' sign)
Code:
#!/system/bin/sh
swapon /data/swapfile
sysctl -w vm.swappiness=0
Save it.
Reboot and check it with a last
Code:
# free
in terminal. Now testdrive your swap file with two browsers and a game simultanously or whatever suits your needs to stress your P990.
Just try it yourself!
Have fun!
and another awesome dev thread by Raum1807 :good:
Interested in making a flashable zip out of it? If not I could do it next week.
Just adding everything into one sh-file which gets called by the updater-script - or just via the Terminal.
tonyp said:
and another awesome dev thread by Raum1807 :good:
Interested in making a flashable zip out of it? If not I could do it next week.
Just adding everything into one sh-file which gets called by the updater-script - or just via the Terminal.
Click to expand...
Click to collapse
Thanks for the offer. Thought about that, too. But I think it is more interesting to understand what we are doing here by following it step-by-step. A script makes it too easy... Maybe later, we will see.
sorry for this dumb question.
what's the difference between using this method and using roehsoft ram expander?
both of them have the option to change swappiness and to enable/disable swap from sdcard (roehsoft ram expander can even choose ext sd as swap location)
i don't get it :silly:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
derEremit said:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
Click to expand...
Click to collapse
i don't think so, AFAIK the max reading speed for ext sd is 10 MBps, which is lower than reading speed in our int sd (about 13 MBps). that's why using int one for swapping would be a better choice
please CMIIW, i'm still noobs in this kind of stuff. though, i just want to share what i know
I have one point to this.
You write "swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left."
But there is every time some free space on RAM, because android never let decrease memory to zero.
babi_perang said:
sorry for this dumb question.
what's the difference between using this method and using roehsoft ram expander?
both of them have the option to change swappiness and to enable/disable swap from sdcard (roehsoft ram expander can even choose ext sd as swap location)
i don't get it :silly:
Click to expand...
Click to collapse
- Doesn't use the external sdcard
- Doesn't cost 7 Euro
- gives you an idea how things work
Sent from my LG-P990 using xda app-developers app
derEremit said:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
Click to expand...
Click to collapse
Swapping is only happening when the RAM is critically low. Btw, the swap partition of the ICS partition layout is also located on the internal memory. No difference so to speak. Using this method shouldn't harm the internal memory at all.
Sent from my LG-P990 using xda app-developers app
tomsi91 said:
I have one point to this.
You write "swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left."
But there is every time some free space on RAM, because android never let decrease memory to zero.
Click to expand...
Click to collapse
Yes, the memory management of Android tries to keep the RAM clean while keeping the last few opened apps in the RAM. Four or five running CM10.x on the P990. But the less RAM you have on your phone the harder this balance gets. Imagine memory eating apps like Gallery/Camera or Chrome. They benefit from more memory being available.
Sent from my LG-P990 using xda app-developers app
Thank you for this helpful guide! It is so easy to make it. And now I know a bit much more about Android and RAM.
Gesendet von meinem LGP990 mit CM10.
Hey! This seems interesting but i have a question , before doing this we have 343 RAM available and after all this trouble only 350 ? so thats 7more RAM or am i missing something ?
Soare23 said:
Hey! This seems interesting but i have a question , before doing this we have 343 RAM available and after all this trouble only 350 ? so thats 7more RAM or am i missing something ?
Click to expand...
Click to collapse
Yes, you forgot to read the original post that explains what exactly swap is:
So what's the catch with swap? For example, a HDD swap partition on a PC offers some sort of relief when RAM is scarce by moving some parts of the RAM (pages) to the HDD and moving them back when it needs it. Of course, it comes for a price: performance! But it works. So why not using it on Android too? To hell with the fact that virtual RAM on the internal memory card is a lot slower than physical RAM, there are times when it would be just nice to have the extra megabytes at hand.
Click to expand...
Click to collapse
The reported RAM will remail the same because you aren't increasing your physical RAM.
When i try to creat a swap file, this Error appears:
/def/zero/: canot open for read: Not directory
I'm a superuser
---------- Post added at 09:20 PM ---------- Previous post was at 09:13 PM ----------
After disconnecting from computer it worked!
Swappiness=0 doesn't stick for me after reboot It returns to 60 everytime.
@Raum1807
Awesome thread. Thanks for kindly explaining everything. I learned a lot here!
Ajsh said:
Swappiness=0 doesn't stick for me after reboot It returns to 60 everytime.
Click to expand...
Click to collapse
just put:
echo "0" > /proc/sys/vm/swappiness
at the end of a .sh file in init.d
As we´re talking about using the wasted Swap-Partition:
Is it possible to use it as a "new" kind of Ramhack?
As for now we cut off some shared Ram of GPU to use it as normal RAM. What if we let the GPU use the Swap-Partition as its Memory and get all physical RAM available?
GPU will not perform as good as now, but some People don´t need a Phone to play Games...
Is this possible or restricted to some Nvidia-Libs that are Closed-Source??
zerocoolriddler said:
As we´re talking about using the wasted Swap-Partition:
Is it possible to use it as a "new" kind of Ramhack?
As for now we cut off some shared Ram of GPU to use it as normal RAM. What if we let the GPU use the Swap-Partition as its Memory and get all physical RAM available?
GPU will not perform as good as now, but some People don´t need a Phone to play Games...
Is this possible or restricted to some Nvidia-Libs that are Closed-Source??
Click to expand...
Click to collapse
This is interesting... it could really make a difference , only if it works tho heh.
Sent from my LG-P990 using xda app-developers app
Can we have both Swap and Zram on in CM 10 ? Any possible side effects

Categories

Resources