-
Notifications
You must be signed in to change notification settings - Fork 335
Description
While working on #3518, I found an inconsistency with the soft-reboot mounts.
In ostree-prepare-root we prepare an rw bind mount for /sysroot/ostree/deploy/fedora/var
ostree/src/switchroot/ostree-prepare-root.c
Lines 328 to 338 in 72e896a
| /* Prepare /var. | |
| * When a read-only sysroot is configured, this adds a dedicated bind-mount (to itself) | |
| * so that the stateroot location stays writable. */ | |
| if (sysroot_readonly) | |
| { | |
| /* Bind-mount /var (at stateroot path), and remount as writable. */ | |
| if (mount ("../../var", "../../var", NULL, MS_BIND | MS_SILENT, NULL) < 0) | |
| err (EXIT_FAILURE, "failed to prepare /var bind-mount at %s", srcpath); | |
| if (mount ("../../var", "../../var", NULL, MS_BIND | MS_REMOUNT | MS_SILENT, NULL) < 0) | |
| err (EXIT_FAILURE, "failed to make writable /var bind-mount at %s", srcpath); | |
| } |
but in ostree-soft-reboot we only bind mount
/sysroot (no AT_RECURSIVE)ostree/src/libostree/ostree-soft-reboot.c
Lines 86 to 95 in 72e896a
| struct mount_attr attr = { .attr_set = MOUNT_ATTR_RDONLY }; | |
| glnx_autofd int sysroot_fd | |
| = open_tree (AT_FDCWD, sysroot_path, OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC); | |
| if (sysroot_fd < 0) | |
| return glnx_throw_errno_prefix (error, "open_tree(%s)", sysroot_path); | |
| if (mount_setattr (sysroot_fd, "", AT_EMPTY_PATH, &attr, sizeof (struct mount_attr)) < 0) | |
| return glnx_throw_errno_prefix (error, "syscall(mount_setattr) of sysroot"); | |
| g_autofree char *target_sysroot = g_build_filename (OTCORE_RUN_NEXTROOT, "sysroot", NULL); | |
| if (move_mount (sysroot_fd, "", -1, target_sysroot, MOVE_MOUNT_F_EMPTY_PATH) < 0) | |
| return glnx_throw_errno_prefix (error, "syscall(move_mount) of sysroot"); |
so we do not copy this bind mount.
I think this bind mount is historical, using old systemd/mount (that use the old mount API), a mount unit with Options=bind,rw,slave,shared, rw is ignored, this is still the case with EL 9 but with newer systemd/mount (new mount API / Fedora), rw works.
Right now soft-reboot + no separate /var filesystem still works because of ostree-remount
ostree/src/switchroot/ostree-remount.c
Line 308 in 72e896a
| do_remount ("/var", true); |
I would prefer to drop this unneeded bind mount, add rw in the mount unit and let ostree-remount save us for EL 9, but I'm open to comments on how to clean this