5

Is there a way of limiting number of cpu cores seen from inside a VE? I have an eight core server, but I want my VE to see only one particular core.

Thanx!

TiFFolk
  • 1,077
  • 3
  • 14
  • 25

2 Answers2

10

If you vz is number 101, than use the following to set it two 2 CPUs (change the number accordingly):

vzctl set 101 --cpus 2 --save

No restart of the VE required. The --save makes it so when the VE is rebooted, the changes will still be there. vzctl --help for other resources that can be set.

Kyle Brandt
  • 82,107
  • 71
  • 302
  • 444
  • This does not work with the newer kernels (2.6.32, used in Debian) currently. The same applies to "cpulimit" (documented at http://wiki.openvz.org/Resource_shortage#cpulimit). – blueyed Oct 14 '10 at 18:27
6

OpenVZ isn't really virtualization. It's containerization. So each container sees the system that it's on as it's own. To control how much cpu time each VE can get you have to assign each VE cpucredits. This page goes into how set the limits on each VE.

Edit: Just found this in the vzctl man page.
--cpulimit num[%] Limit of CPU usage for the VE, in per cent. Note if the computer has 2 CPUs, it has total of 200% CPU time. Default CPU limit is 0 (no CPU limit). --cpus num sets number of CPUs available in the VE.

So Kyle's answer is correct. But I'll leave this answer here b/c there are more than one nob here to tweak.

3dinfluence
  • 12,409
  • 2
  • 27
  • 41
  • Might be a better option for his/her unstated end goal as well. – Kyle Brandt Jan 08 '10 at 20:24
  • 1
    If I only had known this last week. I was dealing with CPUUNITS and didn't understood them correctly until too late. Thanks to vzsplit now I have a better performance on my system. – Leandro López Sep 05 '10 at 00:52