I am going to install ubuntu 18.4 (dual booting with windows). I currently have 4GB RAM. I am going to add 8GB RAM in the next month or so. so, while I am installing ubuntu how much swap area should I use? Should I use it according to 4GB RAM or 8GB RAM? . Doubt 2: would it matter how much space I use for the swap? When I searched how much space I should use I saw many methods for choosing. can I add space as I like? Is there a specific rule? I don't know what to do, please help me.
With your decision to move from 4G RAM to 12G RAM, comes a very important decision. Memory is best installed in pairs of exactly similar RAM sticks. This is so the system can take the speed advantage of memory interleaving. You should consider either, adding another 4G RAM stick, or replacing the current 4G stick with two 8G sticks.
Good question. Swap and swap sizing is important. You'll probably get a ton of opinions about it.
Assuming that you don't already have a /swapfile or swap partition, go ahead and create a 4G /swapfile. To check for an existing /swapfile or swap partition, use these commands:
free -h ls -al /swapfile grep -i swap /etc/fstab
To create a 4G /swapfile...
Note: Incorrect use of the
dd command can cause data loss. Suggest copy/paste.
Note: The first two commands may show an error if no current /swapfile exists.
sudo swapoff -a # turn off swap sudo rm -i /swapfile # remove old /swapfile sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 sudo chmod 600 /swapfile # set proper file protections sudo mkswap /swapfile # init /swapfile sudo swapon /swapfile # turn on swap free -h # confirm 4G RAM and 4G swap
Add this line to /etc/fstab...
Note: This assumes no existing swap line in /etc/fstab.
/swapfile none swap sw 0 0
Reboot and confirm proper operation.