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
it will look something like this
write down the exact number of the swap partition and let's activate it by typing
** 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
now lets drop few lines in
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
Now lets create a fstab file so that the kernel can look at and activate the correct swap partition
Here it goes our swap partition. Remember where X is your actual swap partition according to your partition layout.
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)
Permanent change
As result
** 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
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