Please Note: This HowTo is pending a refactor. There are some things unclear in here. If you have any questions, Please reply to this post.
For those that don't like reading, a video
Note: This guide covers adding a swap file, not a swap partition. I have not tested hibernation with this method as I do not use hibernation, but if it does work it may be more secure on an encrypted Elive installation than a swap partition.
Adding a swap file in Linux is quick and painless. Please note that I learned all this from the ArchiveBot page on the Archive Team wiki, I'm just putting it in a more easily reachable place.
First, you want to create an empty file using
dd. Make sure you have enough space for this (on the command line:
df -h . before you start. This will make a 100MB file.
dd if=/dev/zero of=swapfile bs=1000 count=100000
Click for an explanation on the command.
dd is a command that copies raw data such as hard drives (although regular files work too). In this case, we're copying the special file
/dev/zero which is an infinitely long file with only binary 0s in it (therefore nothing in it) into a file called
swapfile (you can change that to whatever, you just need the
of= before it). The
bs field says how much to copy at a time; 4MB is ok. And
count=100000 will copy 100 000 KB, or around 100MB of data (feel free to change that value - 1000000 is about 1GB).
Now make the permissions secure so people can't just waltz in and corrupt your swap:
chmod 0600 swapfile
sudo chown root swapfile
Now, we need to make it a swap file.
sudo mkswap swapfile
sudo will likely ask for your password unless you've used it in the past few minutes.
Finally, we need to enable the swap file.
sudo swapon swapfile
If/when you want to turn it off, it's as simple as
sudo swapoff swapfile. If you use conky or a similar program, your swap capacity will slowly go down, sometimes as slowly as 20MB at a time. Eventually though, it'll be done.
If you know how to make a swap partition, another howto would be greatly appreciated!