Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes. I think might also need to chmod 600 /swapfile. I do this on all my VPS, especially helps for small VPS with only 1GB ram:

   fallocate -l 1G /swapfile
   chmod 600 /swapfile
   mkswap /swapfile
   swapon /swapfile
Works really well with no problems that I've seen. Really helps give a bit more of a buffer before applications get killed. Like others have said, with SSD the performance hit isn't too bad.


IME SWAP has been explicitly disabled by the VPS providers.

Partly it's a money thing (they want to sell you RAM), partly it's so that the shared disk isn't getting thrashed by multiple VPS


Get better VPS then. Openvz and other kernel paravirtualization have limits, go for Xen or KVM instead (Xen has paravirtualization as well, but I'm not sure how much it's actually used). Full virtualization (implemented by Xen and KVM) do not allow you to prevent swap from being used.


I forgot to mention what the parent comment said, yes, need to put something like this in /etc/fstab:

/swapfile swap swap sw 0 0

or via ansible:

    mount:
      src: "/swapfile"
      name: "swap"
      fstype: "swap"
      opts: "sw"
      passno: "0"
      dump: "0"
      state: present




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: