HOWTO: Create a Swap file
When installing Arch users are prompted to create a swap partition. This is the standard way for any Linux distribution.
But sometimes disk space is precious or users feels that swap partition is not needed as there's plenty of RAM.
So in this cases users can since Kernel 2.6 create a swap file which will be used instead of partition.
The biggest advantage of swap file compared to swap partition you can easily change it's size or remove it all together without formatting disk.
Creating swap file
Creating a swap file is quite easy.
First log in as root user.
Now you we have to create a file whch will be later formated to swap.
To do that write this into console:
# dd if=/dev/zero of=/swapfile bs=1024 count=wished_number_of_space*1024
It's also possible to set bs to 1M and then we don't need to multiply by 1024.
After creating a file that will serve as swap we now have to format it to swap.
And turn it on
# mkswap /swapfile # swapon /swapfile
Now all we have to do is make sure that swap file starts up after next boot. That is done by adding it to fstab.
# your_preffered_text_editor (eg.: nano) /etc/fstab
And then adding it to fstab:
/swapfile1 swap swap defaults 0 0
Well that's more or less it. Now you have a swap file which can be removed and made bigger or smaller according to your preferences.
Removing old swap file and creating new one
To remove old swap we have to first turn off current swap file and then delete it.
su # swapoff -a # rm -rf /swapfile
The we can create new swap file as described above.
Empty_Swap useful script to clear your swap
 A how to with which I made my swap file and inspired me to write this how to.