diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 2f56879d18..de3dc6a54c 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -617,6 +617,12 @@ main (int argc, char *argv[]) err (EXIT_FAILURE, "failed to prepare /var bind-mount at %s", var_dir); if (mount (var_dir, var_dir, NULL, MS_BIND | MS_REMOUNT | MS_SILENT, NULL) < 0) err (EXIT_FAILURE, "failed to make writable /var bind-mount at %s", var_dir); + /* Bind var back to its original place in /sysroot. This is for compatibility. */ + /* ostree does not use this anymore. We make this mount private to prevent propagation. */ + if (mount (var_dir, "../../var", NULL, MS_BIND | MS_SILENT, NULL) < 0) + err (EXIT_FAILURE, "failed to bind-mount /var to ../../var"); + if (mount (NULL, "../../var", NULL, MS_PRIVATE | MS_SILENT, NULL) < 0) + err (EXIT_FAILURE, "failed to make ../../var private"); /* When running under systemd, /var will be handled by a 'var.mount' unit outside * of initramfs.