Create/Resize Swapfile

Run script to create a swapfile:

# Create empty swapfile of 4G
dd if=/dev/zero of=/swapfile bs=1M count=4096

# Set permissions
chown root:root /swapfile
chmod 0600 /swapfile

# Make a swapfile and activate it
mkswap /swapfile
swapon /swapfile

# Show activated swapfiles and deactivate old
swapon -s
swapoff /old_swapfile

Edit /etc/fstab and add line:

/swapfile    none    swap    sw    0   0

Retrieved from "$'"1"