Connecting Ubuntu Server to a Windows share on SMB

I had several directories of files on a NAS host that shared the directories using a ‘windows’ style SMB share. I wanted an Ubuntu server to mount these shares with read/write access. I want the mount to be done automatically at bootup.

The NAS is already sharing these folders and access is protected with an ID/PW.

Load the needed prerequisites on the Ubuntu host.

apt-get install smbfs

We need to create an id/pw file that we can use when mounting the shares. It is important to note that the password file cannot have any extra lines or characters. Create a file in root’s directory and call it .smbcredentials. It should look like this:

Username=user
Password=password

Edit the /etc/fstab file and add the following:

//nashost/media /mnt/media cifs credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=nzbd,guid=root 0 0
//nashost/share /mnt/share cifs credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=nzbd,guid=root 0 0

Lastly, make sure that /mnt/media and /mnt/share exist. If not, create them.

mkdir /mnt/media
mkdir /mnt/share

Load the mounts with

mount -a

With that, the 2 shares should mount and be available after a server reboot.

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
24 − 18 =