Skip to main content
The Road

Mounting a Synology NAS in Linux

One of the things that bothered me about Linux was that, compared to Windows, mounting NAS drives (in my case, Synology) was a bit of a hassle for beginners.

In Windows, you can simply "map a network drive," save your login credentials, and set it to connect automatically at startup. It only takes 3–4 mouse clicks. In Linux, it's a bit more involved, at least if you're the only user on the NAS.

When I use Linux, I always mount network drives via NFS and AutoFS—if you set "Squash" to "All Users as Admin" for the shared folders on the Synology DiskStation, access works without any issues at first glance. The downside is that the files on the DiskStation have different owners.
Files that already exist and were created in Windows are owned by the user created on the DiskStation. Files newly created from Linux are owned by the Linux user.

This is primarily because the Synology user has a different user ID than the Linux user. Windows didn't care about this—but since the DiskStation runs a Linux system, it does matter when accessing it from a Linux system.

However, this can be resolved quite easily in just a few steps.
Please note that you make all of the following settings at your own risk, and don't forget to back up your data!


Preparations

  • On the DiskStation, enable the SSH service and log in to the DiskStation from your computer using PuTTY (install it if necessary).
    Use the same login credentials you use when logging into the NAS via a browser. You will now see the PuTTY terminal; enter the command "Id" (without the quotation marks). You will now see, among other things, your 4-digit user ID, for example 1039. Make a note of this number. Then disable the SSH service on the Synology again.

  • On your Linux computer, create a user with the same name and ID that you wrote down.
    If your user on the NAS is named "hans" and has ID 1039, open a terminal and enter the following command:
    sudo adduser hans -u 1039
    When prompted for a password, enter the password of the existing NAS user.
    As a final step, promote the new Linux user to system administrator—in Linux Mint, this is very easy to do via the user management tool. Please also verify that the new user belongs to the same group as the existing user.

  • Now log in to your Linux computer using the new user account. You'll need the following packages (if they aren't already installed):
    cifs-utils
    nfs-common
    autofs

Mounting the NAS

  • Now launch the file manager with admin privileges; on Mint Cinnamon, this would be "sudo nemo".
    Next, navigate to the "etc" directory. There you'll see a file named "auto.master". Open this file and save it as “auto.synology.”
    Edit this new file and enter the connection details for the shared folder on the NAS.
    Let’s assume your NAS has the IP address 192.168.188.9, the shared folder is named “Music,” and you want to mount it with the same name; the file would look like this:
    Music -fstype=nfs,async,rw,retry=0 192.168.188.9:/volume1/Music
    For Synology DiskStations, you must always prefix the actual share name with "volume1" —or, if there are multiple drives that aren’t grouped together, the corresponding volume on which the share is located.

  • Now open the "auto.master" file and insert the following before the last line (before the +auto.master):
    /home/hans/Synology /etc/auto.synology --ghost --timeout=0
    This will mount the share in the home directory within the "Synology" folder of the user "hans." Personally, I find this more elegant than having to "search" for my NAS drives elsewhere in the system.
    Note: If you’re backing up your home directory using a backup program, be sure to define an exception for the Synology directory in the backup program. Otherwise, your NAS share may be backed up as well.

For more tips on Linux, see here.

 

Not yet rated

Comments

No Comments

Add a comment:

*Required fields




Subscribe to comments RSS Feed



Blog