Jacob Davis-Hansson
Jacob Davis-Hansson

Reputation: 2663

Mounting network drive works in DOS, but breaks in Cygwin. Why?

I'm using VirtualBox to set up a windows 2008 server. I'd like to add a shared folder, but am running into problems.

Running this in DOS works:

net use t: \\vboxsrv\v-root

But in Cygwin:

$ net use t: "\\vboxsrv\v-root"
System error 53 has occurred.

The network path was not found.

I've also tried these:

$ net use t: \\vboxsrv\v-root
$ net use t: \\\\vboxsrv\\v-root

And I've tried creating a bat script containing the working DOS command, and executing it from cygwin. They all fail with the same error.

I need to do it through Cygwin, because I access the system via SSH, and land in a Cygwin environment. If there is any way to "break out" of cygwin temporarily from within Cygwin, that might be a way to go..

What am I missing?

Upvotes: 1

Views: 4088

Answers (4)

jejese
jejese

Reputation: 111

Running windows commands directly or through CMD from bash or other cygwin or MSYS unix-style shell can be tedious to understand and predict, when it tries to convert the paths between windows native spelling and the converted spellings. I've had the most difficulty with getting "DOS style" options through the command line processing, because starting with a forwards slash, they look like unix style paths. There are other nuances that may be harder to remember for otthers.

For me, I've found it simplest to write out any windows command as a string between single quotes, to send that to CMD as standard input using "<<<". As a single string that does not begin with a drive letter or a slash, there will be no cygwin interpretation, and then CMD will interpret the command. While there probably is another way to make the sh-style shell interpret the "net" command by itself with correctly spelled arguments and no "cmd", I still think this is easier to understand.

e.g.

cmd <<<'net use t: \\vboxsrv\v-root'

You could also make an reusable bash function:

function dos() {
    cmd <<<"$@"
    echo "" # (because the last line ending tends to fall off)
}
dos 'net use t: \\vboxsrv\v_root'

Note, the bash function's use of "$@" accepts multiple arguments, but I don't understand why dos dir /s works any more DOS-ily than dir /s (cannot access '/s').

When I tested the "net use" command with one of my own UNC paths, it still didn't work for me, for some secondary reason I do not understand, though. Maybe your situation would work out using just subst instead. Try this:

cmd <<<'subst T \\vboxsrv\v_root'

There will be another problem, next, so you might want to try this, too:

mount -o binary,acl,posix=0,notexec,user T: /t

Usually, an ls -l directory listing under the new /t/ would be very slow for large numbers of files. It reads the first bytes of every file to check for #!, and shows whether files are executable based on that. That is fine on a local drive, but the delays it introduces over network drives are not practical, in my experience. That's also been useful for hybrid situations like OneDrive, to prevent unnecessary syncing.

Upvotes: 0

user921958
user921958

Reputation: 1

For this error,

!) Give full rights to Shared folder at Host side using "sudo chmod 777 -R /home/username/Shared" (Shared is a folder name which we have to be shared.)

!!) Open Guest in Virtualbox, before accessing shared folder.: "Install Guest Additions" From Menu

!!!) Click START, Right click on Computer , Select "Map Network Drive"

!V) In that select any drive and bellow that type folder "\Yourhostipaddress\Shared". Bellow that select "connect with credential" (Yourhostipaddress is a HOST IP ADDRESS and Shared is Shared folder name at host side. )

V) Click On connect button. It will ask you host username and password.

 Put **USERNAME** Properly like "**XXXXXXXX-PC**".

V!) It will map with shared drive successfully !!!!!!!!!!!!!!!!

If still getting error, Put comments bellow this.

Upvotes: 0

Jeroen Bouman
Jeroen Bouman

Reputation: 46

Create a folder somewhere, like:

$> mkdir -p /mnt/t

Now you can us the mount program in cygwin, like so:

$> mount \\vboxsrv\v-root /mnt/t

Easy as 1,2,3 :-)

Upvotes: 3

Matt Ball
Matt Ball

Reputation: 359976

The Windows root path is typically found somehwere under /cygdrive/. Try something like

$ net use t: /cygdrive/c/vboxsrv/v-root

Upvotes: 0

Related Questions