Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,771,111 Members 47,261 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] How to create a swap partition on external micro-sd

Tip us?
 
Segnale007
Old
#1  
Segnale007's Avatar
Senior Member - OP
Thanks Meter 172
Posts: 836
Join Date: Feb 2010
Location: London
Default [GUIDE] How to create a swap partition on external micro-sd

Alright folks, you asked for it and here's a simple how-to that will guide you to create and enable a swap partition on external micro-sd on our SGS.

First things first I assume you have already flashed the kernel Devil2_0.73_swap_i9000_CFS_BLN_CMC_20120420 or any other kernel which supports swap partition.

First thing, you want to partition your SD card in order to create our swap partition, I recommend you to follow this accurately.
If you are on mac you can use iPartition to partition your sd-card, while linux users can use Gparted or any other partition tool they may like.

Now that we have successfully created our swap partition, we want to boot up the phone and enable our swap partition in order to be accessible to the kernel.

To detect the swap partition that we have just created open up a ADB terminal and type

Code:
fdisk -l dev/block/mmcblk1
it will look something like this

Code:
/dev/block/mmcblk1p2            1861        1924      514080  82 Linux swap
write down the exact number of the swap partition and let's activate it by typing

Code:
swapon /dev/block/mmcblk1pX
** where X is the number of the swap partition **

We can now check if our swap partition has been activated by executing the command free

Now we want to make our swap partition to be activated at boot time, without having to activate it manually everytime we reboot the phone.

Assuming you know how to at least write and save a text file in VI, let's go back to our fido ADB shell and type

Code:
vi /system/etc/init.d/05userinit
now lets drop few lines in

Code:
#Activate swap at boot

#!/system/bin/sh

swapon -a
If you are not really comfortable with VI you can also use Nano or even RootExploer or any other root editor if you are more comfortable with UI.

save it and once again in ADB shell lets make it executable

Code:
chmod 750 /system/etc/init.d/05userinit
Now lets create a fstab file so that the kernel can look at and activate the correct swap partition

Code:
vi /system/etc/fstab
Here it goes our swap partition. Remember where X is your actual swap partition according to your partition layout.

Code:
/dev/block/mmcblk1pX swap swap
As last step you may want to change the swappiness value. Note that most of the roms have it set to 60 by default, which is good enough in my opinion, although setting it to higher (max is 100) may help to improve overall performance, while setting it to lower may increase interactivity and overall stability.

Temporary change (until next reboot)

Code:
echo 60 > /proc/sys/vm/swappiness
Permanent change

Code:
echo vm.swappiness=60 >> /system/etc/sysctl.conf
As result

Code:
shell@android:/ # free
             total         used         free       shared      buffers
Mem:        385772       376352         9420            0        26420
-/+ buffers:             349932        35840
Swap:       514076            0       514076

** few notes **

I don't intend to take credit for this how-to as it takes few pieces of commands and hints from any guides out there which covers this topic, and anyways its basic linux knowledge really..

/** A special shout goes out to @DerTeufel1980 for listening to our request and enabling swap on his kernel. **/

So cheers you all and enjoy
-- Follow me on Twitter --


The Following 33 Users Say Thank You to Segnale007 For This Useful Post: [ Click to Expand ]
 
Segnale007
Old
#2  
Segnale007's Avatar
Senior Member - OP
Thanks Meter 172
Posts: 836
Join Date: Feb 2010
Location: London
You never know...
-- Follow me on Twitter --


The Following 2 Users Say Thank You to Segnale007 For This Useful Post: [ Click to Expand ]
 
lerkin
Old
#3  
lerkin's Avatar
Senior Member
Thanks Meter 353
Posts: 1,053
Join Date: Jan 2011
Location: msk
Thanks for great guide!!
 
dark_knight35
Old
#4  
dark_knight35's Avatar
Senior Member
Thanks Meter 998
Posts: 1,936
Join Date: Jan 2012
Thx for this great guide.
Will try it out soon.
 
omyg
Old
#5  
Senior Member
Thanks Meter 124
Posts: 161
Join Date: Oct 2010
is it possible to make swap on internal flash storage ?
Question: [Q] How to find list of available LOCALES (LANGUAGES) from ROM image (file system) ?

Please post Answer to this thread : http://forum.xda-developers.com/showthread.php?t=1593711
 
dark_knight35
Old
#6  
dark_knight35's Avatar
Senior Member
Thanks Meter 998
Posts: 1,936
Join Date: Jan 2012
Quote:
Originally Posted by omyg View Post
is it possible to make swap on internal flash storage ?
Maybe, but most external sd cards are faster. And it's saver.
 
sthomas38
Old
#7  
Senior Member
Thanks Meter 532
Posts: 690
Join Date: Feb 2012

 
DONATE TO ME
Where can we find Devil2 73 please?

Envoyé depuis mon Amazon Kindle Fire avec Tapatalk
 
lerkin
Old
#8  
lerkin's Avatar
Senior Member
Thanks Meter 353
Posts: 1,053
Join Date: Jan 2011
Location: msk
http://forum.xda-developers.com/show...php?p=25085260
Sent from my GT-I9000 using Tapatalk 2
The Following User Says Thank You to lerkin For This Useful Post: [ Click to Expand ]
 
-ReaL-
Old
#9  
-ReaL-'s Avatar
Senior Member
Thanks Meter 112
Posts: 357
Join Date: Nov 2009
Location: Yoshkar-Ola

 
DONATE TO ME
it must be said that the card such use may come into disrepair faster
Unfortunately, I badly speak english. Sorry.
 
Segnale007
Old
#10  
Segnale007's Avatar
Senior Member - OP
Thanks Meter 172
Posts: 836
Join Date: Feb 2010
Location: London
Quote:
Originally Posted by dark_knight35 View Post
Thx for this great guide.
Will try it out soon.
Thank you all.. Your feedback is really important to me .

This guide has been tested on ICSSGS RC 4.2 with kernel Devil2_0.73_swap_i9000_CFS_BLN_CMC_20120420 . However it should just work fine on every roms and kernels which supports swap and do not mess with init.d.
-- Follow me on Twitter --



Tags
swap
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes