# Check Current Swap
sudo swapon -s
# Create Swap File
sudo fallocate -l 4G /swapfile
chmod 600 /swapfile
# Make it to swap format and activate on your system
sudo mkswap /swapfile
sudo swapon /swapfile
# Make Swap Permanent
sudo vim /etc/fstab
# and add below entry to end of file
/swapfile none swap sw 0 0
# Check System Swap Memory
sudo swapon -s
free -m
# Update Swappiness Parameter
sudo vim /etc/sysctl.conf
# append following configuration to end of file
vm.swappiness=10
# Now reload the sysctl configuration file
sudo sysctl -p
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
output
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=fde7d2c8-06ea-400a-9027-fd731d8ab4c8
Copy
sudo fallocate -l 2G /swapfile
Copy