yashsingh1/xdaforums huggingface dataset:
[Galaxy S III Android Development] Yank555:
No problem ;) The thing is, we have a certain amount of RAM at our disposal, plus our devices are getting faster and faster, getting more and more cores, but not that much RAM increase.

Let me illustrate my point :

htc HD2 (my frist device to run Android)

- 2009

RAM : 448 MB usable

CPU : 1 GHz Qualcomm Snapdragon (single core)

SGS3

- 2012

RAM : 778 MB usable

CPU : 1.4 GHz quad-core Cortex-A9

So CPU speed is up by way much more than RAM, and I'm not taking GPU into consideration, plus storage speed increase etc...

Now those devices tend to be used in multitasking, having many apps running at the same time.

What those need is :

- CPU power to run on (we have plenty !)

- RAM to fit in (we have little)

Now even though an APP is running, not every bit of it is really needed, so those parts can be swapped out (put into swap) freeing these memory blocks and making room for more apps to fit in RAM.

So what will this mod do for you : Allow for more multitasking

Keep more apps running in RAM at the same time, making the device snappier when switching from one app to the other.

One app won't run faster !

If now you don't have swap, Android will have to gently ask the least used app to please close (save data, and quit) to free up RAM. Now when you get back to that app, Android will have to reload it, the app will start and reload it's data.

You can see, this will take more time.

Hope this isn't too confusing :o
[Galaxy S III Android Development] hefonthefjords:
I have a question before i attempt setting this up.

How do we identify which partition on the card is supposed to be for swap?

I have a 64gb sandisk card and say i make two partitions, one massive one for data and a 2gb one on the end for swap, how do i identify to android that the 2gb one is for swap? Also, what format should the partition be?

Cheers.
[Galaxy S III Android Development] Yank555:
The script handles finding the partition ;)

All you need to do is partition your card and be sure the swap partition is :

- a primary partition

- of type "Linux Swap"

JP.
[Galaxy S III Android Development] jnr21:
I have 1gb micro sd card, so can i use whole card as swap card?
[Galaxy S III Android Development] Yank555:
Yes, just create one partition with the size of the card, and make it a primary partition of type "Linux Swap".

But just a thought, what speed class is this card ? A too slow card might not be a good idea to use as swap device.

I'm waiting for my 64Gb card, so for now I'm running 512Mb swap on my older Transcend class 4 card, which is running fine for far. I'd not really go lower, though it's sur worth a try ;)

JP.
[Galaxy S III Android Development] paranoid2007:
Will the whole swap partition be used as swap memory?

And one more thing: what happens, if you remove the external sd, while the mod is active?

Gesendet von meinem GT-I9300 mit Tapatalk 2
[Galaxy S III Android Development] hefonthefjords:
Thankyou. Will give this a try.
[Galaxy S III Android Development] Yank555:
Yes, the partition is used, so its size is the limit ;)

JP.
[Galaxy S III Android Development] jnr21:
There's no mention what class it is. As i remember card came with some nokia phone 2-3 yerars ago, so i think that it's pretty slow, but i will test it anyway.
[Galaxy S III Android Development] ctrlaltdel:
use with extsd and internal sd swap script?

Hi,

just wonder if I can use this with the extsd and interenal sd swap mod by mattiadj?

that will be great if i can use both mod and if we can use both, where will be the swap space? still the extsd?

thanks.
[Galaxy S III Android Development] yhrn:
Hi,

Thank you for sharing this mod. What size would you recommend for the swap partition? I think that the general recommendation for desktop Linux is something like one to two times the size of physical RAM, depending on available disk space. Would that be reasonable for Android as well?
[Galaxy S III Android Development] Yank555:
Swap will all be used, but they will have a priority (order) which you can check by typing "cat /proc/swaps" in a terminal.

I'd not use many though, you don't really need that much swap :D Just compare and keep whatever works best for you ;)

On Android that might be shooting a little too high. I have a 512Mb partition, but I suppose 256Mb would be fine, that is the size I used on my previous devices.

JP.
[Galaxy S III Android Development] d8389:
It will not fix the leak, but phone will run longer.

For fix see my thread in this forum.
[Galaxy S III Android Development] Mopral:
just try on mine: the "free" command report used swap 30Mb but system tuner pro report that swappiness is set to 100

And I do not use Supercharger...

EDIT: Swap seems to grow to 70Mb if I launch 2 games and returning on touchwizz without killing the game
[Galaxy S III Android Development] Yank555:
What kernel are you using ? What ROM ?

JP.
[Galaxy S III Android Development] njmata:
Kernel: Siya -v1.5beta6

Rom: Stock Rom
[Galaxy S III Android Development] Yank555:
Swap will grow as RAM is needed and as RAM pages get "old" (unused for a certain time).

JP.
[Galaxy S III Android Development] Yank555:
OK, kernel is fine, it has swap support.

Can you post the result of these commands in a terminal :

su
fdisk -l /dev/block/mmcblk1
cat /proc/swaps
ls -l /system/etc/init.d

Plus can you post the following files (if they exist) :

/data/hardswap.log

/data/swap.0.log

Thanx, JP.
[Galaxy S III Android Development] Yank555:
Update uploaded ==> v1.1 online.

See second post for details ;)
[Galaxy S III Android Development] njmata:
The Screenshot show the command execute in Terminal. I can see that the folder init.d was not created.

The Hardswap.log is:

------------------------------------------------

Hard Swap Flasher by Yank555.lu v1.0a for SGS3

------------------------------------------------

SD-card device = /dev/block/mmcblk1

Paratition table for SD-card :

------------------------------

Disk /dev/block/mmcblk1: 7973 MB, 7973371904 bytes

246 heads, 62 sectors/track, 1021 cylinders

Units = cylinders of 15252 * 512 = 7809024 bytes

Device Boot Start End Blocks Id System

/dev/block/mmcblk1p1 1 955 7282799 c Win95 FAT32 (LBA)

/dev/block/mmcblk1p2 956 1021 503316 82 Linux swap

Swap partition = /dev/block/mmcblk1p2

- formating swap partition '/dev/block/mmcblk1p2'

Setting up swapspace version 1, size = 515391488 bytes

- copying swap activation script to /system/etc/init.d

done.

There is no a file /data/swap.0.log
[Galaxy S III Android Development] Yank555:
Ok, makes sense now ;)

There is no "/data/swap.0.log" because the swap activation script was not run.

The swap actication script was not run, because it was not installed.

It was not installed, because your ROM does not have an init.d folder to run startup scripts to install it into.

What you can do is create the necessary folder by typing this in a terminal :

su
mkdir /system/etc/init.d
chmod 777 /system/etc/init.d
chown 0:2000 /system/etc/init.d

Then reflash the mod.

If now after booting, you still so no swap activated, that means that neither the ramdisk you're using executes the scripts, nor the ROM (some ROMs like to take care of this, even though I find it to be the job of the ramdisk).

Anyway, give this a go, and let's see how it works out ;)

JP.
[Galaxy S III Android Development] gaetanolip:
Ho

I am not sure anymore renaming swap script it loads after v6 superchargher because v6 has 90 seconds delay.

So i modified v6 TO 100 swappiness,Now the 2 scripts works fine
[Galaxy S III Android Development] Yank555:
It should be run once the previous script is done, so swap should only be activated 90 seconds after supercharger script is launched.

Test it, leave Supercharger script as was (swappiness = 20), flash 1.1 hardswap (so the scriptname is 991swap), boot, give it 2 minutes to complete (so you're certain all scripts are done) and check swappiness.

It should be 100 and swap should be activated.

JP.
[Galaxy S III Android Development] njmata:
Mkdir failed... read-only file system

I think that I have to mount the system but I don't know the command to do that. Do you know what are the command to do that?

I found how mount the system. Now the scripts is running, thank you for your help.

If I decide install the new version of your script, first I have to uninstall the 1.0a version?
[Galaxy S III Android Development] Yank555:
Correct, little detail, but important detail ;)

Here you go :

su
[COLOR="Red"]mount -o remount,rw /system[/COLOR]
mkdir /system/etc/init.d
chmod 777 /system/etc/init.d
chown 0:2000 /system/etc/init.d
[COLOR="Red"]mount -o remount,ro /system[/COLOR]

JP.
[Galaxy S III Android Development] njmata:
Thanks men. Now I have running your script.

If I decide install the new version of your script, first I have to uninstall the 1.0a version?
[Galaxy S III Android Development] Yank555:
No, you need to just reflash.

JP.
[Galaxy S III Android Development] ceo.mtcl:
V1.0 never worked for me. I downloaded several times and matched md5 sums also and no success.

Just downloaded v1.0a and it ran just smoothly.

Thanks for the mod.

☞ sent from GS3 or Nexus
[Galaxy S III Android Development] Yank555:
That was the point for 1.0a ;) why not use 1.1 instead of 1.0a ? Won't hurt ;)

JP.
[Galaxy S III Android Development] band_aid:
Can someone check my screen shot, and tell me if the mod is working

Sent from my GT-I9300
[Galaxy S III Android Development] Yank555:
Yep, looks fine to me, Linux Swap partition is present on your SD card, and it is used as swap ;)

JP.
[Galaxy S III Android Development] band_aid:
Internal or external sd card?

Sent from my GT-I9300
[Galaxy S III Android Development] Yank555:
/dev/block/mmcblk1xx ==> External

I don't think you would have repartitioned your internal memory anyway ;)

PS: Internal memory would have been /dev/block/mmcblk0xx btw.

JP.
[Galaxy S III Android Development] band_aid:
Oh ok

Sent from my GT-I9300
[Galaxy S III Android Development] band_aid:
When I use the minitool partition wizard:

a. Create a "primary partition", linux swap

b. Create a logical partition, ext 4

is this correct?
[Galaxy S III Android Development] Yank555:
Nope, you should :

1) Create primary partition FAT32 (where your external SD data will be)

2) Create primary partition Linux Swap

JP.
[Galaxy S III Android Development] Mopral:
a. create a primary partition (fat32,exfat,...) for your data

b. create a primary partition (linux swap) at the end of your SDcard

Edit: Crap! Yank555 has been faster...
[Galaxy S III Android Development] band_aid:
Mod is working well.. just a quick question which option is for exfat? ext1, ext2, ext3 or ext 4?

and is 1gb too much for a partition?
[Galaxy S III Android Development] Yank555:
I would recommend 512Mb for swap, but other users report using 1Gb. I personally have a 512Mb partition.

As for the other filesystem types, those are :

- exFAT - Microsoft's proprietary filesystem for partitions bigger than 32Gb

- ext1-4 - Unix filesystems to use for Linux etc.

In a standard case, you should have one FAT32 or exFAT partition (depending on the size of your SD card), and one Linux Swap partition.

JP.
[Galaxy S III Android Development] band_aid:
I didn't have the option of exFat, so I chose FAT32 instead.
[Galaxy S III Android Development] Yank555:
Correct choice. exFAT you can only create using Windows Format (it's Microsoft proprietary, so only Windows can do).

What is the size of your card ?

JP.
[Galaxy S III Android Development] band_aid:
64gb sandisk
[Galaxy S III Android Development] Yank555:
Lucky you, and your's working ??

I got 2 from Amazon, none worked for longer than 30 minutes :( I sent the first back for a replacement, the replacement as I said lasted no longer so I returned it for a refund...

If FAT32 is working fine, stick with it, as it's easier to get along with FAT32 than exFAT.

If you'd rather use exFAT (standard filesystem on the 64Gb SanDisk), insert the card into your PC and use Windows to format it, and choose exFAT.

Important, don't remove the SD card while your SGS3 is running, you'd crash the device, power it off and remove the card, make the changes, reinsert the card and you're good.

JP.
[Galaxy S III Android Development] band_aid:
I got mines from Amazon US.

I formatted my sd card earlier using my phone, but I couldn't create a partition later using the tool wizard.

---------- Post added at 09:36 PM ---------- Previous post was at 09:23 PM ----------

I think i'll stay with FAT32, i've been meaning to try Cyanogenmod and it doesn't support exFat anyway.

Is it ok to unmount the sd card, then remove it? that's what i usually do.
[Galaxy S III Android Development] Yank555:
Nope, that will only unmount the FAT partition, but swap will stay active ! With hardswap, your SD card is part of the running system.

You could do this in a terminal :

su
swapoff -a

Then check repeating this :

cat /proc/swaps

Until you see that the partition is not listed anymore. This may take a little, the kernel will need to reload all the pages in swap into RAM, possibly killing one or the other background app.

When you reinsert the card, you should type this to reenable swap :

su
/system/etc/init.d/98swap (for the mod up to 1.0a)
/system/etc/init.d/991swap (for the mod starting from 1.1)

Again to check if this worked, you can type this :

cat /proc/swaps

But a different question, why do you remove the card ? To access data from your PC ? I do this using Samba (available free on Google Play) on my SGS3 and access it as a Windows network share, might suit your needs as well ;)

JP.
[Galaxy S III Android Development] band_aid:
i read that information in the earlier posts, thanks for the reminder.

Will try Samba later.
[Galaxy S III Android Development] Yusei:
Hi guys,

This works with JB based roms?
[Galaxy S III Android Development] Yank555:
As long as :

- init.d scripts are executed

- kernel has swap support

It should work.

JP.
[Galaxy S III Android Development] Yusei:
I'll try to find out

Thanks
[Galaxy S III Android Development] ceo.mtcl:
Can you please post a change log in OP so that we can decide if we want to upgrade or not?

☞ sent from GS3 or Nexus
[Galaxy S III Android Development] Yusei:
It's already there.
[Galaxy S III Android Development] earthworm1102:
Quick question: After installing , i see swap partition is working ( 512 swap partition). But when i check on task manager, ram is almost the same.Maybe an improvement of 50 mb or lower. Is task manager still accurate? although i see on terminal that i have a lot of unused ram.
[Galaxy S III Android Development] Yank555:
Changelog = post 2 =

always

updated

before

a new file is uploaded !

Faq = post 3.

JP.
[Galaxy S III Android Development] Yank555:
Task manager will most likely only show RAM status. It is good if you see no more free RAM than before, since that means that the freed RAM pages,which have been swapped out, are being reused for other things.

That's the wole point ;)

Remember :

swap is not RAM, swap is just a place where long-time unused RAM pages can be stored so that those make room for other other apps to use them.

JP.
[Galaxy S III Android Development] punshkin:
ah the nostalgia - i had to set up swap Partitions on My HTC Dream to run Sense Roms :D
[Galaxy S III Android Development] earthworm1102:
Yep, never used swap partition on my HD2 during GB rom editions, hmmm maybe that's why my hd2 is so slow when installing GB lol!! Now everything is runs smooth with JB.

Thanks for this Yank555. Now at least i don't have to worry about my GS3 slowing down.
[Galaxy S III Android Development] pinku1:
perfect! thanks for mod!!!
[Galaxy S III Android Development] Eddiemc:
@JP

I just read through your complete thread and I wanted to say thank you for your patience, help, and commitment.

The same questions keeps getting repeated, and you keep answering helpfully and friendly. Not all devs would bother, so thanks for that.

I think this could be a very beneficial mod, and I will install it as soon as my replacement sd card arrives.

-E

Sent from my mind using telepathy..
[Galaxy S III Android Development] delerium82:
Can I use this method for Samsung Galaxy Note?
[Galaxy S III Android Development] Yank555:
Well if the external SD card is presented to the system as "/dev/block/mmcblk1", then yes you could.

If you're not sure and you want, we can try to figure that out...

Issueing this command in a terminal should give us a good insight :

su
fdisk -l /dev/block/mmcblk1

JP.
[Galaxy S III Android Development] MDHACK:
Hi! I was reading this and it's interesting! I don't have a S3, but can I use this script on others devices, like Galaxy Ace?
[Galaxy S III Android Development] alex1986cy:
Hello yank555 ia there a way to know if my kernel have swap support? I have the omega rom v6.0 XXLF6 if this helps
[Galaxy S III Android Development] Yank555:
Same applies as I wrote just one post above yours, if your sdcard is presented as "/dev/block/mmcblk1", then it should work.

JP.
[Galaxy S III Android Development] Yank555:
I guess either ask the kernel dev, or just try the mod ... if you get a "not implemented" error when executing "swapon", then it's not supported :(

JP.
[Galaxy S III Android Development] alex1986cy:
Is there a possibility to damage my rom and then have to reflash it if i put the mod on sd card and flash it with cwm but my kernel is not supporting swap? Also can you explain my how to check the swapon thing you said. I have to do it before or after flashing your mod?

Thank you in advance
[Galaxy S III Android Development] pinku1:
Hello,

Sorry but after installing this mod successfully my s3 starts responding very slow after 2-3 hours of use. (means can't even use device need to take out battery)

I am on CM10 with Siyah Kernel.

Here is screen shoot from terminal.
[Galaxy S III Android Development] eiraku:
Everything crawling to a halt? I get that too sometimes with my 1.4GB swap + the front page LMK settings + heavy, heavy multitasking (say, multiple very image heavy sites in multiple tabs + PowerAmp + Tasker + Tapatalk + some other stuff).

Changed it to the "medium" LMK preset on System Tuner Pro and I get it less frequently, but consequently the system uses less swap.

Maybe too much swap isn't a good thing? Or maybe it's something else?

BTW, I'm running swap on an Apacer Class 10 mSD (which is more like a Class 8/9 then anything lol).
[Galaxy S III Android Development] Yank555:
I think if you're running a 3.0.39+ kernel, it would be best to use less aggressive LMK settings ! 3.0.39 introduced some changes in memory management, and it seems the system reacts a little bit less smooth on very low free RAM...

Too much swap is not good, so much is certain, since swap is slower than RAM, it makes no sense keeping too much in there. I think 512Mb swap is far more than enough, maybe 256 is fine (I have 512 on mine, have no issue so far, but I'm running a stock Samsung ICS update 4 kernel with swap support, so I'm on Linux 3.0.15, if you want to test with that kernel, it's in my "secret bat-cave", link in my signature,

but I have only tested it on ARHD !!

).

I have updated the info on the 2nd post as follows :

4Mb Foreground Apps

8Mb Visible Apps

16Mb Secondary Server

32Mb Hidden Apps

48Mb Content Providers

64Mb Empty Apps

Could you test those and report back ?

Just a detail, as far as I know, JB ROMs have a memory leak issue, that will eventually lead to a "swap usage issue" since less and less RAM will be available as time goes by ... except that leak issue has been fixed in the past 7 days (since I quit using a JB ROM) ?

JP.

EDIT :

I don't think your SD card is to blame, I had no issues while using a Transcend 32Gb class 4 card as swap device.
[Galaxy S III Android Development] eiraku:
Those are the exact LMK settings System Tuner is recommending for it's "medium" preset (and the same exact one I've been using for the past few days) and I can definitely say it helps A LOT.

Still get that crawl in EXTREME situations with the new LMK settings but that really doesn't matter. In general normal use (which for me translates to pretty heavy multitasking), there hasn't been much issues so far.

Funny though, about the kernel thing. I'm running the latest (open) Siyah beta (beta6 as of right now), which IINM is based on Samsung's update 4 code - which should make it a 3.0.15 kernel too, right?

But then again, Siyah is a purpose built kernel so I'm not sure. It might be based on 3.0.39+ with the update 4 code merged in for all I know.

As for the swap being "too much", I'll shrink it back later when I have some free time.
[Galaxy S III Android Development] Yank555:
GM started on a Sammy kernel, there's no way around that, but updates his kernel to the latest korg 3.0.y as they are available, so I think it should be 3.0.40 in fact ;)

Just type "uname -a" in a terminal and you will know for sure :D

I've just started mine, wanted to update it as well to 3.0.40, but not tonight, too many not obvious conflicts to resolve, no energy left, work tomorrow, it's already been a tough week because of this new toy (SGS3) to get the kernel compiled :( I now have had it for 12 days, and I must have already easily spent 120+ hours on it so far :eek:

JP.
[Galaxy S III Android Development] eiraku:
Pffft. I should've just looked harder at the kernel name in "about device".

It's 3.0.39.

And about spending too much time on the S3, I totally feel you. This thing is my primary internet access device, plus all the modding I do to it.

I don't think spending this much time with an electronic device is healthy lol... :D
[Galaxy S III Android Development] Yank555:
My bad, that's the far easier place to look for, that would have been what uname had returned.

Guess I'm just a terminal juncky :D

JP.
[Galaxy S III Android Development] natboy:
I'm assuming this mod isn't SGSIII specific? I've got an Atrix 4G that I want to try this on. It's got an internal partition that it sees as an sdcard, will this conflict?

Thanks!

EDIT: I manually ran the swapon/mkswap commands and my phone started crashing. Probably a case of a crappy sdcard. Oh well, it was fun anyways :eek:
[Galaxy S III Android Development] Yank555:
Hard call ... the mod is not device specific, it will have two requirements :

1) the kernel need wo have swap support compiled into it

2) you need to know what device your sdcard is (so the script knows where to look for the swap partition)

On the htc HD2 the sdcard is "/dev/block/mmcblk0".

On the htc Sensation and SGS3, it's "/dev/block/mmcblk1", and "/dev/block/mmcblk0" is in fact internal memory !

But anyway, in this version (SGS3) it will look for a "Linux Swap" partition on "/dev/block/mmcblk1", if it cannot find one, it will abort installation.

So if you know the exact device, it's easy to change that in the mod scripts !

So you can give it a try... but Nandroid before ;)

JP.
[Galaxy S III Android Development] eiraku:
AND just so you guys know, NEVER TOUCH mmcblk3. That's your EFS partition right there IINM.

Some guy formatted it while back using Swapper and had a grand time trying to make stuff work again.
[Galaxy S III Android Development] Yank555:
I suppose you mean "/dev/block/mmcblk0p3" ?

Yes, anyway, just don't touch "/dev/block/mmcblk0" at all !! That's your internal memory !

Just a little explanation for those that might not know this :

On the SGS3 :

So for instance if you partiton your sdcard into 2 partitons on the SGS3, that would give 3 available devices :

/dev/block/mmcblk1 - the disk

/dev/block/mmcblk1p1 - the FAT partition

/dev/block/mmcblk1p2 - the swap partition

My script (installer & boot activation script) will lool onto "/dev/block/mmcblk1" to finf which partition is of type swap, and will in the above case use "/dev/block/mmcblk1p2" to use as swap.

JP.
[Galaxy S III Android Development] eiraku:
Sorry for the typo.

With that said, a bit OT but I wonder if our devices can recognize external SDs with multiple saperate partitions, like a 64GB with 32GB in Fat32, 30GB in Exfat and 2GB in swap.

Why somebody would do this is beyond me but I wonder nonetheless.