Skip to main content
Add information
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

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

  • 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

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

  • 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.

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

  • 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
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

Unreliable bind-mounts

On RHEL8-based system 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.

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?).