Create swap file in Linux

1. Create the 1GB swap file (takes a few seconds)

sudo fallocate -l 1G /swapfile

# Alternative if fallocate does not work: # sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

# 2. Ensure correct permissions (root only) sudo chmod 600 /swapfile# 3. Format as swap area sudo mkswap /swapfile# 4. Enable the swap su

do swapon /swapfile# 5. Verify it is active sudo swapon –show free -h# 6. Make it permanent (add to /etc/fstab) echo ‘/

This post is also available in ESPAÑOL.

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .