A while ago while Thomas Schmitt was helping me with dd and xorriso in backing up systems and partitions into usb and back the issue of not having a swap partition in my system came up, since I chose not to during the installation, and how to create one, lead me into a search of doing just that.
In the page https://askubuntu.com/questions/33697/how-do-i-add-a-swap-partition-after-system-installation there are instructions that I believe work just as well on Debian to either create a new partition for swap or create a swap file, which I did not know it was an option. I chose the second as my partitioning has become complex and most of the drive is not available during boot-up. So I assume it would run to an error if I did this on a partition that is not available during boot. Below you will find the exact instructions I used and worked fine for me on Stretch (I believe to be true for all Debian). But here come some questions: 1 What is the difference functionally of having a swap partition from having a swap file? Is it that you can use a separate physical disk that will take the wear and tear of swaping? 2 Is swap size relevant to ram, should it be equal, greater, smaller? Advantages disadvantages? I rarely see in a workstation and my/our use anywhere close to 4GB being used, it usually maxes out around 2,5GB. No, no killing games here, maybe some chess and gnubg. Is it that a Ram of 1GB would benefit from 2-4GB swap space while with 16GB or Ram swap would never be used? 3 chmod 600 for the swapfile. Why? 4 Is "dd bs=1M count=4M" that defines the 4,000Mb of space/size of the file? I am now going to use gnubg to test my mem capabilities. I think making it calculate best move 4-5 moves ahead in bg or chess will stress the system out :) _______________________________________________________ # Create an empty file (1K * 4M = 4 GiB) sudo mkdir -v /var/cache/swap cd /var/cache/swap sudo dd if=/dev/zero of=swapfile bs=1K count=4M sudo chmod 600 swapfile # Convert newly created file into a swap space file. sudo mkswap swapfile # Enable file for paging and swapping. sudo swapon swapfile # Verify by: swapon -s or top: top -bn1 | grep -i swap # KiB Swap: 4194300 total, 4194300 free # To disable, use sudo swapoff swapfile. # Add it into fstab file to make it persistent on the next system # boot. echo "/var/cache/swap/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab # Re-test swap file on startup by: sudo swapoff swapfile sudo swapon -va _____________________________________________________________ -- "The most violent element in society is ignorance" rEG