5

Im trying adding swap file by following this guide:
http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/custom-guide/s1-swap-adding.html

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

MadHatter
  • 78,442
  • 20
  • 178
  • 229

2 Answers2

6

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.

epic9x
  • 1,618
  • 10
  • 9
  • Im in VPS hosting, but not sure if it was openvz. Is it impossible to use swap in virtualized host based on openvz? –  Jan 30 '10 at 02: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 01 '10 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 01 '10 at 23:56
2

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.

Eric
  • 41
  • 5