Using Trellis with Hyper-V

Hi all,

I’ve been developing a site using wsl, and performance using virtualbox was bad, so I started using hyper-v (thanks to kalenjohnson’s pull!). I wanted to share my experience here so if someone wants to try the same they can find some information.

Some things might dependent on what Windows version you use and other settings. I used Windows 10 Build 17763, with firewall disabled.

Not sure if it makes a difference, but I set my vagrant_mount_type to ‘smb’.

The first problem I ran into was the hostmanager setting wrong ips. I made the following change to the vagrantfile starting at line 53:

if Vagrant.has_plugin?('vagrant-hostmanager') && !trellis_config.multisite_subdomains?
    redirects = trellis_config.site_hosts_redirects

    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true
    config.hostmanager.aliases = hostnames + redirects

    config.vm.provider 'hyperv' do
      config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
        # Hyper V

The next problem I ran into was that the machine reported it could not authenticate or reported cifs unknown mount option dmode* for mounting the SMB shares. I changed the sec option in /lib/trellis/vagrant.rb line 56 to use ntlmssp. The result:

def mount_options(mount_type, dmode:, fmode:)
  if mount_type == 'smb'
    ["vers=3.02", "mfsymlinks", "dir_mode=0#{dmode}", "file_mode=0#{fmode}", "sec=ntlmssp"]
    ["dmode=#{dmode}", "fmode=#{fmode}"]

* if this happens, make sure your /srv/www is owned by vagrant and not root! Removing the whole www directory and re-provisioning also fixes it.

Other tips:

  • Use vargant.local.yml to store your vagrant_smb_username and vagrant_smb_password. This file is git excluded by default.
  • Use an external switch for better smb performance

Thanks for sharing :heart:

Are these changes that could (or should) be made upstream in Trellis itself?


Thanks for writing this up! Yes I did get some code for Hyper-V into Trellis but haven’t gotten back to update the docs for it.

You do need to use SMB as the disk mount and have a username and password.

I believe the unknown IP issue is known: , I think what essentially happens is something like hostmanager won’t be able to add the IP for you, so it might be a manual process, I honestly don’t remember exactly how it works though.

Definitely if you have some code or documentation you would like to add please make a PR!


Hi both! I’m no vagrant and/or hyper-v expert, i just recently stared using hyper-v.

For hostmanager: The first code in my start posts always sets the ip correctly, after the vm has booted. If I dont use this code, it will set the default ip ( in the host file. I found out that this code is similar to setting the vagrant_ip to dhcp, but using the fist ip, instead of the second, that doesn’t exists. I’ll open an issue for that.

Also, somethig to note. Hyper-v has serious limitations in regards to networking. And if you’re switching between wifi networks or (network)adapters, it can be really unpredictable, as you need to manualy change the virtual switch each time.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.