Im trying adding swap file by following this guide:

Everything is fine, but starting swapon /swapfile, I got this message:
swapon: /swapfile: Operation not permitted

Use sudo swapon /swapfile also not works, and I got this message:
audit_log_user_command(): Connection refused
swapon: /swapfile: Operation not permitted

After reboot, I use the same command.. also not works

2 Answers 2


This sounds like you are on a virtualized host based on openvz.

The "audit_log_user_command" error is common from a few version of openvz/virtuozzo that didn't patch a kernel bug that echo'd that out to the screen.

In this case, you cannot create swap, you are only allocated a certain amount of system memory. After you exceed this, you will be unable to allocate memory and get OOM kills depending on how frequently you attempt to spawn new processes near the barrier.

  • Im in VPS hosting, but not sure if it was openvz. Is it impossible to use swap in virtualized host based on openvz?
    – Faris
    Jan 30, 2010 at 2:38
  • That's right Faris, openvz doesn't let you use swap at all, it just gives you chunks of ram to use. You an think of an openvz VPS as a "super" chroot, you don't actually have a virtualized operating system, just most of the userspace processes you need to run pretty much the same thing.
    – epic9x
    Feb 1, 2010 at 18:13
  • Also, if you want to be sure you're in openvz, you can always check for the existance of a file /proc/user_beancounters, if that's there you're very likely on openvz/virtuozzo.
    – epic9x
    Feb 1, 2010 at 23:56

Wow. . .this had me stumped for awhile too.

I guess I found the answer is that you can't create swapfiles in a OpenVZ/Virtuozzo environment, since it uses swap inherently.

You must log in to answer this question.