ionbasa wrote:The other one posted creates a swap file, not letting you use an actual partition on the SD card, therefore resulting in a slight bottleneck. But this script seems to work perfectly if you have a swap partition. My sd card is formatted as follows: Fat32 / EXT4 / SWAP. You should be able to recreate this in either CWM or TWRP.
[ DISCLAIMER ] I am not a swap expert so these are simply common sense ideas about the subject....
As I understand it, much of the discourse on swap (partition vs file) comes from the hard drive concepts and original Linux. Keep in mind that we would not be using a hard drive, but rather an SD card with charasteristics quite different from an HD.
In my opinion it doesn't make a lot of difference wether you use a single, contiguous swap file or a partition.
Creating a "normal" file with dd will allocate the file (if at all possible) in a single run, while creating a sparse file will tell you that you have a 10GB file lying around but not actually using up all the space.
So, if the swapfile isn't fragmented, it's exactly as if there were a swap partition at its same location. Or put another way, you'd get identical performance if you used a swap partition raw, or formatted it with a filesystem and then created a swapfile that filled all space, since either way there is a contiguous region used for swapping, which the kernel uses directly.
Thus if we create the swapfile when the filesystem is fresh or has lots of contiguous space (thus ensuring it's not fragmented and at the beginning of the volume), performance should be identical to having a swap partition just before the volume.
On Linux, if the swapfile is created unfragmented, and never expanded, it cannot become fragmented, at least with normal filesystems like ext3/4. It will always use the same blocks, which are contiguous.
Internally, the Linux kernel will access the underlying blocks of a swap file more or less directly.