VPS server configuration

How to create swap file to use as additional memory in VPS server

Viewing 1 post (of 1 total)
  • Author
  • #118

    Following are list of commands to create swap file to increase memory in VPS server using disk space

  • 1. Execute below command

    if the swap file size is 4 GB (128 MB x 32)
    $ sudo dd if=/dev/zero of=/swapfile bs=128M count=32

  • 2. Update the read and write permissions for the swap file:

    $ sudo chmod 600 /swapfile

  • 3. Set up a Linux swap area:

    $ sudo mkswap /swapfile

  • 4. Make the swap file available for immediate use by adding the swap file to swap space:

    $ sudo swapon /swapfile

  • 5. Verify that the procedure was successful:

    $ sudo swapon -s

  • 6. Enable the swap file at boot time by editing the /etc/fstab file.

    Open the file in the editor:

    $ sudo vi /etc/fstab

    Add the following new line at the end of the file, save the file, and then exit:

    /swapfile swap swap defaults 0 0

  • To check if the swap is active:
    $> free -m
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Would you like to subscribe to our notifications?
Would you like to install our app?

Progressive Web App (PWA) is installed successfully.