yashsingh1/xdaforums huggingface dataset:
[G2 and Desire Z Android Development] chocohagelslagje:
I wanted to share my experience with enabling swap. If you have problems you can try to do the following: update busybox (i use an app from the market) and superuser (also binaries in superuser) and after this enable swap with the script. Than it could be that it works! This sometimes worked for me on some older roms. Just wanted to share this, I didn't see anybody mention this yet.
[G2 and Desire Z Android Development] moolash:
enable/disable

Is the swap partition disabled after reboot? (at least it says boot enabled on boot)

In my case I switched back to a previous (non sense 3.0) NAND and # free says I have no swap, which is ok, I was just wondering
[G2 and Desire Z Android Development] xT4Z1N4TRx:
After reboot its enabled. But if u swap rom its disabled
[G2 and Desire Z Android Development] sandipbarik:
Guys the best way to enable and use swap the easy way is the "swapper 2" app...just enable safe unmount and safe remount in options...and it works like a charm, when used as usb mass storage.

Also theres no need to create any partition with this app, it creates a swap file in the sd card, can be easy enabled disabled from the app.

Just enable swap at startup and forget it, no need to activate it everytime

Using it with virtuous sense 3.5 beta 2 on my Desire z
[G2 and Desire Z Android Development] noneabove:
If we set this up with one ROM, do a back up, install some other ROM, will that ROM have the SWAP set up? And then if not, if we go back to the original, will that one have it set up? Thanks in advanced :)
[G2 and Desire Z Android Development] erichung_13:
I tried this but i get 0 0 0 next to swap..

EDIT: It said everything was successful too, only when i do

su

free

is when it gives me three 0's
[G2 and Desire Z Android Development] noneabove:
*sigh* :/ tried multiple times however each time i get 0s... i used ADB and CWM with the same sizes you suggested.. any ideas??
[G2 and Desire Z Android Development] xT4Z1N4TRx:
What rom / kernel?

And, when u did it, did it say it was successful?
[G2 and Desire Z Android Development] erichung_13:
When i did it.. it said it was successful, and did not show up after >>

su

free

until after I mounted SD then unmounted. After mounting then unmounting to pc it came up in both adb and terminal
[G2 and Desire Z Android Development] noneabove:
RCMix3d runny 4.0 with the stock kernel that comes with it... and yes it said it was successful multiple times (i tried it more than once)
[G2 and Desire Z Android Development] xT4Z1N4TRx:
I am using the same rom and kernel....try do it and wipe dalvik cache. What sd you got?
[G2 and Desire Z Android Development] noneabove:
I've already put everything back on my SD of course haha >< i have a class 10 16 Gb SD card (which is the only reason I'm reluctant to do it again, so much copy time)

also I'm afraid that the recopying back to SD card or attempting the swap may have cause some damage as I've had about 6 crashes today when until this point I had had none.. :/ I've now wiped cache and dalvik cache in an attempt to fix the crashing..

---------- Post added at 12:38 PM ---------- Previous post was at 12:34 PM ----------

also do you think I really need it? I average between 60-100mb of free RAM inside of the Task Manager, so do you think I need swap? if so do you then think that wiping dalvik will help
[G2 and Desire Z Android Development] xT4Z1N4TRx:
On sense 3.5 it helps ALOT. Trust me
[G2 and Desire Z Android Development] noneabove:
so do you think that wiping dalvik will help though? and at which step? I just don't want to waste another like 30 min copying stuff to my sd card lol
[G2 and Desire Z Android Development] noneabove:
also when I go to restore my SD, should I just take everything off of my SD card and paste the backup on it or should I try to merge the folders that are already there or what?
[G2 and Desire Z Android Development] erichung_13:
Follow these steps and you will not go wrong.

>Full wipe

>Flash rom (romcleaner optional but well worth it)

>set up phone

>backup SD

>perform the swap

>copy over files from SD

If you follow this you will not run into any problems.. I have done this about 6 times already with no problems at all.
[G2 and Desire Z Android Development] noneabove:
Well the good news is that it worked on the Affinity ROM! But I'm not entirely sure that I am seeing it to it's full potential? Will it show it as additional RAM? How can I be sure that it is working properly?
[G2 and Desire Z Android Development] cjward23:
It won't show up in any task managers. Install terminal emulator and type

su
free
[G2 and Desire Z Android Development] noneabove:
Okay yea it shows up there i was just confused by it not showing up in settings super box or task manager, just wanted to be completely sure it was working, thanks cjawrd23! :)
[G2 and Desire Z Android Development] skinnyveganboy:
Probably because 4ext creates two sd-ext's? any ideas?
[G2 and Desire Z Android Development] chocohagelslagje:
Just one question about copying files back. I never have to do this. After flashing rom I only perform the steps from "chmod...." And after reboot works. Don't know if I am missing something so just asking :)

Sent from my HTC Desire Z
[G2 and Desire Z Android Development] noneabove:
Uhh well the whole partition part should wipe your SD.. XD so maybe you're missing that step or it's just not working or you never had anything on it to start with ? :P
[G2 and Desire Z Android Development] chocohagelslagje:
But I don't partition every time (i know partitioning wipes it)I also thought reading somewhere this isn't needed every time. I have a lot on my sd card, 16 gb card :) and when i perform 'free' it always comes back with numbers so should work I guess....

Sent from my HTC Desire Z
[G2 and Desire Z Android Development] skinnyveganboy:
This is true, you only need to part once and then ONLY again if you've un-part'd for some reason.
[G2 and Desire Z Android Development] chocohagelslagje:
Thanks for confirming, just found the post where this was also mentioned http://xdaforums.com/showpost.php?p=19108360&postcount=158

Sent from my HTC Desire Z
[G2 and Desire Z Android Development] xT4Z1N4TRx:
Not too sure, 4ext can make bigger swap partitions so it's kindof sad it doesn't work:(
[G2 and Desire Z Android Development] noneabove:
Oh oh oh sorry! Didn't realize you had already done it in the past, thought like your first time doing it and it didn't wipe, was very confused! XD
[G2 and Desire Z Android Development] chocohagelslagje:
No problem! Using it for a while now on several roms, first with swapper app but since I found out how easy this was I use this method :)

Sent from my HTC Desire Z
[G2 and Desire Z Android Development] amazinglarry311:
You can also use unused space in your data partition if you don't want to reformat. Pm me, as it's dangerous due to read write cycle limitations with flash memory.

you can also just use an existing ext partition and use a swap file if you have ext already on your sdcard. Then you just mount ext and call the swap file in init.d

it's required to have a kernel that supports swap. For the data partition you'll have to have support for loop.
[G2 and Desire Z Android Development] craiglay:
I'm having problems enabling swap on boot. I can enable it using the Terminal Emulator after boot but despite being in etc / init.d it fails to apply. I have tried giving it a higher number to no avail. I believe init.d is supported in my kernel but not 100% sure.

Any Ideas?

I have Hawst's pre-rooted stock rom and Unity V9 kernel.

Craig
[G2 and Desire Z Android Development] sebastianlow:
Does this gimme more ram?
[G2 and Desire Z Android Development] craiglay:
Very loosely, yes.

More technically, not really. It provides Android with an area on the SD card it can use as RAM when available RAM gets low.

On my Desire Z, it stops Sense from restarting and everything is smoother. Depending on your ROM and how you use your phone, your experience may vary.

Craig
[G2 and Desire Z Android Development] amazinglarry311:
Did you set permissions? 755 for executable
[G2 and Desire Z Android Development] craiglay:
Yes, and the owner. An ls -l of /etc/init.d shows the same permissions and owner for all files.

Thanks
[G2 and Desire Z Android Development] coachmoore:
Do you have to do this every time you swap roms or restore from backup?
[G2 and Desire Z Android Development] craiglay:
Swap ROMs, yes.. Restore from backup, maybe. Depends on what you restore I guess.
[G2 and Desire Z Android Development] coachmoore:
Ok thanks! It says to back up sd card as it will erase it all.. How do I do that and how do I get it all back? Sorry, I'm a noob at this!
[G2 and Desire Z Android Development] craiglay:
I connected it to my Windows 7 laptop and used the standard Windows explorer drag and drop.

1. Copy files from SD card to computer

2. Partition SD card

2. Copy files from computer to SD card
[G2 and Desire Z Android Development] Steven How:
I'm searching for this answer as well,if I perform swap partition with my adb on virtuous affinity,later I flash virtuous unity,do I need to do the whole step of setup partion??
[G2 and Desire Z Android Development] sebastianlow:
How to set swappiness?
[G2 and Desire Z Android Development] rirozizo:
NICE!!!

got it working via ADB, no problems at all!

btw, when partitioning the sdcard, all the files will be deleted... you'll have to put swap_enabler AFTER partitioning...
[G2 and Desire Z Android Development] xdadevolpers:
FOR ME NOT WORKS VIA ADB!

Terminal Emulator & ADB same errors and not works.

I have

Desire Z

8GB memory card CLASS 4

RCMix Blue Edition v4.0 ROM

I will be happy if someone can learn me how to make it working :(
[G2 and Desire Z Android Development] rirozizo:
this is because rcmix's kernel doesn't support swap... it doesn't let u activate it... u should find another kernel to flash and it will work fine... (same happened to me while running rcmix)

—————————————————

I'm a 9gagger, if you are one... pm me
[G2 and Desire Z Android Development] mike102871:
Just set this up on my G2. Im running the sense 2.0 rom now. So if i swap to a sense 3.5 rom i would just need to enable it even though its enabled now. I would just install rom like usual with wiping everything, i wont lose the swap partition or ext partition correct,

I just wanted to be absolutely sure.
[G2 and Desire Z Android Development] xT4Z1N4TRx:
yeah just wipe and install the rom, then do the adb or terminal steps and youre up and running again
[G2 and Desire Z Android Development] Abolfazl:
So I ran this in adb and it said it worked and to reboot. Upon reboot i run 'free' and I still get '0 0 0'. Am I doing something wrong? I have the 2.6.35.14-MDJ-AOSP-ICS-V5 Kernel
[G2 and Desire Z Android Development] craiglay:
Your ROM doesn't support init.d scripts. If you can run it manually in Terminal Emulator using something like /etc/init.d/06swap as root. Don't reboot, but run free and it will have worked. It will have to be done after each reboot.

Craig
[G2 and Desire Z Android Development] MaxWiz:
Does clockwork recovery include an option to align your sd card clusters? This is built in to 4ext. I used 4ext to partition my card. The guide and script here works fine provided you only set up one sd ext. You can repartition and change them all to ext4 without loss of data but to align your sd you will need to back up to pc and repartition the whole card.

Alignment speeds up any/all read/write to the sd card. With a swap partition that extra speed is critical and I would strongly recommend doing it.

Some reading about sd card alignment here.
[G2 and Desire Z Android Development] Abolfazl:
I ran "cat /etc/init.d/06-swap" and it provided me with "swapon /dev/block/vold/179:67"

How do I have it run at each boot?
[G2 and Desire Z Android Development] blahbl4hblah:
There is a certain location for swap, I'm unsure what the location might be but that location is not the location of swap
[G2 and Desire Z Android Development] Abolfazl:
I am confused. I used CWM to make the swap partition. and then ran the .sh file but on reboot I seem to lose swap
[G2 and Desire Z Android Development] blahbl4hblah:
I don't ever need to reboot to enable swap on the roms that I release. But that's because of SparksCo's patch
[G2 and Desire Z Android Development] Abolfazl:
Any chance I can apply this patch to Virtuous Quattro? Also is there a link to the patch? I can;t find any info about it
[G2 and Desire Z Android Development] blahbl4hblah:
If its that rom I doubt it since ics has location issues and I don't know if logcat works too so I'm unsure
[G2 and Desire Z Android Development] Abolfazl:
Ok well I fixed my problem. I needed a solution that would run "/etc/init.d/06-swap" on boot every time so I just added it to "/system/virtuous/scripts/virtuous-scripts.sh" which is ran on boot every time
[G2 and Desire Z Android Development] rirozizo:
I'm trying this on LeeDROID, and this is what i get:

"You need run this script as ROOT user. Exiting"

Now,

my phone is rooted (everything else works)

I made sure "su" is typed

I even tried adb

I tried 4EXT recovery, and clockworkmod

I tried redownloading the swap_enabler.sh file again, and again

So? Any thoughts? Maybe kernel? And if yes, what kernel should i use?

Sent from my HTC Desire Z A7272
[G2 and Desire Z Android Development] sergeikaspd:
ammm....what for eхt2 partition?
[G2 and Desire Z Android Development] taurius1:
I get function not enabled error. I suppose something's been stripped out from the ROM I'm using?
[G2 and Desire Z Android Development] crestofawave:
It really depends on the ROM. What are you using?

Most of the time, if a ROM doesn't support swap altogether then it means it has no use for it. You have to take into consideration that for ROM's like CM or MIUI, all swap will do is degrade your SD Card health as well as eat up more battery cycles, without any actual performance increase.

Sense 3.x, on the other hand does have it's benefits from the use of swap (on our device) since it can offload work to it, hence freeing up precious RAM.

Generally, if you're on anything but Sense, swap will do more bad than good, which is why SWAP functionality is usually disabled on non-Sense ROM's.
[G2 and Desire Z Android Development] xT4Z1N4TRx:
OP updated with a quicker method, only takes a couple seconds. Its at the bottom in bold.
[G2 and Desire Z Android Development] simono_pl:
For me this metod works only to reboot on FXP126 for Sony Ericsson Neo V. After reboot I must enable it again.
[G2 and Desire Z Android Development] kbeezie:
IS this issue common? I've never had a problem with swap/sd-ext etc interfering with USB mass storage on any Rom I've tried (but I don't use Windows either, just OSX and Linux, so maybe that's why).
[G2 and Desire Z Android Development] xT4Z1N4TRx:
its when you use swapper from the play store I think. Can't remember
[G2 and Desire Z Android Development] kbeezie:
:P Then just let the rom handle swapping? :P
[G2 and Desire Z Android Development] qriozum:
If 4Ext Recovery allows you to create two partitions EXT and hence the problem with the script.

I hardwired one parameter in the original script and ... It already works with 4Ext Recovery.

Here is the link to the modified script:

www.elektro-instal.com/swap.sh

regards

q.
[G2 and Desire Z Android Development] kbeezie:
Yea I noticed this with EliteMod, when I formatted with a second SD-Ext partition (didn't quite understand the need for it), swap failed to activate in the rom, but if I re-partitioned it with only one sd-ext partition (a 2GB in my case) then swap would be seen and activated just fine.

(EliteMod uses the CM9 kernel on a AOKP Rom, with his own personal tweaks)
[G2 and Desire Z Android Development] jspina:
would this method work for other phones as well like the HTC Sensation?
[G2 and Desire Z Android Development] qriozum:
If the original script to work with Sensation, this also will work.

I changed it only one value (the number of partitions) Recovery 4Ext because there are two ext partitions - hence the script "crazy".

regards

q.
[G2 and Desire Z Android Development] kbeezie:
By the way you shouldn't use such a tiny SD-EXT size like 128MB, a number of scripts and kernels (Such as Elitemod ICS) maps /data/app* to /sd-ext/app* as a result you run into a problem where your phone keeps saying your'e out of storage.

So ideally if you do use an sd-ext partition, it should not be any less than 1.5GB.
[G2 and Desire Z Android Development] Cobra281:
off topic question, kinda. i'm runing cyanogenmod 7, and used 4EXT recovery to make the partitions on my SD card. what partitions do i need to make use of sd 2 ext, and swap? just ext4 for the sd-ext, and a swap partition of 256mb? is that enough? thanks
[G2 and Desire Z Android Development] kbeezie:
Most roms I know of, do not support a second sd-ext , as a result I skip that.

Far as sd-ext , your /data is typically 1GB (1.3GB if G2 hboot), since /sd-ext is designed to act as your 'internal storage' in an ext4 formatted partition, all of your /data/app and /data/app-private will be migrated there (least they will automatically with EliteMod ICS or EliteMod CM7 when it detects a sd-ext partition).

So naturally you do not want an sd-ext size less than 1.5GB, 2GB ideally (thus giving you a lil more app space than you would have originally had.

In most cases the swap partition does not need to be more than 128MB (though with a Sense rom, 256 might be safer if not using a tool like Supercharge V6).

so recap:

sd-ext (ext4) : no smaller than 1.5GB

swap : 128MB should be fine (4EXT recovery doesn't do smaller)

sd-ext2 : skip, do not use.
[G2 and Desire Z Android Development] mikeinashed:
On the sense 4a Rom, keep getting an error - says ad card is not partitioned or can't find swap. Definitely partitioned. Will it just not work with this Rom?.

Ta.
[G2 and Desire Z Android Development] Steven How:
Which Rom ur using,I used gen this morning and it says the same..but taz rom works
[G2 and Desire Z Android Development] mikeinashed:
Yeah, gen Rom. Might try taz one. Cheers.
[G2 and Desire Z Android Development] proprg8:
Thanks!

Hello xT4Z1N4TRx,

Found this thread through search and I just tried your script on my xperia mini and it works great! I previously used a swap to cache script but it would only give me a 64Mb swap because the internal cache is only around 100Mb. Following your instructions, I partitioned 256Mb swap space on my sd card and ran your script. There was a little hitch at first but I used script manager and it finally worked. It makes a world of difference when running ram intensive apps plus I won't be wearing out my internal memory, just the partition on my sd card :). Thank you very much!

Cheers!
[G2 and Desire Z Android Development] Hyflex:
I get the error:

/mnt/sdcard/swap_enabler.sh: arith: syntax error: "65 on +2

Any idea?
[G2 and Desire Z Android Development] rirozizo:
try

su

swapon /dev/block/vold/179:67

it's actually depending on the ROM's partition handling... the script is meant for 179:65... it said 179:67 so you should type the above command.

———————————————————

pm me if you need any app... ANY app
[G2 and Desire Z Android Development] Hyflex:
IWLT ROM:

C:\Users\Anon>adb shell
# chmod 755 /mnt/sdcard/swap_enabler.sh
chmod 755 /mnt/sdcard/swap_enabler.sh
# su
su
# swapon /dev/block/vold/179:67
swapon /dev/block/vold/179:67
# free
free
total used free shared buffers
Mem: 376748 373020 3728 0 1324
-/+ buffers: 371696 5052
Swap: 249660 0 249660

It doesn't start every time?
[G2 and Desire Z Android Development] rirozizo:
no it will not start on every reboot... you'll have to use Script Manager to start it on boot

———————————————————

pm me if you need any app... ANY app
[G2 and Desire Z Android Development] kbeezie:
What he said. For example see the link in my sig for SDEXT/DataSwap enabler, unpack the zip and look at the dataswap sh that would go in /system/etc/init.d/80dataswap , you can of course change out the lines of code in it to instead activate a SD Swap Partition (bear in mind the SD Swap may differ if it's more than just FAT32 and Swap on there [ie: sd-ext, so double check]), and then would just pop that into your /system/etc/init.d and chmod it 0755 so that it'll always activate your SD Swap upon boot.

In the SD-EXT enabler script, there was an original peice of code at the bottom of it from EliteMod ICS that looked like this, which enabled SD Swap after it enabled SD-ext (/system/etc/init.d/04sdcardparts):

# ...

# find SD Card
for MMC_NUM in `seq 0 9`;
do
MMC_TYPE=`cat /sys/block/mmcblk$MMC_NUM/device/type`
if [ "$MMC_TYPE" = "SD" ];
then
# 3rd partition of sdcard should be the linux-swap if exist
LINUX_SWAP_PART=/dev/block/mmcblk${MMC_NUM}p3

# wait for the device to settle
if [ "$LINUX_SWAP_PART" = "" ];
then
COUNT=3;
until [ -b "$LINUX_SWAP_PART" ] || [ $COUNT -lt 1 ];
do
sleep 2;
COUNT=$((COUNT-1));
break
done;
fi
fi
done

if [ -b "$LINUX_SWAP_PART" ];
then
$BB freeramdisk $LINUX_SWAP_PART;
if [ "$?" = 0 ];
then
$BB swapon $LINUX_SWAP_PART;
if [ "$?" = 0 ];
then
log -p i -t swap2sd "Swap partition activated";
else
log -p e -t swap2sd "Unable to activate swap, exiting";
exit 1;
fi;
else
log -p e -t swap2sd "Unable to freeramdisk, exiting";
exit 1;
fi;
fi;

Basically what his bit of code does is find's the SD card by going thru the blocks til it hits an 'SD' type, and see's if there is a 3rd partition on the SD card (note the p3 at the end) and then activates it if so. It assumes the second one is sd-ext. But because we know this will be on a HTC Vision (G2/Desire-Z) we already know which block it is, so could instead shorten it a tad end up using this script for the whole SD swap:

#!/system/bin/sh
LINUX_SWAP_PART=/dev/block/mmcblk1p3

# wait for the device to settle
if [ "$LINUX_SWAP_PART" = "" ];
then
COUNT=3;
until [ -b "$LINUX_SWAP_PART" ] || [ $COUNT -lt 1 ];
do
sleep 2;
COUNT=$((COUNT-1));
break
done;
fi

if [ -b "$LINUX_SWAP_PART" ];
then
$BB freeramdisk $LINUX_SWAP_PART;
if [ "$?" = 0 ];
then
$BB swapon $LINUX_SWAP_PART;
if [ "$?" = 0 ];
then
log -p i -t swap2sd "Swap partition activated";
else
log -p e -t swap2sd "Unable to activate swap, exiting";
exit 1;
fi;
else
log -p e -t swap2sd "Unable to freeramdisk, exiting";
exit 1;
fi;
fi;

and if you don't use an sd-ext partition, change p3 to p2. I'm guessing $BB is the enviroment variable for the busybox command (normally /system/xbin/busybox). Depending on how your rom is setup, you can instead copy in parts of the above into your userinit, since it's not exactly critical for swap to be activated early in the system (where as sd-ext is pretty important if your apps live there).
[G2 and Desire Z Android Development] Hai_Duong:
I used this script on Sense 4A ROM and its not working... its not compatible ??? I used swap_enabler.sh from Virtuouse Team and its still not working it always say i dont have SWAP, but when i start 4ext recovery and tap on information it shows SWAP 129mb... I hope someone can help me
[G2 and Desire Z Android Development] rirozizo:
maybe the ROM itself doesn't support swap.... yet
[G2 and Desire Z Android Development] Hai_Duong:
I thought that too but i couldnt really test it to see if its supported by the kernel...
[G2 and Desire Z Android Development] kbeezie:
You can test by typing the commands manually in shell. Kinda like how I noticed swapon was not enabled in flinny's Jelly Bean.

Sent from my T-Mobile G2
[G2 and Desire Z Android Development] Hai_Duong:
I tested manually still cant find swap partition...
[G2 and Desire Z Android Development] ilbeppez:
Just enabled it with 128 ext and 256 swap,

I think it worked ^^

great tutorial ;)
[G2 and Desire Z Android Development] oVeRdOsE.:
I have a milestone, with swap partition on. With 128 device is unusable, 64 not bad, but with 32mb is perfect. Most of the members agreed with that.

I dont know if it the same for the DZ, I'm trying 128 right now, I cant say if theres a difference for now.

Its hard to say since the DZ can run almost everything on the market.

Milestone can run more games with swap on.
[G2 and Desire Z Android Development] ilbeppez:
After few days I encontered lots of lags.. so i removed the script and everything went fine again.

Maybe it's beacause I'm on ICS.