Linux: Permanent CIFS/SMB mount
I needed to permanently mount a directory on a Windows server that had spaces in the path. I also wanted to use a credentials file so that the remote server username and password would not be in the world readable fstab file. The following was cobbled together from:
Mount samba shares with utf8 encoding using cifs
and:
Mount password protected network folders
Mount samba shares with utf8 encoding using cifs
and:
Mount password protected network folders
- Create a credentials file (as root) containing the username and password and restrict it's ability to be read by other users (/etc/fstab is world readable).
- vi /root/.smbcredentials
username=someusername
password=somepassword - Save and exit the file. Change the file permissions to only be readable by root.
chmod 600 /root/.smbcredentials - Update the fstab file
- Add the following line to /etc/fstab (spaces are replaced with \040 or the mount will fail)
//ip address/c$/Program\040Files/Microsoft\040SQL\040Server/ /var/backups/Server cifs credentials=/root/.smbcredentials,iocharset=utf8,sec=ntlm 0 0 - Exit and save the file
- Test the fstab entry with:
sudo mount -a
Comments