3

i have been wrestling with adding a (asustor) nas to my network last week and finally got to the point where i can mount folders via nfs in ubuntu and from my raspberry-pi running rune-audio.

i mount these in root/nfs/"folder" and added it to the nautilus sidebar. now i would like to auto mount these upon boot and have read through:
https://help.ubuntu.com/community/Autofs and,
How to setup Automount/Autofs

I have installed autofs.

but i don't seem to understand how to convert the assignment in terminal when i manually mount it to a rule for auto.master:

Manual mount rule used: sudo mount 192.168.0.200:/volume1/Public /nfs/Public

help on this "conversion" would be greatly appreciated.

that is i assume that adding that rule to the standard auto.master is enough or should i work with indirect rules? incorperating auto.nfs?

many thanks in advance on any assistance.

Addition:

I due to the help of steeldriver i indeed got the folder mounted.
But i forgot to mention that besides the rule mentioned above:
sudo mount 192.168.0.200:/volume1/Public /nfs/Public.

i also need to mount:

sudo mount 192.168.0.200:/share/USB1 /nfs/Music.

i assumed this would be similar to implement, but when it tried the following:
* -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid,tcp 192.168.0.200:/volume1/Public
* -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid,tcp 192.168.0.200:/share/USB1

but this only gave me a Music folder with the public content, not the USB1 content. what am i doing wrong here?

2
  • If you want to mount it automatically on boot then you don't need autofs - you can simply add it to your /etc/fstab (although it may need some adjustment of options to prevent boot hangs in the case that the NAS is unavailable) - autofs is really for mounting on demand Feb 17, 2017 at 15:12
  • as you say, mountint upon boot really isn't a necessity. just something i assumed. mounting on demand is just as, or maybe more usefull to me as i work of a laptop and when i disconnect from the network this might indeed give problems if i understand correctly. ifso this leaves the same question. Feb 17, 2017 at 15:41

2 Answers 2

10

To mount NFS shares we need to install nfs-common:

sudo apt-get install nfs-common

To save us from retyping this after every reboot we add the following line to /etc/fstab:

<nfs-server-IP>:/   /mnt   nfs    auto  0  0

If after mounting, the entry in /proc/mounts appears as :// (with two slashes), then you might need to specify two slashes in /etc/fstab, or else umount might complain that it cannot find the mount.

The auto option mounts on startup. However this will not work if your client uses a wifi connection managed at the user level (after login), because the network will not be available at boot time. In Ubuntu 12.04 LTS and later, wifi connections are managed at the system level by default, so auto-mounting of NFS shares at boot time should work fine

Source: https://help.ubuntu.com/community/SettingUpNFSHowTo

With WIFI it's better to use Autofs:

We start by installing AutoFS:

sudo apt install autofs

We edit /etc/auto.master:

sudo nano /etc/auto.master

Content:

#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
#/misc  /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#       "nosuid" and "nodev" options unless the "suid" and "dev"
#       options are explicitly given.
#
#/net   -hosts
#
# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
#
#+dir:/etc/auto.master.d
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
#+auto.master

/media/nfs /etc/auto.nfs --ghost

Comment out (#) "+auto.master" and "+dir:/etc/auto.master.d" and add the lines at the bottom. I spent 2hours trying to get this to work and somehow it does not work without adding the --ghost option. If someone knows why please comment. Now /media/nfs is the dir that will contain your NFS shares (you dont have to create that, autofs does that for you) and /etc/auto.nfs is the configuration file for your shares. We will make that now:

sudo nano /etc/auto.nfs

Insert shares:

Backup      10.0.1.100:/Backup
Multimedia  10.0.1.100:/Multimedia

Now Backup the the dir 10.0.1.100:/Backup will take in /media/nfs.

Restart autofs:

sudo systemctl restart autofs

That's it, enjoy your shares.

5
  • thank you very much for your quick and understandable answer. taking in consideration what you and steeldriver above mentioned, i believe the ideal setup for me would still be to use autofs as that will only mount on demand. as i work on a latop it will be disconnected of the network which might cuase difficulties upon boot. mounting will only be neccesary when i want to access the files if i understand correctly what both of you said. this would be what autonfs is for? Feb 17, 2017 at 15:39
  • I have to do exactly this later today, I'll post how I do this. One more thing, does your laptop get the same ip address every time? How do you handle authentication?
    – Izzno
    Feb 17, 2017 at 17:51
  • thank you! yes all networke nodes have there ip assigned bij dhcp but resserve ip's outside the dhcp range for each MAC adress so they will be assigned there reserved ip, additional wifi contacts will get there ip within dhcp range by the the dhcp. is that what you mean by "how i handle authentification?" Feb 17, 2017 at 20:00
  • for now i added the two lines to fstab.. works like a charm, still thing ik would prefer the on demand thing. but for now i have a working system. thank you very much!! Feb 18, 2017 at 13:06
  • I updated the answer, you should have what you need :). Accept if your happy.
    – Izzno
    Feb 18, 2017 at 21:55
3

It's been a while since I've done this, but from what I remember the usual configuration is that the auto.master contains nothing but a location for the mount, and the name of a protocol-specific map file e.g.

In /etc/auto.master:

# configure nfs automount (for ad-hoc connection to local NAS) 
/nfs   /etc/auto.nfs

The map file /etc/auto.nfs would be something like:

# configure nfs automount (for ad hoc connection to local NAS)
* -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid,tcp 192.168.0.200:/Volume1/Public

If you are using Ubuntu 16.04 or later, the systemd way to reload the autofs maps seems to be

sudo systemctl reload autofs.service

or (if that's not enough)

sudo systemctl restart autofs.service

After that, the NAS volume should mount on demand e.g.

ls /nfs/Public

Note that if your numeric UIDs are not the same on the NAS and the local system, you may need to set up user mapping between the systems.

1
  • Thank you unce again steeldriver. I got the public folder working. something i forgot to mention in my question (well didn't forget. just thought it would be simple once i know the setup) is that i will need to mount another folder two. to make it more clear i will add this to the question. I tried to do this but what ever i do i get a folder with the Public content in there. Feb 17, 2017 at 22:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .