AlexVeeBee's Wiki

Creating a swap file

The swap file is a .img file to store the swap file

  1. Creating a directory to store the swap
mkdir /media/fasthdd
  1. Create the swap file
dd if=/dev/zero of=/media/fasthdd/swapfile.img bs=1024 count=1M

This will take a few seconds or minutes depending on the size.

This will create a 1GB swap
If you want a bigger swap, set the count number to like 4M for 4GB or 8M for 8GB

  1. Bake the swap
mkswap /media/fasthdd/swapfile.img

images.jpg

  1. Activate the swap
    This will ensure that the file will be activated on boot. Edit the /etc/fstab file
nano /etc/fstab

and add this below the default /swap.img

/media/fasthdd/swapfile.img swap swap sw 0 0

Optionally, you can comment that swap out.