Link to home
Start Free TrialLog in
Avatar of Dwight Baer
Dwight BaerFlag for Canada

asked on

Ubuntu - how to automatically mount a resource

On my desktop (ubuntu) client machine, I need to mount some resources that are found on a server.  I'd like this mount to happen every time the machine boots, automatically.
The command I'm running is:

(sudo) mount 10.10.1.57:/mnt/nfs/Desktop /mnt/nfs/mnt/nfs

Thanks
Avatar of arnold
arnold
Flag of United States of America image

which resources? you can use autofs
Avatar of Dwight Baer

ASKER

The resources are just a bunch of files I'd like people to be able to access.

So ... I installed autofs

And I found a procedure at https://www.linuxtechi.com/automount-nfs-share-in-linux-using-autofs/ 

Comments on that procedure?  Thumbs-up is all I think I need, it seems quite clear, thank you very much.
OK, I added the following in /etc/fstab:
10.10.0.57:/mnt/nfs/Desktop /mnt/nfs  nfs  defaults  0  0

Now the resources are automatically mounted when the machine boots.  Yeah ... I'm halfway there.  Now I just need it to automatically unmount before shutting down.  I'll dig into the autofs documentation again.
This will be mounted for all users, autofs can mount your specific path.
much depends on your need. you said you wanted your resource to be available on login.

in the path, you have a typo, do you really need to nest the things
/mnt/nfs/mnt/nfs
do these mount points exist?
/mnt
/mnt/nfs
/mnt/nfs/mnt
/mnt/nfs/mnt/nfs

often, if you need a resource of your own, you would create it as part of your home dir ~yourusername/mnt
once added run mount -a
this will trigger the mount of all things within the fstab without the need to reboot.
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think

Using the procedure at https://www.linuxtechi.com/automount-nfs-share-in-linux-using-autofs/ 

It involves:
1.  Adding the following line to /etc/auto.master:
/mnt/nfs  /etc/auto.nfsdb  --timeout=180

2.  Adding the following line to /etc/auto.nfsdb:
/mnt/nfs  -fstype=nfs4,r,soft/intr  10.10.0.57:/mnt/nfs/Desktop

3.  I started the autofs service:
sudo /etc/init.d/autofs start

But no joy ... it's not mounted.
Yeah!!!  

OK ... Thanks so much arnold for hanging in there.  It works.

I abandoned autofs.  No problem, I learned something.

mount -a worked.

And the key thing you said that was helpful was ... " no need for a special directive" - I'm assuming that it will unmount cleanly and properly when I do shutdown.

Thanks so much.
I agree ... no need for /mnt/nfs/mnt/nfs - I reduced it to /mnt/nfs
Thanks again