Swap

Swap space is used to free chunks (pages) of memory from the RAM. This is needed when the physical memory is running out, or when pages initially created by a program are not needed any more. There are two types of swap space: swap partition and swap file.

Swap Partition
TODO

Swap File
More flexible than swap partition and well supported today. May not be the best choice on old fragmented hard disk though.

Setup
fallocate -l 4G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile /swapfile none swap defaults 0 0 swapoff -a rm /swapfile
 * As root, create the swap file:
 * Activate the swap file:
 * Optionally make it available when system starts, in /etc/fstab, add:
 * If you need to delete it:

Server specific things
Scaleway provides a script that does exactly above, with the exception of adding the swap file to the fstab. The script can be used like this: /usr/local/sbin/scw-swapfile start  # create and activate a 4GB swap file in /swapfile /usr/local/sbin/scw-swapfile stop   # de=activate and delete /swapfile If you need an different swap file size, you can edit SWAPFILE_SIZE in the script.