vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

winRM Samba share fails: "Mount point already exists and is not a symbolic link"

Open sjroman opened this issue 6 years ago • 4 comments

Vagrant version

2.2.1

Host operating system

Windows 10 Pro Version 10.0.17134 Build 17134

Guest operating system

Windows 10 Pro Version 10.0.10586 Build 10586

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.guest = :windows
  config.vm.communicator = "winrm"
  config.vm.boot_timeout = 120
  config.vm.graceful_halt_timeout = 120
  config.vm.network :forwarded_port, guest: 3389, host: 3389
  config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
  config.vm.network :forwarded_port, guest: 1521, host: 5555

  config.vm.synced_folder "./test", "/test ", type: "smb"
    config.vm.provider "virtualbox" do |vb|
     vb.gui = true
     vb.default_nic_type = '82540EM'
     vb.memory = "4096"
    end
end

Debug output

https://gist.github.com/sjroman/d584d01ec07b17869cee8bf6e743c962

Expected behavior

Samba share mounts successfully and two-way directory sync is established

Actual behavior

Guest share folder is created if it didn't already exist but sync is not established

Steps to reproduce

  1. Install Vagrant 2.2.1
  2. Import Windows 10 Pro box and create with above Vagrantfile
  3. vagrant up

I can't provide the box unfortunately due to licensing. It's a plain Windows 10 Pro box with some fairly standard Oracle software.

References

  • GH-4593

sjroman avatar Nov 21 '18 20:11 sjroman

I have the same issue also

Vagrant version

2.2.4

Host operating system

image

Guest operating system

Windows Server 2012R2 Powershell V5.1

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.require_version ">= 2.2.1"

Vagrant.configure("2") do |config|
    config.vm.box = "windows_2012_r2"
    config.vm.communicator = "winrm"

    config.vm.guest = :windows
    config.windows.halt_timeout = 15
    config.vm.synced_folder "../../Data", "/Data"
    config.vm.synced_folder ".", "/vagrant", disabled: true

    config.vm.network :forwarded_port, guest: 3389, host: 3390, id: "rdp", auto_correct: true

    config.vm.provider :virtualbox do |v, override|
        v.name = "galaxy"
        end
end

Debug output

https://gist.github.com/Vagrantin/2f8740a536da42c22beaacf933ec2f54

Expected behavior

Guest sync folder to be created, and startup to succeed

Actual behavior

Sync folder created but startup get stuck and I got this error message:

An error occurred executing a remote WinRM command.

Shell: Powershell
Command: function Test-ReparsePoint([string]$path) {
  $file = Get-Item $path -Force -ea 0
  return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}

$MountPoint = [System.IO.Path]::GetFullPath("/Data")
$ShareName = "Data"
$VmProviderUncPath = "\\vboxsvr\Data"

# https://github.com/BIAINC/vagrant-windows/issues/4
# Not sure why this works, but it does.

& net use $ShareName 2>&1 | Out-Null

Write-Debug "Attempting to mount $ShareName to $MountPoint"
if( (Test-Path "$MountPoint") -and (Test-ReparsePoint "$MountPoint") )
{
  Write-Debug "Junction already exists, so I will delete it"
  # Powershell refuses to delete junctions, oh well use cmd
  cmd.exe /c rd "$MountPoint"

  if ( $LASTEXITCODE -ne 0 )
  {
    Write-Error "Failed to delete symbolic link at $MountPoint"
    exit 1
  }

}
elseif(Test-Path $MountPoint)
{
  Write-Error "Mount point already exists and is not a symbolic link"
  exit 1
}

$BaseDirectory = [System.IO.Path]::GetDirectoryName($MountPoint)

if (-not (Test-Path $BaseDirectory))
{
  Write-Debug "Creating parent directory for mount point $BaseDirectory"
  New-Item $BaseDirectory -Type Directory -Force | Out-Null
}

cmd.exe /c mklink /D "$MountPoint" "$VmProviderUncPath" | out-null

if ( $LASTEXITCODE -ne 0 )
{
  exit 1
}

Steps to reproduce

  1. Install Vagrant 2.2.4
  2. Import Windows 10 Pro box and create with above Vagrantfile
  3. vagrant up

Vagrantin avatar May 11 '19 11:05 Vagrantin

I am having the same issue.

jacquecosta avatar Oct 28 '19 19:10 jacquecosta

When creating the new guest, does the synced folder path on the guest already exist (C:/test)? If so, is this path empty when the guest is created?

chrisroberts avatar Jul 17 '20 20:07 chrisroberts

I am facing this error also has anyone resolved it yet ?

My vagrantfile setting cfg.vm.synced_folder "/Users/kianting/code/", "Z:", automount: true, create: true

The error message `Bringing machine '1idm' up with 'virtualbox' provider... ==> 1idm: Clearing any previously set forwarded ports... ==> 1idm: Clearing any previously set network interfaces... ==> 1idm: Preparing network interfaces based on configuration... 1idm: Adapter 1: nat 1idm: Adapter 2: bridged ==> 1idm: Forwarding ports... 1idm: 5985 (guest) => 55985 (host) (adapter 1) 1idm: 5986 (guest) => 55986 (host) (adapter 1) 1idm: 22 (guest) => 2222 (host) (adapter 1) ==> 1idm: Running 'pre-boot' VM customizations... ==> 1idm: Booting VM... ==> 1idm: Waiting for machine to boot. This may take a few minutes... 1idm: WinRM address: 127.0.0.1:55985 1idm: WinRM username: Administrator 1idm: WinRM execution_time_limit: PT2H 1idm: WinRM transport: plaintext ==> 1idm: Machine booted and ready! [1idm] GuestAdditions 7.0.12 running --- OK. ==> 1idm: Checking for guest additions in VM... ==> 1idm: Setting hostname... ==> 1idm: Configuring and enabling network interfaces... ==> 1idm: Mounting shared folders... 1idm: Z: => /Users/kianting/code The following WinRM command responded with a non-zero exit status. Vagrant assumes that this means the command failed!

function Test-ReparsePoint([string]$path) { $file = Get-Item $path -Force -ea 0 return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint) }

$MountPoint = [System.IO.Path]::GetFullPath("Z:") $ShareName = "Z:" $VmProviderUncPath = "\vboxsvr\Z:"

https://github.com/BIAINC/vagrant-windows/issues/4

Not sure why this works, but it does.

& net use $ShareName 2>&1 | Out-Null

Write-Debug "Attempting to mount $ShareName to $MountPoint" if( (Test-Path "$MountPoint") -and (Test-ReparsePoint "$MountPoint") ) { Write-Debug "Junction already exists, so I will delete it"

Powershell refuses to delete junctions, oh well use cmd

cmd.exe /c rd "$MountPoint"

if ( $LASTEXITCODE -ne 0 ) { Write-Error "Failed to delete symbolic link at $MountPoint" exit 1 }

} elseif(Test-Path $MountPoint) { Write-Error "Mount point already exists and is not a symbolic link" exit 1 }

$BaseDirectory = [System.IO.Path]::GetDirectoryName($MountPoint)

if (-not (Test-Path $BaseDirectory)) { Write-Debug "Creating parent directory for mount point $BaseDirectory" New-Item $BaseDirectory -Type Directory -Force | Out-Null }

cmd.exe /c mklink /D "$MountPoint" "$VmProviderUncPath" | out-null

if ( $LASTEXITCODE -ne 0 ) { exit 1 }

Stdout from the command:

Stderr from the command:

function Test-ReparsePoint([string]$path) { : Mount point already exists and is not a symbolic link + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException`

kianting avatar Jan 18 '24 09:01 kianting