[Solved] Connect to Synology DiskStation using NFS (or SMB?)

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

[Solved] Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

Hello,

I'm having trouble to include my Synology DiskStation to my file system. First, some facts:
  • Linux Mint 21.2 default
  • Synology OS 7.2.1
  • DiskStation runs 2 HDDs in Raid 1 configuration with ext4 file system
SMB:
I was using the DiskStation with smb in Windows for the longest time without any trouble. But when I tried to copy large amount if data with Nemo accessing via smb interface, I got "broken pipe" errors all the time. Because I was worried that my data could corrupt, I decided to don't trust smb anymore when using Linux client and tried NFS instead. If there is a fix for smb, I'd be happy to try it.

NFS:
Synology offers NFSv3 or NFSv4. Trying to mount the drive NFSv3 mode gave me "protocol not support" error. NFSv4 works (although I didnt try large amounts of data yet), but there is a flaw: For some reason, the user:group of the mount directory is reverted to "user:root", and no application of chown, chgrp etc does change that. After unmounting, the same folder changes back to "user:user". As a result, I can read/write the drive as root without problems, but because of the user group it doesnt allow me to have write access in Nemo.

Any help from SMB/NFS experts is appreciated!
Last edited by gflash on Tue Mar 26, 2024 4:21 pm, edited 3 times in total.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by AndyMH »

See my posts in this topic:
viewtopic.php?p=2224687&hilit=synology+fstab#p2224687

Ignore the bit about me setting smb to V1 on the synology, that was me getting my facts wrong. Leave the setting as is, mint will connect and negotiate for a higher version.

I did try nfs, got it working but wasn't happy with the end result and reverted to cifs. I can email you a pdf "how to" on nfs if you really want, you would need to PM me an email addy.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

I am so very close to get it to work with NFS. Following settings in the disk station:

Code: Select all

Control Panel -> FIle Services -> NFS
[x]		Enable NFS Service
[NFSv4]	Maximum NFS Protocol
Advanced Settings
[x]		Apply default UNIX permissions
[ ] 		Customized Ports
[32k]	Read packet size
[32k]	Write packet size
[ ]		NFSv4 domain

Code: Select all

Control Panel -> Shared Folders -> DiskStation -> NFS permissions -> Edit
[<myIP>/255.255.255.0]		Hostname or IP  <-- Adding subnet mask will allow any PC in the subnet to connect, not just one
[Read/Write]			Privilege
[no mapping]			Squash
[sys]				Security
[x]		Enable Asynchronous
[ ] 		Allow connections from non-privileged
[]		Allow users to access mouned subfolders
The UID/GID on the share are still a bit borked. User rights for an example file:

Code: Select all

-rwxrwxrwx  1 gflash users  214339 Jan  3  2019 'Projektplan 1.xlsx'
Note that the file is in group "users", not "gflash".

User rights for mount folder after mounting:

Code: Select all

drwxrwxrwx  4 gflash root   4096 Mär 23 18:13 diskstation
I can mount and access the shared folder without problem, also now I have full read/write access with my standard user from console. If I copy a file from the NFS share to my home folder it gets gflash:gflash. If I copy a file from my home folder to the NFS it gets nobody:nogroup. However, Nemo still thinks it is not allowed to write on the NFS share. How is it possible that it works fine in console but not in Nemo?
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by AndyMH »

You are starting to see why I reverted to cifs. I think part of the problem is the squash options on synology are limited.

This is what my synology looks like in nemo mounting with cifs:
Screenshot from 2024-03-23 18-47-10.png
Everything owned by me, because the mount statement in fstab explicitly tells mint who the owner is.

This is the same thing, but with an nfs mount:
Screenshot from 2024-03-23 18-57-16.png
Everything owned by user 1026, except for one owned by 1024. I asked synology, 1026 is the first user created on the synology (pretty much every linux distro has the first user at 1000, why do they have to be different?). The file owned by 1024 is a file I had copied up to the NAS via nfs. The only way I could get write access was to select the squash option “Map all users to admin”, so I'm assuming 1024 is the root user on the synology. I asked synology can I map to a specific user, they said no. It was at that point I reverted to cifs, I never downloaded anything to the local PC via nfs, so never checked what it showed as the owner.

I could also never figure out how to use it with hostname instead of the IP address - with cifs you access the NAS using credentials for a user on the NAS, with nfs you give access permission for a specific PC (or group).

In spite of the fact that the synology is running linux I have not found it very linux friendly - their target market are win users.

I did the above a couple or three years ago and have not revisited it since.

EDIT - to upload screenshots. In mint PrtScn will take a screenshot of the desktop, Alt + PrtScn will take a screenshot of the active window. Default is to save in ~/Pictures. Below the compose/reply window see the attachments tab. There you can upload files and when uploaded a "place inline" button appears, that will put the code for the image at your cursor in the compose window. Use preview to check it works. There is a limit of 200kb on uploads, most screenshots are less. Above that you need to either convert to a jpg (screenshots are png) or use a remote site like imgur and the [rimg] tags.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

Well, thing is, regarding NFS everthing works fine. Files end up with correct user:group on my client, and I don't really care about messed up file permissions on the Synology.

The only remaining issue is how to tell Nemo that it can actually write on files/folders in group 100(users). For me it looks a bit like a bug in Nemo, but I'm not confident yet.
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

I think this post can be closed, because NFS is working fine. I'll open another post in the Cinnamon section to discuss the (for me) unexpected behaviour of Nemo.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [Solved] Connect to Synology DiskStation using NFS (or SMB?)

Post by AndyMH »

Thinking sideways, I assume you are mounting the synology via nfs with an entry in fstab. Normally you would use uid=1000,gid=1000 to an ntfs file share because win filesystems do not support linux file permissions. I wonder what happens when you use it for an nfs share?
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
altair4
Level 20
Level 20
Posts: 11461
Joined: Tue Feb 03, 2009 10:27 am

Re: [Solved] Connect to Synology DiskStation using NFS (or SMB?)

Post by altair4 »

AndyMH wrote: Sun Mar 24, 2024 7:46 am Thinking sideways, I assume you are mounting the synology via nfs with an entry in fstab.
I've got a theory but I have a question for you.

When you enable nfs on synology - but do not mount it manually or in fstab - does it appear under Network in Mint's Memo file manager?

I'm wondering if this is the NFS counterpart to this: viewtopic.php?p=2417188#p2417188

If gvfs-fuse isn't installed or if /usr/libexec/gvfsd-fuse was never instructed to active the /run/user/1000/gvfs folder if you just click on the server in Nemo it would fit the symptoms: You can see the contents of the share but cannot write.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [Solved] Connect to Synology DiskStation using NFS (or SMB?)

Post by AndyMH »

altair4 wrote: Sun Mar 24, 2024 10:05 am When you enable nfs on synology - but do not mount it manually or in fstab - does it appear under Network in Mint's Memo file manager?
No, all I see are either smb or ftp shares. My guess on why, other than ftp, I have two diskstations is that as well as SMB I have bonjour enabled (no idea why, probably seemed like a good idea at the time). M720 is the local pc.
Screenshot from 2024-03-24 14-51-36.png
Looking at my previous screenshots, my cifs mount for the synology shows under network in nemo, but the nfs share appears under devices! That suggests to me that everything in nemo that is network related (probably coming from gvfs) is cifs/smb related in spite of nfs being a linux native protocol. Note my nfs knowledge is limited, I figured out how to connect to the synology with it, didn't like it and abandoned it.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: [Solved] Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

Hello,

This is what I do (for now, I will later add it in fstab and use a better mount path).

Code: Select all

sudo mount diskstation.local:/volume1/DiskStation diskstation
If I try with uid/gid option I get an error. I have no idea what the "Created symlink" message mean though.

Code: Select all

sudo mount -o umask=0022,gid=1000,uid=1000 diskstation.local:/volume1/DiskStation diskstation
Created symlink /run/systemd/system/remote-fs.target.wants/rpc-statd.service → /lib/systemd/system/rpc-statd.service.
mount.nfs: an incorrect mount option was specified
If I try nfs://diskstation.local/volume1/DiskStation in Nemo title bar, I get something intetesting: Access Denied. Maybe it would work this way if I'd use kerberos on the NFS server. This is something I didnt try to set up yet.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [Solved] Connect to Synology DiskStation using NFS (or SMB?)

Post by AndyMH »

gflash wrote: Mon Mar 25, 2024 1:01 am If I try with uid/gid option I get an error.
Well that's one bright idea in the bin. I didn't try with kerberos, looked complicated.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
altair4
Level 20
Level 20
Posts: 11461
Joined: Tue Feb 03, 2009 10:27 am

Re: [Solved] Connect to Synology DiskStation using NFS (or SMB?)

Post by altair4 »

gflash wrote: Mon Mar 25, 2024 1:01 am Hello,

This is what I do (for now, I will later add it in fstab and use a better mount path).

Code: Select all

sudo mount diskstation.local:/volume1/DiskStation diskstation
So what you are saying is the permissions on the "disktation" folder displayed in a terminal using:

Code: Select all

ls -dl $HOME/diskstation
And:

Code: Select all

stat $HOME/diskstation
Is different from the permissions you see when you open Nemo > Right click the diskstation folder in your home directory > Properties > Permissions?
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

diskstation mount folder:

Code: Select all

gflash@Valinor:/media$ ls -dl diskstation
drwxrwxrwx 4 gflash root 4096 Mär 23 18:36 diskstation
perm_diskstation.png

Example file on the NFS while mounted:

Code: Select all

gflash@Valinor:/media/diskstation/backup/Dokumente/Haus$ ls -dl Projektplan\ 1.xlsx 
-rwxrwxrwx 1 gflash users 214339 Jan  3  2019 'Projektplan 1.xlsx'
perm_files.png

To me permissions look identical. As I said, the issue is that Nemo doesn't realize it actually has write access to the files.

Sorry for all the German.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by AndyMH »

gflash wrote: Mon Mar 25, 2024 12:18 pm To me permissions look identical. As I said, the issue is that Nemo doesn't realize it actually has write access to the files.
To clarify, when you try and copy a file with nemo, it refuses?

I think that was the problem I had (I didn't try copying files from the terminal with cp). The solution on the synology was to map "all users to admin" in the squash settings. Then I had write access using nemo. I did ask synology if I could map a user to a user. The answer was no. What I would have liked to do was map user andy (uid=1026) on the synology to user andy (uid=1000) locally. As I said I didn't spend much time on nfs and what I have said in this post represents the sum total of my knowledge on the subject.
Screenshot from 2024-03-25 16-32-48.png
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

Hello,

I did some more testing and now have to take back some of what I said.

Firstly, using Squash setting "all users to admin" or "all users to nobody" leads to inconsistent behaviour. Now some folders can be written, others can not. Furthermore, console now shows a similar behavior.

Secondly, I tried again without squashing. Now I found folders that cannot be written in console, too. It seems initially I just was in luck with the folders I randomly tested. But there definitely where folders that could be written in console, but not in Nemo. Also, it happened that I was able to copy a file to the NFS folder by drag&drop, but then it didnt allow me to delete it. Deletion in console worked.

So now we have different behavior among folders, which were certainly all created with the same permissions. We have inconsistent behavior between console and Nemo (sometimes, sometimes not). Honestly I'm close to giving up on NFS now. This kind of behavior seems buggy.

Maybe its more worthwile to examine the broken pipe errors I had when using SMB? Did you observe something similar?
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by AndyMH »

gflash wrote: Mon Mar 25, 2024 1:24 pm Honestly I'm close to giving up on NFS now.
Maybe its more worthwile to examine the broken pipe errors I had when using SMB? Did you observe something similar?
I did!

I have had no issues with SMB or with cifs (which is how I normally access the synology).

Some of the nfs issues maybe down to the permissions that synology sets on your "home" folders. It was a nightmare getting ssh working with it so I could do an rsync backup to it:
viewtopic.php?p=2334473&hilit=rsync+NAS#p2334473
At some point I might revisit nfs with this in mind.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
altair4
Level 20
Level 20
Posts: 11461
Joined: Tue Feb 03, 2009 10:27 am

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by altair4 »

I would just like to point out there is a difference in how Nemo ( or any other Linux file manager ) accesses a smb server and how AndyMH uses cifs ( as in mount.cifs ) to access a share.

Accessing a SMB server through Nemo is a convoluted process:

Nemo > gvfs ( gio ) backend > a smb client library > server access.

Whereas connecting to a SMB server with a cifs mount is more direct:

Linux Kernel > server access
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

AndyMH wrote: Mon Mar 25, 2024 1:34 pm I have had no issues with SMB or with cifs (which is how I normally access the synology).
Could you post your /etc/fstab line?
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by AndyMH »

Code: Select all

//diskstation.local/home/	/media/synology	cifs	credentials=/etc/samba/credentials,uid=1000,gid=1000,user,nofail	0	0
Where credentials is pointing at a file of the form:

Code: Select all

user=xxxx
password=yyyy
You can use user=xxxx,password=yyyy instead of credentials=
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Connect to Synology DiskStation using NFS (or SMB?)

Post by gflash »

It worked, thanks again! Also no broke pipe errors anymore.

For possible future readers:
  • I had to set "Maximum SMB protocol" in the advanced settings to SMB3
  • Mind that home is not a directory name, but the name of the share (DiskStation in my case)
Synology.png
Post Reply

Return to “Software & Applications”