1 | <?xml version='1.0' encoding='UTF-8'?>
|
---|
2 | <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
|
---|
3 | <topic xml:lang="en-us" id="cpuhotplug">
|
---|
4 | <title>CPU Hot-Plugging</title>
|
---|
5 |
|
---|
6 | <body>
|
---|
7 | <p>With virtual machines running modern server operating systems, <ph
|
---|
8 | conkeyref="vbox-conkeyref-phrases/product-name"/> supports CPU hot-plugging. </p>
|
---|
9 | <p>On a physical computer CPU hot-plugging would mean that a CPU can be added or removed while the machine is
|
---|
10 | running. <ph conkeyref="vbox-conkeyref-phrases/product-name"/> supports adding and removing of virtual CPUs while
|
---|
11 | a virtual machine is running. </p>
|
---|
12 | <p>CPU hot-plugging works only with guest operating systems that support the feature. So far this applies only to
|
---|
13 | Linux and Windows Server. Windows supports only hot-add, while Linux supports hot-add and hot-remove. To use this
|
---|
14 | feature with more than 8 CPUs, a 64-bit Linux guest is required. </p>
|
---|
15 | <p>CPU hot-plugging is done using the <userinput>VBoxManage</userinput> command-line interface. First, hot-plugging
|
---|
16 | needs to be enabled for a virtual machine: </p>
|
---|
17 | <pre xml:space="preserve">$ VBoxManage modifyvm <varname>VM-name</varname> --cpu-hotplug on</pre>
|
---|
18 | <p>The <codeph>--cpus</codeph> option is used to specify the maximum number of CPUs that the virtual machine can
|
---|
19 | have: </p>
|
---|
20 | <pre xml:space="preserve">$ VBoxManage modifyvm <varname>VM-name</varname> --cpus 8</pre>
|
---|
21 | <p>When the VM is off, you can then add and remove virtual CPUs with the <userinput>VBoxManage modifyvm
|
---|
22 | --plug-cpu</userinput> and <userinput>VBoxManage modifyvm --unplug-cpu</userinput> commands, which take the
|
---|
23 | number of the virtual CPU as a parameter, as follows: </p>
|
---|
24 | <pre xml:space="preserve">$ VBoxManage modifyvm <varname>VM-name</varname> --plug-cpu 3
|
---|
25 | $ VBoxManage modifyvm <varname>VM-name</varname> --unplug-cpu 3</pre>
|
---|
26 | <p>Note that CPU 0 can never be removed. </p>
|
---|
27 | <p>While the VM is running, CPUs can be added and removed with the <userinput>VBoxManage controlvm
|
---|
28 | plugcpu</userinput> and <userinput>VBoxManage controlvm unplugcpu</userinput> commands instead, as follows: </p>
|
---|
29 | <pre xml:space="preserve">$ VBoxManage controlvm <varname>VM-name</varname> plugcpu 3
|
---|
30 | $ VBoxManage controlvm <varname>VM-name</varname> unplugcpu 3</pre>
|
---|
31 | <p>See <xref href="vboxmanage-modifyvm.dita">VBoxManage modifyvm</xref> and <xref href="vboxmanage-controlvm.dita"
|
---|
32 | >VBoxManage controlvm</xref> for details. </p>
|
---|
33 | <p>With Linux guests, the following applies: </p>
|
---|
34 | <p>To prevent ejection while the CPU is still used it has to be ejected from within the guest before. The Linux
|
---|
35 | Guest Additions contain a service which receives hot-remove events and ejects the CPU. Also, after a CPU is added
|
---|
36 | to the VM it is not automatically used by Linux. The Linux Guest Additions service will take care of that if
|
---|
37 | installed. If not a CPU can be started with the following command: </p>
|
---|
38 | <pre xml:space="preserve">$ echo 1 > /sys/devices/system/cpu/cpu<id>/online</pre>
|
---|
39 | </body>
|
---|
40 |
|
---|
41 | </topic>
|
---|