virtualbox increase cpu cores script wise

9,229

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" 
Share:
9,229
canoodle
Author by

canoodle

Updated on September 18, 2022

Comments

  • canoodle
    canoodle over 1 year

    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/