1

On a RHEL8-based virtual machine running systemd 239, I have the following bind-mount setup:

  • a filesystem (identified via UUID) mounted to a "source" mount-point (/path/to/sourcemnt)
  • multiple sub-directories on that "source" mount-point:
    /path/to/sourcemnt/dirA /path/to/sourcemnt/dirB /path/to/sourcemnt/dirC 
  • bind-mounts for each sub-directory to "target" mount-points

The fstab looks like this:

# auto-generated entries for 'sourcemnt' UUID=<...> /path/to/sourcemnt ext4 defaults 1 2 # manually added entries for bind mounts /path/to/sourcemnt/dirA /path/to/targetmnt/dirA none bind,x-systemd.requires=/path/to/sourcemnt 0 0 /path/to/sourcemnt/dirB /path/to/targetmnt/dirB none bind,x-systemd.requires=/path/to/sourcemnt 0 0 /path/to/sourcemnt/dirC /path/to/targetmnt/dirC none bind,x-systemd.requires=/path/to/sourcemnt 0 0 

The Problem

Not all of the bind-mounts are automatically mounted during boot. This can be seen from the ownership/permissions of the mount-points as well as output of findmnt and mountpoint commands.

  • The journalctl output doesn't contain error messages trying to mount the "failed" bind-mounts, they are simply never mentioned. Only the successfully mounted bind-mounts are mentioned in the usual way:
    <Date> <Hostname> systemd[1]: Mounting /path/to/sourcemnt... ... <Date> <Hostname> systemd[1]: Mounted /path/to/sourcemnt. <Date> <Hostname> systemd[1]: Mounting /path/to/targetmnt/dirB... ... <Date> <Hostname> systemd[1]: Mounted /path/to/targetmnt/dirB. 
  • Manually mounting them (as root) works.
  • The number of "failing" bind-mounts is not consistent on re-boot. Sometimes only one is missing, sometimes two, but at least one is always successfully mounted.
  • Changing the order in which the bind-mounts are specified in the fstab doesn't change which of them are mounted and which are not.
  • It seems that the one lexicographically in the middle of the sort-order (dirB) is always there, dirA sometimes and dirC only after a hard restart (if at all) - but I didn't try often enough to say for sure.
  • The same setup still worked as of RHEL7

This looks like a timing problem/race condition, but how can I ensure that all bind-mounts are present? I even tried to "cascade" the mount-requirements as in

/path/to/sourcemnt/dirA /path/to/targetmnt/dirA none bind,x-systemd.requires=/path/to/sourcemnt 0 0 /path/to/sourcemnt/dirB /path/to/targetmnt/dirB none bind,x-systemd.requires=/path/to/targetmnt/dirA 0 0 /path/to/sourcemnt/dirC /path/to/targetmnt/dirC none bind,x-systemd.requires=/path/to/targetmnt/dirB 0 0 

but that also didn't help (that said, why should it in the first place?).

1 Answer 1

0

I was seeing a similar problem, but in my case the source disk was mounted via NFS.

I was sometimes seeing dependency loops at bootup which would cause other services to fail (eg named-chroot).

In the end I was unable to fix it so I cheated. I created an rc.local script that waited until the source was available and then did the bind mounts there.

m() { cnt=0 while [ ! -e $1 -a $cnt -lt 10 ] do sleep 1 cnt=$((cnt+1)) done mount -o bind -r $1 $2 } m /datadisk/netboot/kvm/boot /var/lib/tftpboot/9cdc29af m /datadisk/netboot/econet-bridge/boot /var/lib/tftpboot/661b168a 

Messy, but it works!

1
  • In the end, I did the same ;) It would still have been nice to figure out what caused the problem, though ... Commented Oct 21, 2024 at 11:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.