Skip to content

Instantly share code, notes, and snippets.

@rraallvv
Created October 21, 2018 17:34
Show Gist options
  • Save rraallvv/9173124897e3c800e450bf56eff96120 to your computer and use it in GitHub Desktop.
Save rraallvv/9173124897e3c800e450bf56eff96120 to your computer and use it in GitHub Desktop.
Create Fake Swap in OpenVZ VPS
#!/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
free -m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment