Accessing a NAS from your Linux laptop should be done with autofs
rather than fstab
, because the automounter will reestablish the remote filesystem access automatically should you loose your wifi connection now and then.
In my home setup i have a FRITZ!Box 7490 serving an USB 3.0 SSD as my local NAS to be accessed by multiple different devices. Some of these are Linux laptops running an openSUSE 15.2 distribution. The NAS itself supported the SMB 1 protocol only in the past, but after upgrading to a newer FRITZ!OS i can use SMB 3 now.
To get the automounter service running, i had to install it first because it wasn't part of a default installation:
$> zypper in autofs
I want to access the NAS with the mount point /fritz.box
, therefore i created that directory first with mkdir /fritz.box
. After that i edited the file /etc/auto.master
, the main configuration file of the automounter, by adding the line:
/- /etc/auto.direct
After the above mentioned file /etc/auto.direct
was created by myself i wrote the following line into it to access my NAS dynamically with the automounter:
/fritz.box -fstype=cifs,rw,uid=${UID},gid=users,noserverino,cache=none,file_mode=0664,dir_mode=0775,username=cifsuser,password=XXXXX ://fritz.box/fritz.nas
Most of the parameters should be self-explanatory (for cache=none
see my other article). I created an explicit cifsuser
account on the FRITZ!Box NAS server first before using it here for the connection authorization. If you need to, you could include these authorization credentials from an external file (preferably from the current users home directory) instead of hardcoding it into this line here. The uid
parameter takes the current user id from the environment of the calling user, because depending on who is using my laptop currently (my other household members), he will get this NAS path mounted as himself.
Now before all the autofs magic happens, you have to enable and start the automounter first (if it was a new installation):
$> systemctl enable autofs.service
$> systemctl start autofs.service
One additional note. If you happen to have an older version of FRITZ!OS which supports the SMB 1.0 protocol only, you have to add a ver=1.0
parameter to the above mentioned mount line in /etc/auto.direct
.