How can I increase virtual memory in Ubuntu?

To increase the virtual memory of Ubuntu, you can follow these steps:

  1. Open the terminal and use the following command to create a file for storing virtual memory:
  2. Create a swap file with a specified size using the sudo fallocate command.
  3. The parameter represents the size of the virtual memory file to be created, measured in gigabytes.
  4. Establish permissions to ensure only the root user can read and write to the virtual memory file.
  5. Change the permissions of the file “swapfile” to 600 using sudo.
  6. Convert the file into a swap space.
  7. Create a swap file using the command “sudo mkswap /swapfile”
  8. Enable swap space.
  9. Enable the swap file using sudo command.
  10. To automatically mount the swap space during system startup, you need to edit the /etc/fstab file.
  11. Open the file /etc/fstab using the nano text editor with administrator privileges.
  12. Add the following lines at the end of the document:
  13. /swapfile should have the following settings: swap, swap, defaults, 0, 0
  14. Save and close the file.
  15. Finally, reboot the system to apply the changes.
  16. Restart the system using elevated privileges.

After completing the above steps, the virtual memory of Ubuntu will be increased. You can verify if the virtual memory has successfully increased by running the following command.

sudo swapon --show
bannerAds