Vagrant: Cannot configure Hyper-V box memory more than 2048mb without setting maxmemory

Created on 30 Oct 2018  ยท  4Comments  ยท  Source: hashicorp/vagrant

Vagrant version

2.2.0

Host operating system

Windows Server 2012 R2 [Version 6.3.9600] (German)

Guest operating system

generic/debian9

Vagrantfile

Vagrant.configure("2") do |config|
  #config.vm.box = "debian/stretch64" # does not support provider hyperv
  config.vm.box = "generic/debian9"
  config.vm.provider "hyperv" do |h|
    h.memory = 4096
    # h.maxmemory = 4096
  end
end

Debug output

https://gist.github.com/vchrizz/8730697b9d4323c5ed4d16a2b2e3e704

Expected behavior

Vagrant machine should start with the defined memory set.

Actual behavior

vagrant up fails with an error about maxmemory setting:

An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: configure_vm.ps1
Error:

Failed to configure memory: Maximum memory value is less than required minimum memory value.

Steps to reproduce

  1. vagrant init
  2. edit Vagrantfile and set memory more than 2048
  3. do NOT set maxmemory (setting this to same amount as memory 'fixes' the issue.
  4. vagrant up

References

  • GH-9477

Most helpful comment

Hi there,

This is occurring because the generic/debian9 box sets the maxmemory option to 2048. Below is the snippet from the Vagrantfile:

  # Adding a second CPU and increasing the RAM to 2048MB will speed
  # things up considerably should you decide to do anythinc with this box.
  config.vm.provider :hyperv do |v, override|
    v.maxmemory = 2048
    v.memory = 2048
    v.cpus = 2
  end

If you want to the VM to have the memory statically allocated to it, you can just set the maxmemory option to nil. If you'd rather allow Hyper-V to dynamically allocate memory to the guest, you can not modify memory and instead just update the maxmemory option to 4096.

Cheers!

All 4 comments

Hi there,

This is occurring because the generic/debian9 box sets the maxmemory option to 2048. Below is the snippet from the Vagrantfile:

  # Adding a second CPU and increasing the RAM to 2048MB will speed
  # things up considerably should you decide to do anythinc with this box.
  config.vm.provider :hyperv do |v, override|
    v.maxmemory = 2048
    v.memory = 2048
    v.cpus = 2
  end

If you want to the VM to have the memory statically allocated to it, you can just set the maxmemory option to nil. If you'd rather allow Hyper-V to dynamically allocate memory to the guest, you can not modify memory and instead just update the maxmemory option to 4096.

Cheers!

Thanks! Didnt notice that.
For Vagrant beginners, where can i find this Vagrantfile from generic/debian9 to know where to debug?

It'll be with the unpacked box, and the path will be dependent on the VAGRANT_HOME setting and the box version. The path will look something like this with default settings:

C:\Users\USERNAME\.vagrant.d\boxes\generic-VAGRANTSLASH-debian9\BOX_VERSION\hyperv\Vagrantfile

Where USERNAME is your username on the host and VERSION is the version of the box you have installed.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RobertSwirsky picture RobertSwirsky  ยท  3Comments

barkingfoodog picture barkingfoodog  ยท  3Comments

rhencke picture rhencke  ยท  3Comments

OtezVikentiy picture OtezVikentiy  ยท  3Comments

DreadPirateShawn picture DreadPirateShawn  ยท  3Comments