1x cpu core is not enough for an SMB filesharing Ubuntu box.

How do we poweroff the VM at midnight, increase the cpu cores 1->2, and power on that box (script-wise)?

(it's a windows host... but Linux-examples welcome as well :)

screenshot here -> http://dwaves.de/index.php/2014/09/22/virtualbox-box-management/

  • This isn't facebook, please format your question. Sep 22, 2014 at 14:25

2 Answers 2


I would recommend trying hot-plug instead of powering off, changing CPU and starting it again.

First, you need to mark it as cpu-hot-plug:

VBoxManage modifyvm "VM name" --cpuhotplug on

Second, set a maximum CPU count

VBoxManage modifyvm "VM name" --cpus 2

Third and last, add or remove the "extra" cpu:

VBoxManage modifyvm "VM name" --plugcpu 1
# DO STUFF with extra core
VBoxManage modifyvm "VM name" --unplugcpu 1

Make sure you have installed the Linux Guest Additions or the Ubuntu box would not see the new CPU and could have some issues when unpluggin.

Alternatively, if you experience issues with hot-plugging, disable the feature, stop the VM, perform the CPU operation and start it again:

# Disable hot-plug if it does not work for you (only once)
VBoxManage modifyvm "VM name" --cpuhotplug off

VBoxManage controlvm "VM name" acpipowerbutton
VBoxManage modifyvm "VM name" --cpus 2
VBoxManage startvm "VM name" 
# DO STUFF with extra core
VBoxManage controlvm "VM name" acpipowerbutton
VBoxManage modifyvm "VM name" --cpus 1
VBoxManage startvm "VM name" 

I'm curious why you want to script this: is it something you want to do repeatedly? If it's a one-time project, it is fairly easy to do in virtualbox: power down the VM, right click and go into settings -> system -> processor, and move the slider to 2. You will need hardware visualization turned on for your windows host: you need to do that from the BIOS, and the particular menu depends on the machine. For example, the IdeaPad computers have it here: https://forums.lenovo.com/t5/IdeaPad-Y-and-U-series-Laptops/How-to-Enable-Hardware-virtualization-on-IdeaPad-Y510p/ta-p/1394215 . For mine, it was actually under the BIOS -> security menu.

Now within the VM, running 'nproc' as superuser should show "2" instead of "1".

If you want to script this, check out VBoxManage, the command line interface to control virtualbox: https://www.virtualbox.org/manual/ch08.html I have not tried it myself, but it appears like this would be about right for you:

VBoxManage controlvm "my VM" poweroff
VBoxManage modifyvm "my VM" --cpus 2
VBoxManage startvm "my VM"

--cpus : This sets the number of virtual CPUs for the virtual machine (see Section 3.4.2, “"Processor" tab”). If CPU hot-plugging is enabled (see below), this then sets the maximum number of virtual CPUs that can be plugged into the virtual machines.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .