Mounting a Samba Share Under Debian – Natural Born Coder (Natural Born Coder » Feed) (https://www.naturalborncoder.com/feed/) (Natural Born Coder » Comments Feed) (https://www.naturalborncoder.com/comments/feed/) (https://www.naturalborncoder.com/wp-json/) (JSON) (https://www.naturalborncoder.com/wp-json/wp/v2/posts/1330) (RSD) (https://www.naturalborncoder.com/xmlrpc.php?rsd) (https://www.naturalborncoder.com/2023/07/mounting-a-samba-share-under-debian/) (https://www.naturalborncoder.com/?p=1330) (oEmbed (JSON)) (https://www.naturalborncoder.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fwww.naturalborncoder.com%2F2023%2F07%2Fmounting-a-samba-share-under-debian%2F) (oEmbed (XML)) (https://www.naturalborncoder.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fwww.naturalborncoder.com%2F2023%2F07%2Fmounting-a-samba-share-under-debian%2F&format=xml) Skip to content (https://www.naturalborncoder.com/) Natural Born Coder (https://www.naturalborncoder.com/category/java/) Java (https://www.naturalborncoder.com/category/java/java-ee/) Java EE (https://www.naturalborncoder.com/category/java/javafx/) JavaFX (https://www.naturalborncoder.com/category/methodology/) Methodology (https://www.naturalborncoder.com/category/methodology/revision-control/) Revision Control Covering all flavours of revision control from CVS and Subversion to Git. (https://www.naturalborncoder.com/category/linux/) Linux (https://www.naturalborncoder.com/category/virtualization/) Virtualization (https://www.naturalborncoder.com/category/networking/) Networking (https://www.naturalborncoder.com/about/) About Mounting a Samba Share Under Debian (https://www.naturalborncoder.com/2023/07/mounting-a-samba-share-under-debian/) Jul 15, 2023 — by (https://www.naturalborncoder.com/author/doozer/) doozer in (https://www.naturalborncoder.com/category/linux/) Linux In this article we’ll permanently mount a Samba share on a Debian based system, this process will be similar for other Linux distributions too. It is assumed that you have a share somewhere else already configured and ready to go. Start by installing the required utilities, this will install a few other utilities as well. sudo apt install cifs-utils sudo apt install cifs-utils sudo apt install cifs-utils Now create a folder to act as the mount point for the shared drive. Where you put these is up to you, but I generally put mine under the /mnt directory. Strictly speaking /mnt is for temporarily mounted filesystems but the (https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard) filesystem hierarchy standard doesn’t really provide a good location for permanently mounted shares that don’t have an obvious location elsewhere (although /srv looks like a possible candidate). For Docker installs I’ve take to creating a root directory called /data and a subdirectory /data/mnt , I find this works well enough. sudo mkdir /mnt/music sudo mkdir /mnt/music sudo mkdir /mnt/music Create a credentials file in your home directory that will contain the login details needed to mount the remote share. Root will be mounting the share so place the file in root’s home directory. I name the file with the server name first which is helpful if there are multiple sets of credentials stored. sudo nano /root/.fileserver_smbcredentials sudo nano /root/.fileserver_smbcredentials sudo nano /root/.fileserver_smbcredentials The credentials file should contain just two lines: username=samba_username password=samba_password username=samba_username password=samba_password username=samba_username password=samba_password Now test mount the share by issuing the command below. You may or may not need all the options that are specified here. The uid and gid flags tell the mount system to set the user and group for the mount. In my case I need to write to the share as a particular user and group since that is what my file server is expecting. I needed to add the lxc-users group to the machine I was creating the mount on and then add the user to the group. If you don’t add the uid and gid settings you’ll find the you can only write to the share as root. The dir_mode and file_mode settings tell the mount system what the default permissions should be, I want files and directories writeable by the whole group. You could probably also use the noperm option but that removes all permissions checks. I also needed to use the fully qualified name of the file server, I must have forgotten to set up search domains. sudo mount -t cifs -o rw,vers= 3.0 ,credentials=/root/.fileserver_smbcredentials,dir_mode= 0775 ,file_mode= 0775 ,uid= 1000 ,gid= 9999 //fileserver.example.co.uk/music /mnt/music sudo mount -t cifs -o rw,vers=3.0,credentials=/root/.fileserver_smbcredentials,dir_mode=0775,file_mode=0775,uid=1000,gid=9999 //fileserver.example.co.uk/music /mnt/music sudo mount -t cifs -o rw,vers=3.0,credentials=/root/.fileserver_smbcredentials,dir_mode=0775,file_mode=0775,uid=1000,gid=9999 //fileserver.example.co.uk/music /mnt/music If that works you can unmount the path again with: sudo umount /mnt/music sudo umount /mnt/music sudo umount /mnt/music If the manual mounting works you can add the same settings to /etc/fstab to make the mount permanent. Note that the order of the settings is somewhat different in the fstab file and the entry shown should all appear on a single line. sudo nano /etc/fstab sudo nano /etc/fstab sudo nano /etc/fstab //fileserver.example.co.uk/music /mnt/music cifs rw,vers=3.0,credentials=/root/.fileserver_smbcredentials,dir_mode=0775,file_mode=0775,uid=1000,gid=9999 //fileserver.example.co.uk/music /mnt/music cifs rw,vers=3.0,credentials=/root/.fileserver_smbcredentials,dir_mode=0775,file_mode=0775,uid=1000,gid=9999 //fileserver.example.co.uk/music /mnt/music cifs rw,vers=3.0,credentials=/root/.fileserver_smbcredentials,dir_mode=0775,file_mode=0775,uid=1000,gid=9999 When you’re done save the file and reboot the machine. If the settings are all correct you should find the share mounted after the restart. References (https://help.ubuntu.com/community/MountCifsFstabSecurely) Mounting with CIFS (https://superuser.com/questions/320415/mount-device-with-specific-user-rights) Mount a device with specific permissions (https://tecadmin.net/mounting-samba-share-on-ubuntu/) General guide to mounting on Debian (https://linuxize.com/post/how-to-mount-cifs-windows-share-on-linux/) General mounting on Linux guide (https://www.naturalborncoder.com/tag/debian/) Debian (https://www.naturalborncoder.com/tag/linux/) Linux (https://www.naturalborncoder.com/tag/nas/) NAS ← (https://www.naturalborncoder.com/2023/07/setting-up-sudo-on-debian/) Previous: Setting up Sudo on Debian (https://www.naturalborncoder.com/2023/07/creating-a-personal-music-server-navidrome/) Next: Creating a Personal Music Server – Navidrome → (https://www.naturalborncoder.com/) Natural Born Coder Making electrons work for a living…