如何解决Vagrant与Hyper-V共享文件夹挂载失败问题?
Looks like you're hitting a classic SMB connectivity snag between your Windows Hyper-V host and Ubuntu 16.04 guest with Vagrant. That Host is down error usually boils down to network issues, missing guest dependencies, or security software blocking traffic. Let's walk through the fixes step by step:
1. Install Required Tools on the Ubuntu Guest
First, the error mentions mount.cifs failing—Ubuntu 16.04 doesn't come with the necessary SMB tools pre-installed. You'll need to get cifs-utils:
- If you can still SSH into the guest (use
vagrant ssh, or connect directly via Hyper-V Manager), run:sudo apt-get update && sudo apt-get install -y cifs-utils - After installing, try re-mounting with
sudo mount -aor restart the VM withvagrant reload.
2. Verify SMB Service & Firewall on Windows Host
SMB relies on the Lanman Server service running on your Windows machine, and firewall rules allowing traffic:
- Check if the service is running: Open PowerShell as admin and run:
If it's stopped, start it and set it to auto-start:Get-Service LanmanServerStart-Service LanmanServer Set-Service LanmanServer -StartupType Automatic - Check Windows Firewall: Ensure the File and Printer Sharing (SMB-In) rule is enabled for your active network profile (Public/Private). You can verify this in Windows Defender Firewall > Advanced Settings > Inbound Rules.
3. Fix Vagrant SMB Configuration
Your Vagrantfile might be using auto-detected network settings that aren't reliable. Tweak the synced folder config:
- Specify your Windows host's actual external IP address (find it via
ipconfigin Command Prompt) to avoid auto-detection failures:Vagrant.configure("2") do |config| config.vm.box = "bento/ubuntu-16.04" config.vm.provider "hyperv" config.vm.network "public_network" # Add smb_host with your Windows host IP, and explicit mount options config.vm.synced_folder ".", "/vagrant", type: "smb", smb_host: "192.168.1.100", # Replace with your host's external IP mount_options: ["sec=ntlmssp", "uid=1000", "gid=1000"] config.vm.provider "hyperv" do |h| h.enable_virtualization_extensions = true h.linked_clone = true end end - The
sec=ntlmsspoption replaces the olderntlmthat might not be compatible with Ubuntu 16.04.
4. Double-Check Security Software
You mentioned temporarily closing Avast, but security tools often leave background processes running:
- Fully disable Avast shields until restart (right-click the tray icon > Avast Shields Control > Disable until computer restart).
- Also, check Windows Defender Real-Time Protection—temporarily turn it off to test if it's blocking SMB traffic. If it works, add your VM's IP and the shared folder path to Defender's exclusions.
5. Validate Network Connectivity
Ensure the guest can actually reach the host:
- SSH into the guest and ping your Windows host's external IP. If ping fails, your Hyper-V external switch is misconfigured:
- Open Hyper-V Manager > Virtual Switch Manager, confirm the external switch is bound to your active physical network adapter.
- Make sure the guest and host are on the same subnet (check guest IP with
ip ain Ubuntu).
After trying these steps, run vagrant reload to restart the VM and re-apply the config. That should resolve the SMB mount error.
内容的提问来源于stack exchange,提问作者kvjava1




