How can I Change amount of Ram and CPU cores for a virtual machine in KVM that is already created? Thanks
5 Answers
For offline configuration:
To increase the number of CPUs:
virsh setvcpus <vm_name> <vcpu_count> --config
If you get an error that you exceeded the maximum number, first do:
virsh setvcpus <vm_name> <vcpu_count> --config --maximum
Then repeat the above:
virsh setvcpus <vm_name> <vcpu_count> --config
To increase the memory size:
virsh setmaxmem <vm_name> <memsize> --config
virsh setmem <vm_name> <memsize> --config
For online configuration:
You can set the vCPU and memory while the VM is running with --current instead of --config, but the new numbers has to be within the maximum values already set. You can not set these maximum numbers while the VM is running. You will have to shutdown the VM with virsh shutdown <vm_name>, use the above command and start back the VM with virsh start <vm_name>.
- 521
You can edit its XML from command-line with:
virsh edit name_vhost
Then, you only have to search the <memory> tag and modify it
Keep in mind that the memory allocation is in kilobytes, so to allocate 512MB of memory, use 512 * 1024, or 524288.
- 64,083
- 302
You can edit the VM settings in virt-manager or in cli by changing the XML in virsh edit VMNAME
- 19,257
This is the exact way to change RAM and CPU cores through the Virtual Machine Manager GUI app (virt-manager):
- In Virtual Machine Manager, double-click your VM.
- A new window appears. On the top ribbon with the icons, select "Show virtual hardware details" (it is the second icon, picture here). This is the place to edit the specifications of your VM.
- 11
To increase the maximum amount of memory that can be allocated to the VM you have to increase the maximum memory limit, power off the VM, increase the memory allocated, the start the VM. There's a step-by-step guide here:
http://earlruby.org/2014/05/increase-a-vms-available-memory-with-virsh/
To get more VCPUs you have to edit the virsh XML file and restart the VM. There's a step-by-step guide to do this here:
http://earlruby.org/2014/05/increase-a-vms-vcpu-count-with-virsh/
- 429
- 4
- 6