How To Add More Swap Space In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. Check the Current Swap Space and Usage Run the following command to check the existing swap space and its usage: $sudo swapon –s
2. Create a New File as Swap Space You can create a swap file using the dd command. For example, to create a 2 GiB swap file, you would run: $sudo dd if=/dev/zero of=/swapfile bs=1024 count=2097152
3. Set the Permission on the Swap File Setting the correct permissions on the swap file is important for security. You can use the chmod command to set 600 permission on your swap file: $sudo chmod 600 /swapfile
4. Enable the Swap File Now you can enable the swap file using the following command: $sudo mkswap /swapfile
5. Activate the Swap File The new swap space is available, but it is not activated yet. To activate it, use the following command: $sudo swapon /swapfile
6. Make the Swap File Permanent To make sure that the swap file is enabled after a reboot, open /etc/fstab file and add the following line at the end of the file: /swapfile swap swap defaults 0 0