Debian, create swapfile

From Andreida

source

  • create the file and set it read only
fallocate -l 4G /swapfile
chmod 600 /swapfile
  • set as swap and activate
mkswap /swapfile
swapon /swapfile
  • modify /etc/fstab so it will be set after a reboot
/swapfile   none    swap    sw    0   0