Skip to content

Missing /sysroot/ostree/deploy/fedora/var bind mount after soft-reboot (cosmetic) #3519

@champtar

Description

@champtar

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

/* 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)
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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/prepare-rootIssue relates to ostree-prepare-root

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions