Auto mounting NFS shares via autofs without cd
I have a home network that I access using NFS via autofs. It all works well but in order to make the network folders visible I need to cd into them in the terminal, like this:
cd /mnt/192.168.0.10
Is there a way to automate this, so when the computer starts this is taken care of?
About this post
- Posted
- Archived
- Score
- 0 · 100% up
- Kind
- Text
- ID
- 3bey2b
8 comments
You should try using systemd's features to do this. I was using autofs for quite some time because I wanted the automatic unmount feature. But the latest systemd versions are able to do this as well.
So the above will automatically create the path /run/autofs/music and will only mount the nfs share when it is actually accessed (noauto,x-systemd.automount). Once nothing has been accessing this share for thirty seconds, it will be automatically unmounted (x-systemd.idle-timeout=30). Then I have ~/Music/server as a symlink pointing to /run/autofs/music for easy access.
Really interesting suggestion, it was because of the automount that I was using autofs - my restart and shutdown would hang when I tried mounting via fstab.
Indeed, this is why I was using the autofs package as well. I just needed it to unmount because I would forget every time to do it manually before shutdown.
that is how autofs works. you don't need to cd anywhere. the first time it is used by anything, it will be mounted. if you really wanted to you could turn off the nobrowse option, but the only difference will be cosmetic.
That makes sense but I still can't see the network folders in my file manager unless I cd into them using the terminal.
What file manager are you using? As autofs only connects drives when you need them, they won't show in the file manager until you somehow reference them. If you use a file manager with favourites you could just set up a favourite linking to the drives. You could also type the drive location in full in the file manager (eg CTRL L in nautilus, not sure on others).
Deleted before we saved it.