Adding extra swap to a Linux system
Add Swap Space
Small compute instances with limited memory can slow things down and overload the CPU. You want to add 2x of your available RAM in swap space in my case, this is 1.2GB of swap for 600MB of RAM. Create your swap file:
sudo fallocate -l 1.2G /swapfileChange permissions to only allow root access:
sudo chmod 600 /swapfileSet up a Linux swap area on the file:
sudo mkswap /swapfileMake sure the changes are permanent by modifying the filesystem table:
sudo nano /etc/fstabAppend /swapfile swap swap defaults 0 0 to the end of the file. It should look like this:
LABEL=cloudimg-rootfs / ext4 defaults 0 1
LABEL=UEFI /boot/efi vfat defaults 0 1
/swapfile swap swap defaults 0 0