Thursday, March 5, 2009

How to mount a network drive (Samba share) on Linux

Make sure 'smbfs' package is installed.

Mount Manually


# mkdir -p /mnt/win
# mount -t cifs -o username=winntuser,password=mypassword //windowsserver/sharename /mnt/win
# cd /mnt/win
# ls -l


Mount at every system start

Edit the file '/etc/fstab'

# vi /etc/fstab

Append following line in a single line

//windowserver/share /mnt/win cifs credentials=/etc/.sambapasswords,iocharset=utf8,_netdev 0 0

Next, create the password file

# vi /etc/.sambapasswords

and add following content

username = winntuser
password = mypassword


Now, make sure only root can access your file

# chown 0.0 /etc/.sambapasswords
# chmod 600 /etc/.sambapasswords




No comments: