Access Synology NAS via NFS client in Ubunt 18.04

Nowadays, more and more families use NAS. Most NAS systems provide multiple file sharing methods. This article records how to configure Ubuntu 18.04 clients to access Synology NAS shared files.

Configure NFS shared files on the NAS

The following records are the configuration steps on Synology NAS, other systems should be similar. The static IP address of the NAS is:

Log in to the web management interface of Synology NAS, select “Control Panel” -> “Shared Folder”, then select the directory you want to configure (share), click “Edit”, and select “NFS Permissions” in the pop-up dialog box.

If NFS has not been configured before, the table here is blank. Select “Create” to add a rule. Fill in the relevant configuration information in a pop-up window. It should be noted here that it is recommended to select the “Squash” option as: “Map all users to guest” and check “enable asynchronous”. To simplify the configuration of the subsequent client.

Install and set up the client

First, execute the following command on the Ubuntu 18.04 machine to install the NFS Client.

sudo apt-get update
sudo apt-get install nfs-common

After installation, we can use the “showmount” command to view the shared NFS files on the specified machine (IP address). such as:

showmount -e

You can see the folder shared on the NAS just now.

If you need to access a folder on the NAS, you first need to mount the shared folder locally.

First create a folder locally, for example, create a folder named nfs_music

sudo mkdir /mnt/nfs_music

Then execute the following command to mount:

sudo mount -t nfs /mnt/nfs_music

“/volume1/music” is the directory of the shared folder on the NAS.

To view the effect of mounting, you can use the df -h command

df -h

You will get system output similar to the following:

Filesystem                        Size  Used Avail Use% Mounted on
udev 967M 0 967M 0% /dev
tmpfs 200M 1.1M 199M 1% /run
/dev/sda2 5.9G 3.1G 2.6G 55% /
tmpfs 997M 0 997M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 997M 0 997M 0% /sys/fs/cgroup
/dev/loop0 89M 89M 0 100% /snap/core/7270
/dev/loop1 92M 92M 0 100% /snap/core/8689 1.0T 1.0T 307G 70% /mnt/nfs_music
tmpfs 200M 0 200M 0% /run/user/1000

Set to automatically mount NFS at boot

After performing the above steps, if you restart the client machine, you need to execute the mount command again to mount the NFS shared directory. If you want to mount the NFS shared directory automatically at boot, you need to edit the /etc/fstab file and execute:

sudo vi /etc/fstab

Add the following line at the end of the file:

1 /mnt/nfs_music nfs defaults,timeo=900,retrans=5,_netdev 0 0

Replace the corresponding content in the command with your IP address and directory name. After editing, save and exit. In this way, the NFS shared directory can be mounted automatically when the machine is restarted.

本文标题:Access Synology NAS via NFS client in Ubunt 18.04

文章作者:Morning Star

发布时间:2021年07月03日 - 06:07

最后更新:2021年07月03日 - 06:07


许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。