Skip to content

Commit

Permalink
prepare-root: bind mount var under deployment for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihe774 committed Jan 2, 2025
1 parent d472e60 commit 0824da8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/switchroot/ostree-prepare-root.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0824da8

Please sign in to comment.