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
fdisk -l dev/block/mmcblk1
/dev/block/mmcblk1p2 1861 1924 514080 82 Linux swap
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
#Activate swap at boot #!/system/bin/sh swapon -a
save it and once again in ADB shell lets make it executable
chmod 750 /system/etc/init.d/05userinit
/dev/block/mmcblk1pX swap swap
Temporary change (until next reboot)
echo 60 > /proc/sys/vm/swappiness
echo vm.swappiness=60 >> /system/etc/sysctl.conf
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