I remember once I tried to add CPU cores and virtual sockets to a VPS running windows server 2003 and it didn't work and somehow it became unstable and I couldn't use it anymore . Now I'm running Ubuntu 16.04 xenial server version on a VPS and I wonder if it's safe to change the number of cores and virtual sockets from 2-2 to 4-2 ?


This is fine to do. In most hypervisors you can even do this while online given an installed suite of guest tools. If you feel especially wary about it in any way, just "power off" the VM before editing its configuration.

If you're going to be mucking around with changing cores / sockets, then using CPU pinning and mirroring existing architecture will make best use of CPU caches and the like. Other than that, most virtual configurations will float processes as normal tasks. This makes considerations of emulated core / socket architecture pretty meaningless.

  • Thanks for the answer. I already powered off the VM before changing the core numbers . One more question , I want to use all Cpu cores of my server for this VM . Number of virtual sockets is 2 now and number of cores per socket is 4 now . Will this setting use all cpu power ? or is it opposite? the number of virtual sockets should be 4 and number of cores per socket should be 2 ? please guide me and tell me the difference . – gldcmt Sep 22 '16 at 9:40
  • It won't use all of your CPU power in any case, as the guest will be limited in regard to how much CPU time it may use. However, it will still have the ability to cripple the host. Further, why not put it directly on bare metal if you're going to use and pin all resources to it? You can't live migrate VMs that have pinned CPUs (if that's what you intend to accomplish here). – Spooler Sep 22 '16 at 9:48
  • yes you are right . this server had vmware installed when I bought it . thanks for the help anyhow – gldcmt Sep 22 '16 at 14:46

You can easily "add" more cores to your server while running by running this script:

for CPU in /sys/devices/system/cpu/cpu*/online ; do
grep -v -q 0 $CPU || continue
echo -n "Bringing $CPU online... "
echo 1 > $CPU || exit $?
echo OK

Assuming you already "added" some more cores/socket in vcenter/hyperv/whateveryouuse.

But ofcourse, it is no problem to add more cores and then reboot your VM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.