Create a swap file

Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"

Top Level » System Level

Create a swap fileLast Modified: Oct 21, 2018, 8:26 pm
Some VPSs do not come with a swap file.   DirectAdmin recommends to 2 Gig of ram, and 4 Gig of swap.
The more ram the better, but much more than 4Gig of swap isn't as useful.

To add 4 Gig of swap, assuming you have enough space on disk, would be to run:

dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

and confirm it's loaded in with:

free -m

or by running "top".

If it works, then add this into your /etc/fstab:

/swapfile   swap    swap    sw  0   0

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST