Link to home
Start Free TrialLog in
Avatar of bcmchong
bcmchongFlag for United States of America

asked on

Cygwin on a Win2003 server mounting to UNC paths

I have a Win2003 Server running Cygwin. How do I configure it such that without any user logging in, I have drive letters auto-magically get mapped to UNC paths (other Windows Servers via  \\servername\share) each time the server gets bounced or reboots? If I'm not mistaken, drive letters are mapped to UNC paths by user, or more accurately when a user logs in. Am I wrong? Sorry, I'm no Windows guru/expert.
Avatar of reb_elmagnifico
reb_elmagnifico

You are right.  Drives are mapped on a user by user basis.  It would be nice if mapping worked as mounting works in Linux.

As far as I know there isn't a way to map a drive before logging in.
Avatar of bcmchong

ASKER

I'd like to ask my question a different way. Like I mentioned, I have Cygwin on a Windows 2003 Server. How do I configure Cygwin such that when the Server is rebooted, Cygwin is able to map a folder, say /foobar1 to a UNC path, say \\ServerName\foobar2? Can I accomplish this with an entry into an fstab file? Does Cygwin even have an fstab file? Thanks.
i don't know if it can use one, but no, cygwin does not come with an fstab or mtab by default

why do you need these drives mapped in the first place? is this for some sort of scheduled script? why not just have said script do the mounting?
Can these scripts you mention automatically mount if the machine were to be rebooted? If so, that would be great. do you have a sample of what it might look like? Please remember for security reasons, I don't want to have to log in to the server for those UNC paths to be mounted.

Thanks.
you didn't answer the question of *WHY* you need network paths auto-mounted when the system reboots
there is an application that is a port from UNIX and it is running on the Windows Server within the Cygwin environment. This application doesn't seem to care for UNC paths. So I was going to do a mount in Cygwin and enter the mount point in to the application to see if that would work.
SOLUTION
Avatar of reb_elmagnifico
reb_elmagnifico

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
this service that is running in cygwin, i assume it is running with cygrunsrv?

it would be possible to create a script that tested if the UNC path was mounted, and mount it if it was not, and then schedule it to run every 5 minutes. however if the service is starting when the system boots, that means it would probably fail to start because the path would not be mounted for several minutes after the system boots.

perhaps check out /usr/doc/Cygwin/sysvinit.README and /usr/doc/Cygwin/initscripts.README to see if you can create a startup script that would mount the directory for you.
netmunky: Thanks for the pointers. I'll check out those READMEs and see what I can gleam. Thanks a bunch.
Can u use "net use  p:   \\ServerName\foobar2  /user:mountuser password"?
If yes, u can access this p: as /cygdrive/p

U can apply it in DOS batch or cygwin bash scipt
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes - running some experiments, using the cygwin cron service to run a script referencing a mapped drive X: , as ntemunky says, it does not remember the mapped drive for the service user.
By using aavictor's suggestion, and putting "net use X: \\\\server\\share" as the first line of the script, it happily "saw" the remote folder every time.
One can either ignore the "already mapped" error on subsequent calls, or put a check in  front of it for existence of a known file in the remote folder....
 
 
Thank nrbreen.
Avatar of powercram
bcmchong,

Following the directions at http://cygwin.com/cygwin-ug-net/using.html#mount-table, I was able to setup a system-wide folder-to-UNC mapping.  Your passwd file would just reference the newly created share name - in this example it is "MyShare."

This is the registry entry:

Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/MyShare]
"flags"=dword:0000000a
"native"="\\\\<server name>\\MyShare"

Open in new window