A step-by-step guide to adding swap space on Ubuntu using a swap file. Covers checking existing swap, creating and sizing the swap file with fallocate or dd, setting correct permissions, enabling swap with mkswap and swapon, making it persistent via /etc/fstab, and tuning vm.swappiness and vm.vfs_cache_pressure for server
•14m read time• From digitalocean.com
Table of contents
IntroductionWhat is Swap?Swap File vs. Swap PartitionRecommended Swap Size by RAMStep 1 – Checking the System for Swap InformationStep 2 – Checking Available Space on the Hard DriveStep 3 – Creating a Swap FileStep 4 – Enabling the Swap FileStep 5 – Making the Swap File PermanentStep 6 – Tuning Swap and Cache SettingsResizing or Removing SwapTroubleshootingFAQConclusionSort: