1. Create a blank file where you would like the swap partition mounted
    • touch /swapfile
  1. Allocate the amount of memory you want to the file
    • fallocate -l 4GB /swapfile
  1. Change the permissions on the file to keep it secure
    • chmod 600 /swapfile
    • chown root:root /swapfile
  1. Convert the file into a swap type
    • mkswap /swapfile
  1. Create persistent settings so that it will create the file on boot
    • vim /etc/fstab
    • /swapfile swap swap defaults 0 0
  1. Turn swap off and then on
    • swapoff -a && swapon -a
  1. Verify the changes have taken effect
    • free -h

Leave a Reply

Your email address will not be published. Required fields are marked *