Post Reply

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

OP Segnale007

21st April 2012, 10:07 AM   |  #1  
Segnale007's Avatar
OP Senior Member
Flag London
Thanks Meter: 172
 
836 posts
Join Date:Joined: Feb 2010
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
The Following 33 Users Say Thank You to Segnale007 For This Useful Post: [ View ]
21st April 2012, 10:07 AM   |  #2  
Segnale007's Avatar
OP Senior Member
Flag London
Thanks Meter: 172
 
836 posts
Join Date:Joined: Feb 2010
You never know...
The Following 2 Users Say Thank You to Segnale007 For This Useful Post: [ View ]
21st April 2012, 10:24 AM   |  #3  
lerkin's Avatar
Senior Member
Flag msk
Thanks Meter: 354
 
1,059 posts
Join Date:Joined: Jan 2011
Thanks for great guide!!
21st April 2012, 10:31 AM   |  #4  
dark_knight35's Avatar
Senior Member
Thanks Meter: 998
 
1,936 posts
Join Date:Joined: Jan 2012
Thx for this great guide.
Will try it out soon.
21st April 2012, 11:11 AM   |  #5  
Senior Member
Thanks Meter: 124
 
161 posts
Join Date:Joined: Oct 2010
is it possible to make swap on internal flash storage ?
21st April 2012, 11:19 AM   |  #6  
dark_knight35's Avatar
Senior Member
Thanks Meter: 998
 
1,936 posts
Join Date:Joined: Jan 2012
Quote:
Originally Posted by omyg

is it possible to make swap on internal flash storage ?

Maybe, but most external sd cards are faster. And it's saver.
21st April 2012, 11:39 AM   |  #7  
Senior Member
Thanks Meter: 532
 
690 posts
Join Date:Joined: Feb 2012
Donate to Me
More
Where can we find Devil2 73 please?

Envoyé depuis mon Amazon Kindle Fire avec Tapatalk
21st April 2012, 11:45 AM   |  #8  
lerkin's Avatar
Senior Member
Flag msk
Thanks Meter: 354
 
1,059 posts
Join Date:Joined: Jan 2011
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: [ View ]
21st April 2012, 11:55 AM   |  #9  
-ReaL-'s Avatar
Senior Member
Flag Yoshkar-Ola
Thanks Meter: 112
 
361 posts
Join Date:Joined: Nov 2009
Donate to Me
More
it must be said that the card such use may come into disrepair faster
21st April 2012, 12:47 PM   |  #10  
Segnale007's Avatar
OP Senior Member
Flag London
Thanks Meter: 172
 
836 posts
Join Date:Joined: Feb 2010
Quote:
Originally Posted by dark_knight35

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.

Post Reply Subscribe to Thread

Tags
swap
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Galaxy S I9000 Android Development by ThreadRank