This is a guide that describes on how to mount a remote Samba share configured on TrueNAS on to a Linux machine.
Login in your Linux machine. (I am using a Linux Mint 19.3 in this demo. This should technically work on other Debian/Ubuntu based systems as well).
Use the following commands to get your current user’s user ID (UID) and group ID (GID) respectively.
id -u $USER id -G $USER
Create a file /etc/.truenas_creds. This is where you would store the samba credentials.
Replace text in red with the username and password of the remote SMB share which was configured in TrueNas.
cat /etc/.truenas_creds username=enter_username_here password=enter_password_here
Modify the file permissions so that root is the owner and set the file permission to 600.
sudo chown root: /etc/.truenas_creds sudo chmod 600 /etc/.truenas_creds
In your linux machine, create a folder to where you want the contents of the remote samba share to be mounts. For example: create a directory named /mnt/truenas/.
sudo mkdir /mnt/truenas/
-Below is a sample syntax that can be used for populating /etc/fstab.
//ip-of-nas-server/enter-remote-samba-share/location /enter-local-mount/location/here/ cifs credentials=/etc/.truenas_creds,iocharset=utf8,uid=enter_your_uid_here,gid=enter_your_gid_here,noperm 0 0
-Here is what that I added in /etc/fstab.
//192.168.1.12/mnt/truenas /mnt/truenas/ cifs credentials=/etc/.truenas_creds,iocharset=utf8,uid=1000,gid=1000,noperm 0 0
My TrueNAS server’s IP => 192.168.1.12
Remote samba share => /mnt/truenas
Local mount location => /mnt/truenas/
Credentials for samba share => /etc/.truenas_creds
-Once complete, run the following to mount all entries looking at /etc/fstab.
-If there are no errors in the above command, check your local mount path to verify that the mount was successful.
ls -l /mnt/truenas/