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.
The following records are the configuration steps on Synology NAS, other systems should be similar. The static IP address of the NAS is: 192.168.1.100
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.
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 192.168.1.100
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 192.168.1.100:/volume1/music /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
You will get system output similar to the following:
Filesystem Size Used Avail Use% Mounted on
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:
192.168.1.100:/volume1/music /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.