Goglides Dev 🌱

Goglides Dev 🌱 is a community of amazing users

Shaping the future of IT, one connection at a time.

Create account Log in
Balkrishna Pandey
Balkrishna Pandey

Posted on

How to adjust memory allocation for virtual machines using Virsh

[root@localhost ~]# virsh setmem hubztp-master-1 45G --config
error: invalid argument: cannot set memory higher than max memory
Enter fullscreen mode Exit fullscreen mode

The error message "invalid argument: cannot set memory higher than max memory" indicates that the memory allocation you are trying to set for your virtual machine is higher than its maximum memory limit. This means you need to adjust the maximum memory limit before setting a higher memory allocation.

To do this, you can use the Virsh command setmaxmem to set your virtual machine's maximum memory limit to a higher value. Once you have set the maximum memory limit, you can use the setmem command to set the memory allocation to the desired value.
Here are the steps to follow:

  • Step 1: Check Current Maximum Memory Limit To check the current maximum memory limit for your virtual machine named "hubztp-master-1," enter the following command:
virsh dominfo hubztp-master-1 | grep "Max memory"
Enter fullscreen mode Exit fullscreen mode

This will display the maximum memory allocation for your virtual machine. Make a note of this value.

  • Step 2: Set Maximum Memory Limit To set the maximum memory limit for your virtual machine to 45G, enter the following command:
virsh setmaxmem hubztp-master-1 45G --config
Enter fullscreen mode Exit fullscreen mode

This will set the maximum memory limit for your virtual machine to 45G.

  • Step 3: Check Maximum Memory Limit To check the maximum memory limit for your virtual machine, enter the following command:
virsh dominfo hubztp-master-1 | grep "Max memory"
Enter fullscreen mode Exit fullscreen mode
  • Step 4: Set Memory Allocation To set the memory allocation for your virtual machine to 45G, enter the following command:
virsh setmem hubztp-master-1 45G --config
Enter fullscreen mode Exit fullscreen mode

This will allocate 45G of memory to your virtual machine.

  • Step 5: Stop and Start the Virtual Machine To apply the memory allocation changes, you need to stop and start your virtual machine. To stop the virtual machine, enter the following command:
virsh shutdown hubztp-master-1
Enter fullscreen mode Exit fullscreen mode

This will stop the virtual machine named hubztp-master-1. To start the virtual machine, enter the following command:

virsh start hubztp-master-1
Enter fullscreen mode Exit fullscreen mode

This will start the virtual machine with the updated memory allocation.

Discussion (0)