1

Ubuntu 18.04.1 LTS

I am having trouble exporting a directory from a USB drive. I have a number of exports similarly configured as to permissions and they are just fine.

Here is the error:

mount --bind /mnt/usb2T/inbox /export/inbox
mount: /export/inbox: mount(2) system call failed: No such file or directory.

And here are the directories involved in the issue:

The USB drive:

ls -la /mnt/
drwxrwxr-x  7 root users 4096 Sep 14 14:29 usb2T

successfully mounted to export as

/mnt/usb2T /export/usb2T nfs bind 0 0

and successfully exported and mounted by clients as

/export/usb2T 10.0.0.0/24(rw,nohide,insecure,no_subtree_check,async)

However when I try the same approach with a subdirectory of usb2T, I get into trouble:

ls -la /mnt/usb2T/inbox | wc -l
96

So it does exist and there are files there.

And so does the /export/inbox directory:

ls -la /export
drwxrwxr-x  0 root users    0 Sep 14 14:29 inbox
drwxrwxr-x  7 root users 4096 Sep 14 14:29 usb2T

Bind mount is attempted with this line in fstab:

/mnt/usb2T/inbox /export/inbox nfs bind 0 0

Why am I getting this error?

1 Answer 1

2

Ubuntu 18.04.1 LTS is new enough to use systemd, and systemd does not mount the filesystems listed in /etc/fstab with just a traditional mount -a.

Instead, it auto-generates a .mount-type systemd unit file for each /etc/fstab line, adds some default dependencies to those units, and then runs those units in parallel at boot time, basically as soon as possible.

The trick is, unless systemd is explicitly told that one mount depends on another being already done, there is no guarantee of any particular order. The ordering of /etc/fstab lines has no meaning, like it once might have had with mount -a.

Your second bind mount can only succeed if /mnt/usb2T is already mounted. To tell this requirement to systemd, you'll need to change its fstab line to this:

/mnt/usb2T/inbox /export/inbox nfs bind,x-systemd.requires=/mnt/usb2T 0 0

Or, depending on systemd version used, to this:

/mnt/usb2T/inbox /export/inbox nfs bind,x-systemd.requires-mounts-for=/mnt/usb2T 0 0

(Technically, on bind mounts, the filesystem type in the fstab line should probably be none instead of nfs, but I think that's ignored with bind mounts anyway.)

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .