Overview

Skill Level: Beginner

basic linux knowledge

In this post i will explore the different methods to increase the memory size for the virtual machine

Ingredients

Guest Vitual machine should be up and running

 

Step-by-step

  1. Method 1:

    To add additional memory to your VM, you should do the following:

     

    • Shutdown your VM
    • Edit the VM file and increase the value of maximum memory allocated to this VM
    • Restart the VM
  2. First, shutdown the VM using virsh shutdown as shown below

    [root@kvm_iic ~]# virsh shutdown POWERVC
    Domain POWERVC is being shutdown

  3. Next, edit the VM using virsh edit

    [root@kvm_iic ~]# virsh edit POWERVC

    Look for the below line and change the value for memory to the following. In my example, earlier it was 2097152:

    <memory unit=’KiB’>2097152</memory>

    <currentMemory unit=’KiB’>2097152</currentMemory>

    Edit the value 2097152 as 4194304

    Now it should be like

    <memory unit=’KiB’>4194304</memory>

    <currentMemory unit=’KiB’>4194304</currentMemory>

    [root@kvm_iic ~]# virsh edit POWERVC
    Domain POWERVC XML configuration edited.

     

     

    Note: After making the change, save and exit

  4. Create the xml file

    [root@kvm_iic ~]# virsh create /etc/libvirt/qemu/POWERVC.xml
    Domain POWERVC created from /etc/libvirt/qemu/POWERVC.xml

  5. View the available Memory for this domain

    [root@kvm_iic ~]# virsh dominfo POWERVC | grep memory
    Max memory: 4194304 KiB
    Used memory: 0 KiB

  6. Start virtual machine

    [root@kvm_iic ~]# virsh start POWERVC

    Connect to you virtual machine and verify the changes

  7. Method 2:

    Set the memory for this domain to 4GB on the fly using virsh setmem as shown below

    [root@kvm_iic ~]#virsh setmaxmem POWERVC 4194304 –config
    [root@kvm_iic ~]#virsh setmem POWERVC 4194304 –config

    Verify using virsh dominfo command

    [root@kvm_iic ~]# virsh dominfo POWERVC | grep memory
    Max memory: 4194304 KiB
    Used memory: 0 KiB

    Now, you have allocated 4GB of memory for this domain without Powering off your guest VM

  8. Method 3:

    [root@kvm_iic ~]#virsh edit POWERVC

    Look for the below line and change the value for memory to the following. In my example, earlier it was 2097152:

    <memory unit=’KiB’>2097152</memory>

    <currentMemory unit=’KiB’>2097152</currentMemory>

    Edit the value 2097152 as 4194304

    Now it should be like

    <memory unit=’KiB’>4194304</memory>

    <currentMemory unit=’KiB’>4194304</currentMemory>

     

     

    Note: After making the change, save and exit

    [root@kvm_iic ~]#virsh define /etc/libvirt/qemu/POWERVC .xml
    Domain POWERVC XML configuration defined

    Now, you have allocated 4GB of memory for the domain without Powering off your guest VM

    [root@kvm_iic ~]# virsh dominfo POWERVC | grep memory
    Max memory: 4194304 KiB
    Used memory: 0 KiB

     

    You have successfully added the additional memory to the existing guest VM.

Join The Discussion