Friday, January 9, 2015

How to Map a Windows Network Drive in Linux

I use Linux at work. I'm the only one. I need to access docs on a shared network drive. Everyone else simply drops the path beginning with \\ into their windows explorer at it works. What about me?

One thing Windows does is it auto-logs in since you had to use your ldap login to get on the work machine in the first place. So, first thing to overcome is credentials.


1. I create a credentials file at my home directory, so /home/username/.ldapcredentials

In it, I have:
username=myWinUsername
password=thisismysecret

2. Now I go create the directory where I want to mount the mapped drive. I like to put it under /mnt.

$ cd /mnt
$ sudo mkdir zdrive

3. Now the confusing stuff. I go into /etc/fstab and create an entry. I knew why once, not anymore.

Let's say the path I'm given for a file looks like this: \\zapo1\liciousVol2\teams\documents\how-we-work.xls

I will type an entry at the bottom of fstab that looks like this (remember to use sudo to open the file so it's not read only):

//zapo1/liciousVol2 /mnt/zdrive cifs noauto,credentials=/home/username/.ldapcredentials,iocharset=utf8,file_mode=0666,dir_mode=0777 0 0

You can go look up what all those mean as I don't really remember. I'm just making note of this here in case I need to use it again for quick reference.

4. Now mount the drive
$ sudo mount zdrive

5. Navigate to the drive
$ cd /mnt/zdrive
$ ls

You should now see the files and directories in the drive and be able to navigate it.