Skip to content

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?

0 points7 comments
Open on Reddit
About this post
Posted
Archived
Score
0 · 100% up
Kind
Text
ID
3bey2b

Author

6
posts
85
comments
0
media
View profile

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.

my-server:/music  /run/autofs/music nfs4  noauto,x-systemd.automount,x-systemd.idle-timeout=30   0 0

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.

3 points

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.

1 points

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.

1 points

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.

2 points

That makes sense but I still can't see the network folders in my file manager unless I cd into them using the terminal.

1 points

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).

1 points
unknown author

Deleted before we saved it.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.