A lot of people are asking about swap in an OpenVZ VPS.
Usually swap is not good but in some cases there are applications that need swap, or need at least to see swap available in order to run correctly.


In order to make your VPS believe it has a swap partition you can use the script below. We also recommend you to run the script at system startup also.


You need to remember that this will not actually be a real swap partition and should read the article, following the link at the bottom.

#!/bin/bash
SWAP="${1:-512}"
NEW="$[SWAP*1024]"; TEMP="${NEW//?/ }"; OLD="${TEMP:1}0"
umount /proc/meminfo 2> /dev/null
sed "/^Swap\(Total\|Free\):/s,$OLD,$NEW," /proc/meminfo > /etc/fake_meminfo
mount --bind /etc/fake_meminfo /proc/meminfo


The script was taken from: http://forum.openvz.org/index.php?t=msg&goto=27275&
DLow Reviewed by DLow on . How to enable swap inside your VPS A lot of people are asking about swap in an OpenVZ VPS. Usually swap is not good but in some cases there are applications that need swap, or need at least to see swap available in order to run correctly. In order to make your VPS believe it has a swap partition you can use the script below. We also recommend you to run the script at system startup also. You need to remember that this will not actually be a real swap partition and should read the article, following the link at Rating: 5