Zend certified PHP/Magento developer

Wait for USB mount before starting NFS server on a Raspberry Pi Zero 2 (zero2w) with Raspbian?

I have Raspberry Pi Zero 2 (zero2w) with Raspbian x32 installed and attached USB SSD drive which main purpose is to act as a network (image) backup server for several other devices (all Raspberry Pis – Linux).

What actually keeps me from properly implementing my idea is nfs-server (nfs-kernel-server.service) obviously not being able to properly start upon (re)boot on this small scale backup server giving me the following error

systemctl status nfs-kernel-server.service
nfs-server.service - NFS server and services
Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code)
Process: 434 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)
Process: 437 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
Process: 438 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)

Jan 10 16:13:47 zero2w-ImageBackupper systemd[1]: Starting NFS server and services...
Jan 10 16:13:47 zero2w-ImageBackupper exportfs[434]: exportfs: Failed to stat <NFSSHAREPATH1>
Jan 10 16:13:47 zero2w-ImageBackupper exportfs[434]: exportfs: Failed to stat <NFSSHAREPATH2>
Jan 10 16:13:47 zero2w-ImageBackupper systemd[1]: nfs-server.service: Control process exited, code=exited, status=1/FAIL
Jan 10 16:13:47 zero2w-ImageBackupper systemd[1]: nfs-server.service: Failed with result 'exit-code'.
Jan 10 16:13:47 zero2w-ImageBackupper systemd[1]: Stopped NFS server and services.

I’ve searching around and found several possible solutions including:

  1. Finding out name of the USB mount unit with systemctl list-units --type=mount

  2. Adding the following into /lib/systemd/system/nfs-kernel-server.service (one at the time)

    After=multi-user.target <MOUNTUNITNAME>.mount
    After=network.target <MOUNTUNITNAME>.mount
    After=storage.mount
    RequiresMountsFor=<NFSSHAREPATH>
    
  3. I’ve found out this post on the Unix & Linux SE site where someone had the same problem and obviously solved it by editing data.mount file but I simply coundn’t find this file on Raspbian.

  4. Tried searching for <MOUNTUNITNAME>.mount (output from step 1.) file since systemctl show <MOUNTUNITNAME>.mount returns quite a lot but I simply couldn’t find it (I’m not that kind of an expert but I guess this is something generated on the fly?)

    But nothing of the above works!

  5. Haven’t tried but also reported not to be working (reported by the same person on the link provided above) is editing /etc/fstab with x-system.d.before=nfs-server.service in fstab file: UUID=<UUID> /data auto nosuid,nodev,nofail,x-gvfs-show,x-system.d.before=nfs-server.service 0 0 and x-system.d.before=nfs-kernel-server.service

Could please someone help me out to figure how to make nfs-kernel-server.service to wait for USB SSD to be mounted before starting so clients could properly pick up network mount points and properly process backups?