Mount NAS drive Every time at Startup

12,300

Solution 1

As per exchange with steeldriver above,I got the usual way to work:

I just followed this link more or less exactly reused the fstab entry but with the ip of my drive and mounting to subset of media: How can I mount an NFS drive via fstab

Apologies in that case for the repeat of question - I'd tried following fstab guides including a couple on here and just not got it to work... not sure what I could have been doing wrong...

Solution 2

This is how I set up the /etc/fstab for my disk:

<ip>:/nfs     /media/<mountpoint>   nfs     rw,suid,dev,exec,user,sync,_netdev,user=1000,x-systemd.after=network-online.target,x-systemd.device-timeout=5s,x-systemd.automount      0       0

This autoconnect on every startup after I have Wifi connectivity with a timeout of 5s.

One issue I experience is that login into my machine outside my home network it takes longer time because the disk mount fails.

Share:
12,300

Related videos on Youtube

DanBennett
Author by

DanBennett

Updated on September 18, 2022

Comments

  • DanBennett
    DanBennett over 1 year

    this is similar to some other Qs here, but I'd not been able to get any of those to work, even just to mount the drive, let alone mount it every time.

    I have had some success with this guide - I have the exact same drive http://www.huffingtonpost.com/dulio-denis/wd-my-cloud-nas-on-ubuntu_b_5121961.html

    It works pretty well for me at least in terms of mounting a drive by running a command at terminal. I ended up with this slightly modified command:

    sudo mount -o soft,intr,rsize=8192,wsize=8192 192.168.1.5:/nfs /media/nfs/
    

    However, I can't get this to connect automatically on startup I've basically stuck the command in a file ConnectNAS.conf that i've saved in /etc/init/

    script looks like this

    script
    sleep 10
    sudo mount -o soft,intr,rsize=8192,wsize=8192 192.168.1.5:/nfs /media/nfs/
    script
    

    So far as I can tell, that script does absolutely nothing. Any suggestions?

    • steeldriver
      steeldriver over 8 years
      The usual way to mount drives persistently (i.e. every time on startup) is via the system's /etc/fstab file: see How can I mount an NFS drive via fstab for example
    • DanBennett
      DanBennett over 8 years
      Thanks! Worked this time. I guess I got my details right this time where I hadn't before. Will post details below.