Forgot to create a swap partition? Here’s how you add a swap file (do this with root privileges):
- Create the actual file, we’ll go for 1GB (1048576 blocks à 1024 bytes = 1GB):
dd if=/dev/zero of=/swapfile_1GB bs=1024 count=1048576
- Set permissions:
chmod 0600 /swapfile_1GB
- Transform the file into a swap file:
mkswap /swapfile_1GB
- Activate the new swap file:
swapon /swapfile_1GB
- Make the swapfile permanent (surviving reboots):
echo "/swapfile_1GB none swap sw 0 0" >> /etc/fstab