Creating a file based swap

First create a file "swapfile" with the input file of /dev/zero and the output file of "swapfile"
Byte Size is 1 gig and the loop count is 1, so it will create a file that is 1 GB.

Create the file:

dd if=/dev/zero of=swapfile bs=1G count=1

Then we permission it:

chmod 600 swapfile

Format it:

mkswap swapfile

And turn it on!:

swapon swapfile