Skip to main content

Mount an SMB share.

You nee the helper program installed for either the nfs or cifs file system. For nfs based file system, following utility is required

sudo apt-get install nfs-common

To mount a Cifs file system, install the following utility

sudo apt install cifs-utils

Then mkdir /mnt/folder and :

sudo mount -t cifs //machineNameOrIPadress/folder /mnt/folder -o username=myusername,password=mypassword

You might want to add puid:pgid to make it writable, eg: 998:100

sudo mount -t cifs //machineNameOrIPadress/folder /mnt/folder -o username=myusername,password=mypassword,uid=998,gid=100

Example, where Video is the SMB share physically located at /srv/devdiskbyuuid.../Video

sudo mount -t cifs //orbiter/Video/ /mnt/OrbiterVideo -o username=root,password=omgstrongpassword,uid=998,gid=100


To unmount an SMB share, you can use the umount command followed by the mount point directory. Here's an example:

sudo umount /mnt/folder

Edit fstab to automounnt after a reboot.
Make sure to create a directory for the mountpoint on the target server.

nano /etc/fstab


Add this to fstab - hardcoded credentials option.

//[IPADDRESS]/[SHARENAME] /mnt/[SHARENAME]/ cifs username=[SMBUSER],password=[SMB PASSWORD],iocharset=utf8,noperm,uid=1000,gid=1000 0 0

i.e:

//orbiter/Video /mnt/OrbiterVideo/ cifs username=root,password=password,iocharset=utf8,noperm,uid=998,gid=100 0 0

 

To unmount an SMB share, you can use the umount command followed by the mount point directory. Here's an example:

sudo umount /mnt/folder

I have not done it yet, so I cannot give you a walkthrough, but you should visit the *arr wiki and Ibracorp's site/yt content for ideas and instructions. If you are not using any Windows machines you will probably be better served with NFS protocol for shares, but if you intend to share the folders with Windows machines too, then CIFS/Samba might be a better solution.

You should read about hard links, but you should also read why some suggest avoiding the use of hard links and make your own decision if you wish to do it. Basically, a hard link makes a pointer to a file on the level of a file system. You can have multiple pointers to the same file from various folders without having spent any additional space. It is as if the file was mounted in different folders. The alternative to a hard link is a soft link that functions more like a shortcut, so if you change the location of the file or its name it will get defunct.

To permanently add bind mounts there is an option to add them to fstab list. Because mounts added to the system get unmounted on system reset, so to have them automount you have to add them to the list. The other thing, there is an option for mount to add a credentials file for mounts and to reference the file in the mount command instead of having to write the credentials manually every time you mount some folder.


Make sure to create a directory for the mountpoint on the target server.
mkdir /mnt/[SHARENAME]

Add this to fstab - hardcoded credentials option.

//[IPADDRESS]/[SHARENAME] /mnt/[SHARENAME]/ cifs username=[SMBUSER],password=[SMB PASSWORD],iocharset=utf8,noperm,uid=1000,gid=1000 0 0

OR

//[IPADDRESS]/[SHARENAME] /mnt/[SHARENAME] cifs credentials=/home/[YOURUSER]/.smbcredentials,iocharset=utf8,noperm,uid=1000,gid=1000 0 0

Then store your credentials in home/[YOURUSER]/.smbcredentials like this:

user=[SMBUSER]

password=[SMBPASS]

Secure your credentials using
chmod 0600 ~/.smbcredentials