Mount Windows Share on Redhat Linux

Problem Description : 

Need to mount a windows drive on Linux

 

 

 Resolution : 

 

Open terminal window on Redhat...

 

Create a mount point on the Server...

 

# mkdir -p /mnt/mount_name

 

Use the mount command as follows...

 

# mount -t cifs -o username=myUserName,password=myPassword //server_name/share_name /mnt/mount_name

 

* -t cifs : File system type to be mounted

* -o : are options passed to mount command, this example passes two options. Username and password that has access to connect to remote windows box

* //server_name/share_name : Windows NT share name

* /mnt/mount_name Linux mount point (to access share after mounting)

 

For example, if you want to mount a Windows share called //bessie/Unix then you need to enter the following:

 

# mkdir -p /mnt/commvault

# mount -t cifs -o username=xxxxxxx,password=xxxxxxx //bessie/Unix /mnt/commvault

 

 

*************************************************

NEED TO TEST THIS FIRST!!!

 

To make mount stay after reboot you must add entry to  /etc/fstab file:

 

//bessie/Unix /mnt/mount_name cifs username=xxxxxxx,password=xxxxxxxx

 

This is not a good idea however: /etc/fstab is readable by everyone and so is your Windows password in it. The way around this is to use a credentials file. This is a file that contains just the username and password.

Using a text editor, create a file for your remote servers logon credential:

gedit ~/.smbcredentials

 

Enter your Windows username and password in the file:

username=msusername

password=mspassword

 

Save the file, exit the editor.

Change the permissions of the file to prevent unwanted access to your credentials:

chmod 600 ~/.smbcredentials

 

Then edit your /etc/fstab file (with root privileges) to add this line (replacing the insecure line in the example above, if you added it):

//bessie/Unix /mnt/mount_name cifs credentials=/dir_location/.smbcredentials

 

Finally, test the fstab entry by issuing: 

 

sudo mount -a

 

This will (re)mount all entries listed in /etc/fstab.

 

If there are no errors, you should test how it works after a reboot. Your remote share should mount automatically.

 

 

 

 

 

 

 Revision Date : 6/11/2013