fstab does not mount automatically a NFS remote folder

25,208

Solution 1

If your mount -a option works then you should add _netdev in fstab.

192.168.1.1:/home/export /home/import/server1 nfs defaults,_netdev 0 0

Also make sure for "chkconfig netfs on"

Solution 2

  1. Create a file at: /etc/network/if-up.d/fstab

  2. Add this to it:

    #!/bin/sh
    mount -a
    
  3. Make the file executable:

    sudo chmod +x /etc/network/if-up.d/fstab
    

You are directing the system at boot time to issue a mount -a after the network stack is up and operation which if it's like a cifs mount in fstab is the reason your shares are not mounting at boot.

From this answer: nfs shares in /etc/fstab not loaded on boot in 18.04 at Ubuntu forums.

Share:
25,208

Related videos on Youtube

XavierStuvw
Author by

XavierStuvw

Proficiency, competence and ambitions of an educated layman, interested in much, expert in little Some experience with programming in FORTRAN, C++, Matlab/Octave, Python and R. Using Linux since 2014 and committed to it I like it when a computer does what I want. It's a creative accomplishment where knowing what I want and wanting what I know come together Happy to help and to be corrected

Updated on September 18, 2022

Comments

  • XavierStuvw
    XavierStuvw 2 months

    I do not manage to get a remote directory automatically mounted during bootstrap. I am using the NFS protocol under Ubuntu 14.04 LTS. The server is 192.168.1.1 and the client is 192.168.1.2

    The setting in /etc/exports at the server side is

    /home/export 192.168.1.2(ro,no_root_squash,sync)

    Although the \home\user directory at the client side is, note that all directories mentioned in this post are not encrypted. The server computer is always on, and the two machines can ping each other. Also note that, in both machines, the \home directory is mounted on an own partition.

    The command line works well and I can see the remote content at the mount point after sudo mount 192.168.1.1:/home/export /home/import/server1.


    Like in How to edit /etc/fstab properly for network drive? I want to mount a network drive by editing /etc/fstab. However, when I add any one of those lines to /etc/fstab

    [1] 192.168.1.1:/home/export /home/import/server1 nfs rsize=8192,wsize=8192,timeo=14 0 0

    [2] 192.168.1.1:/home/export /home/import/server1 nfs auto 0 0

    [3] 192.168.1.1:/home/export /home/import/server1 nfs auto, rsize=8192,wsize=8192,timeo=14 0 0

    [4] 192.168.1.1:/home/export /home/import/server1 nfs defaults 0 0

    I need to launch a sudo mount -a manually to get the view on the server side. This defies my expectations and those from this U&L post as well.

    How can I get the auto-mounting capability running on its own feet?


    Inspirations/copy-catting disclosed:

    [1] https://help.ubuntu.com/14.04/serverguide/network-file-system.html

    [2] https://help.ubuntu.com/community/SettingUpNFSHowTo#Mounting_NFS_shares_in_encrypted_home_won.27t_work_on_boot

    [3] = [1] + [2]

    [4] mimicking the mount options of the local device partitions in etc/fstab

  • Sagar
    Sagar almost 6 years
    Please share your boot logs. _netdev is for network device and mounts the device once network service is up.
  • Sagar
    Sagar almost 6 years
    Also share output of "tail -1 /etc/mtab " after firing sudo mount -a.