Using a swapfile to increase the swap space on your system
This can be a very handy function if we want to use a file, instead of a partition, and with modern filesystems the performance is almost on par with using a dedicated partition for your swap area.
1. Using dd lets make a zero’d file for the swap
dd if=/dev/zero of=/swapfile bs=1048576 count=1000
2. Make file as a swapfile
mkswp /swapfile
3. Activate swapfile
swapon /swapfile
4. Verify that our swapfile has been activated
swapon -s
Filename Type Size Used Priority
/swapfile file 9999992 0 -2
open up /etc/fstab in your favourite editor and add the following line.
/swapfile swap swap defaults 0 0