How to Add a Swap File
A swap file acts as virtual RAM. It's used when your physical RAM is full. While not a replacement for more RAM, it can help prevent out-of-memory errors on systems with limited resources.
Creating a 1GB Swap File
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
CopyMaking the Swap File Permanent
To ensure the swap file is activated on boot, add it to `/etc/fstab`:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Copy