Score:0

How to mount samba share on NAS at boot the same way it is mounted by "Files"?

cn flag

Before you mark this as duplicate kindly read on.

I have a samba share on a NAS that is mounted only when I click on it in Files.

enter image description here

The share is mounted as

/run/user/1000/gvfs/smb-share:server=mycloudex2ultra.local,share=public

I would like the NAS to be mounted exactly like that, but at boot. What should I write in the /etc/fstab?

Instructions I have found are to mount the share in a directory under /media which is not what I am trying to do. Also, I don't know where the file with samba credentials is, if anywhere.

hr flag
I'm not sure that /run/user/1000 even exists "at boot" does it? AFAIK it's created on the fly by pam_systemd (and destroyed when the user has no more concurrent sessions)
Score:1
nu flag

You can mount the smb share at boot by adding this line to /etc/fstab

//server/shared /path/to/mount cifs credentials=/path/to/creds.txt 0 0

For what your case seems to be:

//mycloudex2ultra.local/public /path/to/mount cifs credentials=/path/to/creds.txt 0 0

Also create a file /path/to/creds.txt and do chmod 600 /path/to/creds.txt with the following content:

username=Username
password=Password
domain=DomainName

You can read more through redhat's documentation here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/managing_file_systems/index#mounting-an-smb-share-on-red-hat-enterprise-linux_managing-file-systems

The documentation would be very similar to Ubuntu

Score:1
es flag

I really think you would be better off with a traditional CIFS mount as outlined by Killian Fortman's answer.

But if you absolutely need to have it mount like Nautilus does it then this example might work:

I created a file in my Ubuntu home directory: /home/tester/ServerCreds with this content:

guest
workgroup
dummypassword

I'm accessing a guest share that doesn't require credentials but gvfs demands I pass one anyway so I made something up.

Then go to Activities > Startup Applications > Add

Name: ServerPublicShare
Command:  bash -c 'gio mount smb://vxub2204.local/public < /home/tester/ServerCreds'

When I logoff and login again the share is mounted and available in Nautilus:

tester@vub2204:~$ ls -l /run/user/1000/gvfs
total 0
drwx------ 1 tester tester 0 Feb  7 06:56 'smb-share:server=vxub2204.local,share=public'
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.