Skip to content

Commit

Permalink
rpm-ostree: Setup readonly sysroot for ostree & rw karg
Browse files Browse the repository at this point in the history
- Enable read only sysroot in the ostree repo config.
- Add `rw` to the kernel arguments to keep statefull parts of the system
  (/var & /etc) writable.
- Update units tests to account for the new rw karg

(cherry-picked from a commit 0e00c90)

Related: RHEL-2250
  • Loading branch information
travier authored and poncovka committed Jan 26, 2024
1 parent 6dfbab2 commit 853f583
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion pyanaconda/modules/payloads/payload/rpm_ostree/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ def _set_kargs(self):
if root_data.type == "btrfs subvolume":
set_kargs_args.append("rootflags=subvol=" + root_name)

set_kargs_args.append("rw")

safe_exec_with_redirect("ostree", set_kargs_args, root=self._sysroot)


Expand Down Expand Up @@ -515,7 +517,18 @@ def run(self):
self._data.remote + ':' + ref]
)

log.info("ostree deploy complete")
log.info("ostree config set sysroot.readonly true")

safe_exec_with_redirect(
"ostree",
["config",
"--repo=" + self._sysroot + "/ostree/repo",
"set",
"sysroot.readonly",
"true"]
)

log.info("ostree admin deploy complete")
self.report_progress(_("Deployment complete: {}").format(ref))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def test_btrfs_run(self, devdata_mock, storage_mock, symlink_mock, rename_mock,
exec_mock.assert_called_once_with(
"ostree",
["admin", "instutil", "set-kargs", "BOOTLOADER-ARGS", "root=FSTAB-SPEC",
"rootflags=subvol=device-name"],
"rootflags=subvol=device-name", "rw"],
root=sysroot
)

Expand Down Expand Up @@ -661,7 +661,7 @@ def test_nonbtrfs_run(self, devdata_mock, storage_mock, symlink_mock, rename_moc
)
exec_mock.assert_called_once_with(
"ostree",
["admin", "instutil", "set-kargs", "BOOTLOADER-ARGS", "root=FSTAB-SPEC"],
["admin", "instutil", "set-kargs", "BOOTLOADER-ARGS", "root=FSTAB-SPEC", "rw"],
root=sysroot
)

Expand Down

0 comments on commit 853f583

Please sign in to comment.