Results 1 to 4 of 4

Thread: How to create a swapfile in your VPS

  1. #1
    Join Date
    Jan 2006

    Default How to create a swapfile in your VPS


    We've been noticing quite a few people trying to add more memory to their VPS by creating a swapfile. This will NOT work, and will only result in your VPS being unbootable.

    If you need more memory, upgrade via the control panel.

    We don't have the full specifics of why OpenVZ will not allow this, but our theory (based on the resource utilization reports in /proc/user_beancounters, and the error messages we receive when the VPS will not start) is that when you enable swapping on the file, the resource allocation is NOT increased, and the use of the additional memory from the swapfile causes you to use more memory than is assigned to your VPS. This means the OpenVZ resource system kills processes and refuses to allocate more memory (since it thinks you are using more memory than you are paying for) and logs memory overutilization errors. When trying to restart the VPS, the massive numbers of memory overutilization prevent the VPS from even booting.

    The only way we are able to restart your VPS if you do this, is to reboot the hardware node (which would affect all other VPS's also hosted on the same node, not something we are likely to do) or rebuild your VPS from scratch manually. So please, don't try to add more memory to your system with a swapfile, it just doesn't work.

    Update: Even running mkswap seems to trigger this problem, so our theory is not completely correct. Still does not change the fact that it causes the VPS to be unbootable without manual intervention.

    Update (12/24/2008): Note that this applies only to OpenVZ VPS's. Our newer Xen VPS's allow for creation of swap files to increase available memory, at the expense of disk i/o in extreme cases.
    Last edited by Lyle@VPSlink; 12-24-2008 at 03:51 PM. Reason: Xen update

  2. #2


    Great response Lyle

    I personally don't mind the no-swap policy -- since most of us are running web services, swapping isn't particularly ideal.
    Kelvin Nicholson - Blacklist and availability monitoring built from the ground up for outsourced IT providers.

  3. #3
    MikeG@VPSlink Guest


    Just to clarify- this only applies to OpenVZ. XEN can have swapfiles.

  4. #4
    Join Date
    Oct 2007


    Quote Originally Posted by kelvinn View Post
    I personally don't mind the no-swap policy -- since most of us are running web services, swapping isn't particularly ideal.
    Not if you plan on running any Java apps. I would gladly get that 140M back Tomcat takes up from trying to use swap space

    Granted that is one very rare case that would justify a dedicated server if the site really takes off.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts