A collection of computer systems and programming tips that you may find useful.
 
Brought to you by Craic Computing LLC, a bioinformatics consulting company.

Tuesday, November 13, 2018

Sharing a folder on a Synology NAS with MacOS and Ubuntu linux using CIFS / SMB

I have a Synology DS418 Network Attached Storage (NAS) system.

I wanted to create a Shared Folder on the NAS that I could access from Mac OS (Mojave 10.14) and a Linux box running Ubuntu 16.04.

MacOS uses SMB to share folders and so I decided to use that on the Linux box.

There are 3 parts to this process:

#1 Set up the folder on the NAS.

In Synology File Station, create the folder (SMBtest is the name used here). Under the Permissions Tab I gave my user (jones) full control by selecting 'Administration' and 'Change Permissions' and 'Take Ownership'

I think that is all that is needed on the NAS.

#2 on the Mac

Under the Finder -> 'Go' -> 'Connect to Server'
In my case the address to use was 'smb://craic-nas-1'
Connect as Registered User on the NAS and then select the volume 'SMBtest'

I then had access to that volume in the Finder or at /Volumes/SMBtest on the command line

#3 on the Linux box

Ubuntu Linux uses the CIFS "common internet file system" protocol to communicate with SMB servers.

I had to install the CIFS software

sudo apt-get install cifs-utils

and I created a credentials file with my NAS username and password.

emacs ~/.smbcredentials

username=jones
password=<mypassword>

chmod 600 ~/.smbcredentials

I created a mount point on the Linux box and made myself the owner

mkdir /mnt/
mkdir /mnt/jones
sudo chown jones.jones /mnt/jones

To mount that shared folder

sudo mount -t cifs -o credentials=~/.smbcredentials,uid=1000,gid=1000,iocharset=utf8 //craic-nas-1/SMBtest /mnt/jones/SMBtest

My UID on the linux box is 1000 - the uid and gid options means that the mounted directory is owned by me on the linux box - otherwise there are all sorts of permission issues.

The iocharset=utf8 is important. Without it, if I edited a file on Linux then there would be strange characters when I looked at it on the Mac side.

With that mount command I can create, edit and run scripts on either MacOS or Linux

To unmount the share

sudo umount /mnt/jones/SMBtest

To mount the share automatically I added this to /etc/fstab

//craic-nas-1/SMBtest /mnt/jones/SMBtest cifs credentials=/home/jones/.smbcredentials,uid=1000,iocharset=utf8 0 0

To test that works

sudo mount -a











No comments:

Archive of Tips