First of all thank you for your time. I've been fighting for two days with this problem. I have the same environment in ubuntu 14.04 and is working perfect. So, let's start:

I want to mount a NFS at boot time. This NFS will have /etc/apache2 and other config folders. So, my fstab (working in 14.04) look like this:

X.X.X.X:/share_NFS         /mnt/nas        nfs   auto,nolock,soft,intr,nfsvers=3,tcp,bg,rw      0       0

Then, I bind every folder that I want to mount in the NFS like this:

/mnt/nas/config/apache2         /etc/apache2            none    auto,rbind,defaults     0       0

/mnt/nas/config/php5            /etc/php5               none    auto,rbind,defaults     0       0

/mnt/nas/config/logrotate.d     /etc/logrotate.d        none    auto,rbind,defaults     0       0

/mnt/nas/config/postfix         /etc/postfix            none    auto,rbind,defaults     0       0

/mnt/nas/www                    /var/www                none    auto,rbind,defaults     0       0

My problem: The problem is when I boot the machine. Sometimes it's mounted correctly and sometimes not. If I reboot the machine, I have 25% of probability that NFS is not mounted correctly. If I make a "mount -a" it mounts fine.

I'm almost certain that there is a systemd problem. I found a lot of problems and some bugs with NFS and remote-fs.target dependencies in systemd. But anyone has a clear a solution. For example, I changed some dependencies of remote-fs.target just to require network-online, but it didn't work for me.

i think that is a matter of how systemd start the remote-fs.target and NFS.

I noticed that for every mountpoint of /etc/fstab, systemd generates a unit ended with .mount. So, if I look for this units:

systemctl show mnt-nas.mount

I saw this:


Requires=system.slice -.mount


RequiredBy=etc-logrotate.d.mount etc-php5.mount remote-fs.target var-www.mount etc-apache2.mount etc-postfix.mount


Before=etc-logrotate.d.mount umount.target etc-php5.mount remote-fs.target var-www.mount etc-apache2.mount etc-postfix.mount

After=systemd-journald.socket remote-fs-pre.target system.slice network.target -.mount network-online.target


My questions: Has anyone had this problem? has anyone get this kind of behaviour mounting NFS at boot time? How you solved if you had?

Thank you very much!

  • 1
    I had same problem both on Ubntu Mate (RaspberryPi ) and Ubuntu16.04. Following solution solved it both- Read it carefully. raspberrypi.stackexchange.com/questions/13882/… . Guy – Guy . D Nov 22 '17 at 9:25
  • Thank you! I will check the link and I'll tell you something – jps88 Nov 22 '17 at 10:41
  • I've forgotten to say that I'm using ubuntu server, just in case. – jps88 Nov 22 '17 at 10:44
  • It worked on desktop and Mate. Give it a try. I’ll believe it’ll work – Guy . D Nov 22 '17 at 10:46
  • @Guy.D I solved the problem! Your link gave me a clue to resolve it. I'll post the solution now. Thank you very much! – jps88 Nov 22 '17 at 12:31

Well, finally I've solved the problem.

In this case, I had two problems:

  • By default, remote-fs.target is NOT depending on network-online.target . This is an known ¿bug? reported by the comunity. So, this si what makes that sometimes work and sometimes not (depends if ethernet has link or not when nfs is mounted).

  • Second problem, in my case, I mount rbinds after mount the NFS. The source of the rbinds is a folder of the NFS mountpoint (so, it's clear that is has to be mounted later). When systemd generates the ".mount" unit files for every mountpoint of the fstab, all rbinds were depending of local-fs.target. Of course, this is a problem in this case because it could mount the rbinds (local-fs.target) before the nfs mountpoint (remote-fs.target).

So, to solve this situation what I made is:

  • First, I edited the file /lib/systemd/system/remote-fs-pre.target and added:



  • Then, in /etc/fstab I indicated to the NFS mountpoint the next options:

    X.X.X.X:/nfs_share /mnt/nas nfs _netdev,noauto,x-systemd.automount,nolock,soft,intr,nfsvers=3,tcp,bg,rw 0 0

And finally, we indicate to systemd that rbinds are network device (so, systemd will put them on remote-fs.target) and also I indicated that /mnt/nas has to be mounted strictly.

/mnt/nas/config/php /etc/php none noauto,_netdev,x-systemd.automount,x-systemd.requires=/mnt/nas,rbind,defaults 0 0

With this change, I fix the order of launching the mounts propertly in systemd

  • 1
    Do not edit /lib/systemd files or you'll have a bad time. The correct solution is to add a drop-in, with systemctl edit remote-fs.target, and you only specify the properties to be changed. – OrangeDog Jul 11 '18 at 16:33
  • 1
    @OrangeDog I think you mean systemctl edit remote-fs-pre.target, and adding only the Wants=network-online.target and After=network-online.target lines to the override file (in /etc/systemd/system/remote-fs-pre.target.d/override.conf). See man systemctl for details. – Steeve McCauley Aug 10 '18 at 15:40
  • @SteeveMcCauley correct – OrangeDog Aug 10 '18 at 15:44

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.