November 3, 2019

Adding a Synology NAS directory to be mounted at start

Previously I didn't bother about mounting the NAS directories at boot in Ubuntu, because most of the file management I did was using Windows. But I don't have a Windows boot on the new machine, then I tried to sort that out. It took some investigation, but in the end it works well.

First the mounting directory needs to be created, and then the /etc/fstab file has to be modified. The credentials for the connection are stored in a file in my home directory.

First create the directory:

mkdir ~/mapped_directory_name

Then create the file with the credentials:

touch ~/.nas_credentials

And write on it the details:


Then edit the file /etc/fstab. I used Visual Studio Code to add the following line:

//your_nas_name.local/your_nas_directory /home/your_local_username/mapped_directory_name cifs vers=1.0,auto,credentials=/home/your_local_username/.nas_credentials,iocharset=utf8,sec=ntlm 0 0

If you want to mount a NAS directory temporarily, the command is:

sudo mount -t cifs //your_nas_name.local/your_nas_directory /home/your_local_username/mapped_directory_name  -o credentials=/home/your_local_username/.nas_credentials,vers=2.0

If you look at the fstab line and the terminal command, there is a vers= difference (1.0 in fstab, 2.0 in the command). For some reason 2.0 was giving me errors in fstab, but 1.0 seems to be happy.

One final note, if your directory names have spaces, then in the fstab file you need to replace them with \040. Doing that:

//your_nas_name.local/name with spaces

will become: