Score:1

Mounting shares from Synology NAS persistent on boot up

us flag

Mounting shares from Synology NAS persistent on boot up

I'm using Ubuntu 20.4 with a Synology NAS that is accessible easily from Windows and Mac

I can mount the shares using the following command in terminal:

sudo mount -o uid=linuxusername,username=shareuser,pass=sharepass //192.168.1.2/music /home/profile/Music/musicone

However, that's labourious since I have several sharepoints to mount, therefore I want to mount using fstab for persistent mount, so I made this entry:

//192.168.42.2/music /home/profile/Music/musicone cifs uid=linuxuser,username=sharepointuser,pass=sharepointpass 0 0

I had a lot of problems making that fstab file work, but finally I got it tweaked. I'm leaving this here in case I can help others with the same mounting issue. That is the functioning syntax. I did try using gid instead of uid, but that did not work, so this only works for one user, I think. (I only have one user, and the mounts are in that home directory)

However ... I'd prefer to use a file for credentials, so I made a file called .smbcredentials, substituting credentials=filepath for the username and password.

This is not working. The sharepoint appears, but opening as user yields an error that it can only be mounted as root, and opening as root says

mount:/home/profile/Documents/nas: you may need a file type detail like /sbin/mount.(filetype) helper program

but I don't know where to place that in the syntax. There's no mount.smb option in sbin, but there is mount.nfs which could work, because my NAS has NFS turned on. But it doesn't, with the first error saying the share is not in host:dir format. Adding a colon after the IP of the server did not help and that didn't even get to the authentication part.

I did try putting /sbin/mount.nfs in a few places in the syntax, leaving in the nfs reference (where cifs goes) but nothing would make the share available.

Mounting with a group id (gid=1000) would be better, (and I'd put the mountpoints in /mnt/) but that's not working, so if I added a user, I'd be in trouble there.

Here's two of the dozens of web pages I looked at, these yielded the most, but obviously not complete, results.

https://wiki.ubuntu.com/MountWindowsSharesPermanently https://deathofagremmie.com/2012/05/01/mounting-a-synology-diskstation-on-ubuntu-12.04/#disqus_thread

Peter Addison avatar
us flag
subsituting 'nfs' for 'cifs' in the mount syntax does not successfully mount the sharepoints. in user, I can see the shares, but I cannot open them. In user mode I get "only permitted as root" and in root mode I get "mount.nfs: share not in host:dir format" Adding a colon after the server's IP did not resolve this problem. that was one suggestion I had tried, I'd be very happy if you could provide a syntax for sharing. adding the colon gave the error "failed to resolve server, name or service unknown.
Marc Vanhoomissen avatar
in flag
Do you have a `mount.cifs` in `/sbin`?
Peter Addison avatar
us flag
no, I don't have that. I do have mount.nfs. mounting cifs works fine, except I can't put the credentials in a file and read them.
Peter Addison avatar
us flag
I reconfigured the Synology, adding an NFS permisson on one of the shares. I confgured mapping root to admin, and configured a matching user for my linux "profile" account, with read-write permissions on the nfs share. I can easily browse to the folder through the network, but have been unsuccessful in mounting it with nfs profile@Ubuntu-pc:~$ sudo mount 192.168.42.2:/volume2/MusicTwo /home/profile/Music/nfstest mount.nfs: access denied by server while mounting 192.168.42.2:/volume2/MusicTwo
Peter Addison avatar
us flag
I keep getting "access denied by server" after trying several tweaks to the NFS permissions on the server and in the nfs options. For me, NFS is a non-starter for mounting it. I can browse to it, since I have a user account on the Synology now, but I can't mount it. Not by command line, nor in the fstab. The prohibits access to the share from several programs as they won't access it unless it's locally mounted.
ar flag
Try enabling `sftp` in Synology NAS. Then either use [`sshfs`](https://help.ubuntu.com/community/SSHFS) in `/etc/fstab` to mount. Alternately use something like `sftp://[email protected]/NetBackup/Computer_to_be_backedup/peter` as the storage location in DejaDup, the default backup app in Ubuntu.
ar flag
If you think the answer below is correct then click on the gray check mark ✔️ next to the answer and turn it green ✅. This will mark the problem as solved and help others.
Score:0
in flag

Do you have a mount.cifs in /sbin? If not, try and install smbclient

sudo apt-get install smbclient

I used to do so but now I use automount. That solution has the advantage of automatically mounting your shares as soon as your NAS becomes available.

Edit: Re-installing cifs-utils, it worked (sudo apt install cifs-utils)

Peter Addison avatar
us flag
I ran that install, but neither mount.cifs or mount.smb is not in /sbin
Marc Vanhoomissen avatar
in flag
Are the `cifs-utils`also installed? (`sudo apt install cifs-utils`)
Peter Addison avatar
us flag
I did install smbclient, but it did not improve anything
Peter Addison avatar
us flag
yes, cifs-utils were install some time ago
Marc Vanhoomissen avatar
in flag
@PeterAddison Very strange because mount.cifs belongs to cifs-utils (https://packages.debian.org/search?searchon=contents&keywords=mount.cifs). Maybe be a reinstall could solve the problem.
Peter Addison avatar
us flag
Kowabunga. when I re-installed the cifs-utils it worked with the credentials installed in the file .smbcredentians in my home directory.
Peter Addison avatar
us flag
//192.168.42.2/fileshare /home/profile/Documents/nasfiles cifs uid=profile,credentials=/home/profile/.smbcredentials 0 0
Peter Addison avatar
us flag
how do I post that so it comes in the grey background?
Marc Vanhoomissen avatar
in flag
@PeterAddison: just use the backtick "`" before and after the text. Or use the <kbd>{}</kbd> button.
Marc Vanhoomissen avatar
in flag
@PeterAddison Also, if the answer solved the problem, mark it as 'accepted', so that further users can spot it easily.
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.