Brainstorm: How to solve issues in the mutable directories?

Related OSTree factory reset issue

On the atomic versions, /etc is mutable. /var too, but this may be more complex and less troublesome.

The default /etc lives in /usr/etc, while the mutable /ostree/deploy/fedora/<ID>/deploy/etc is linked to /etc.

Users can completely mess up their systems, example: overwrite some random files, like

# editing
/etc/systemd/resolved.conf
# instead of 
/etc/systemd/resolved.conf.d/some-override.conf

(spare me, I did that once)


Show the diffs

Docs page

sudo ostree admin config-diff

or with more detail

sudo diff -yrW200 --suppress-common-lines --color=always /usr/etc /etc 2>/dev/null
1 Like

Doesn’t /etc also live (from the release image) in /var/lib or /usr/lib` on the atomic system?

1 Like

I’m fairly new to ostree, but here are my thoughts.

It should be possible to see the difference between the default config and the current deployment using ostree admin config-diff. It will show which files are modified, new or deleted.

The default configuration can be found inside /usr/etc, so using diff on /etc and /usr/etc should also work.

What you are trying to do here sounds much like this github issue. From what I understand doing something like this should already be possible using ostree admin deploy and --no-merge. No idea what the exact command for that would be though.

Using rsync to copy the default config into the /etc directory should also work. See this comment from cgwalters.

4 Likes

yes, this is the solution. I think adding such a feature to rsync those default settings might be good for usability? Even though it sounds like this is possible without.

so the rsync should be a reliable and perfect solution, as that one is upstream and immutable. I wonder if that could be added to rpm-ostree, or if that would not be possible

I don’t think that rsync is a perfect solution. There are files that shouldn’t be deleted (fstab, crypttab) or the system doesn’t remain bootable. A reset command should probably have a build in list with files to keep. Using rsync will also modify the current deployment which isn’t great, it would be better to create a new one with the restored /etc so it is easy to rollback.

So I think that seeing the difference is possible, but doing a complete reset isn’t yet. It is possible, but you would need to carefully look at the diff and keep the important files. Would probably be interesting to have a full list of files that should be kept. After that we could probably create a script that does the reset.

Here are some github issues for coreos, silverblue and ublue for the reset feature.
coreos: Add factory reset capability · Issue #399 · coreos/fedora-coreos-tracker · GitHub
silverblue: Implement factory reset capability · Issue #337 · fedora-silverblue/issue-tracker · GitHub
ublue: Investigate a state reset feature · Issue #95 · ublue-os/main · GitHub

1 Like

Good points. I think it would be beneficial to document that diff command, and maybe a few more.

I think this would fit well in the desktops, but I dont know how many sites are symlinked/shared, or if it should be in coreOS etc.

1 Like

I searched the docs and the ostree admin config-diff command is already documented in the silverblue docs.

Also has this neat command to show the diff with more details:

 sudo diff -yrW200 --suppress-common-lines --color=always /usr/etc /etc 2>/dev/null
2 Likes

There is also the very excellent libostree documentation at libostree | ostreedev/ostree and of course the rpm-ostree documentation found at A true hybrid image/package system | rpm-ostree
And libostree would need to “know” what is different in order to perform the three-way merge that creates the local commit.

2 Likes

the last one is especially useful!

I really like utils like “cheat” which present an opinionated, small subset of commands.

Is maintaining a page like that in scope of Fedora?

cat >> ~/.config/fish/functions/custom-functions.fish <<EOF
function cheat
  curl cheat.sh/$argv[1]
end
EOF
$ cheat rpm-ostree
# rpm-ostree
# A hybrid image/package system.
# Manage ostree deployments, package layers, filesystem overlays, and boot configuration.
# More information: <https://coreos.github.io/rpm-ostree/administrator-handbook/>.

# Show rpm-ostree deployments in the order they will appear in the bootloader:
rpm-ostree status

# Show packages which are outdated and can be updated:
rpm-ostree upgrade --preview

# Prepare a new ostree deployment with upgraded packages and reboot into it:
rpm-ostree upgrade --reboot

# Reboot into the previous ostree deployment:
rpm-ostree rollback --reboot

# Install a package into a new ostree deployment and reboot into it:
rpm-ostree install package --reboot
cheat ostree                                                                                                                                                             master ◼
# ostree
# Version control for binary files similar to git but optimized for operating system root filesystems.
# OSTree is the foundation for immutable image-based operating systems such as Fedora Silverblue, Fedora IoT or Fedora CoreOS.
# More information: <https://ostreedev.github.io/ostree>.

# Initialize a repository of the files in `$PWD` with metadata in `$PWD/{{path/to/repo}}`:
ostree init --repo path/to/repo

# Create a commit (snapshot) of the files:
ostree commit --repo path/to/repo --branch branch_name

# Show files in commit:
ostree ls --repo path/to/repo commit_id

# Show metadata of commit:
ostree show --repo path/to/repo commit_id

# Show list of commits:
ostree log --repo path/to/repo branch_name

# Show repo summary:
ostree summary --repo path/to/repo --view

# Show available refs (branches):
ostree refs --repo path/to/repo