Skip to content

install: Support reinstallation (factory reset) #404

Open

Description

@cgwalters

#137 is tracking part of this, a lot of related discussion in coreos/fedora-coreos-tracker#399

Basically we should support something like bootc install factory-reset that would configurably wipe local system state.

On the implementation side...I think the best way to do this would be something like:

  • Create new deployment with fresh etc targeting a new stateroot
  • Boot into it
  • optional: clean up old deployment + stateroot

The beauty of this approach is that the "factory reset" would actually also be fully transactional, i.e. you could roll back into the previous state. It'd be easy to copy over any desired state (SSH host keys, cached container images e.g.) from the previous boot before deleting it.

Active work

Goals:

  • Make stateroots more visible, e.g. at least status should show them if different
  • Need to support explicit pruning of deployments e.g. bootc deployment rm (like ostree admin undeploy) so that I can get rid of old stateroots

Ideas:

  • Add bootc mount <deployment> /run/tmp-next-root so that I can cp -a --reflink=always /var/home /run/tmp-next/root/var/home

Activity

  1. added
    area/install
    enhancement
    on Mar 19, 2024
  2. changed the title [-]install: Support reinstallation[/-] [+]install: Support reinstallation (factory reset)[/+] on Mar 20, 2024
  3. cgwalters commented on Mar 20, 2024

    @cgwalters
    MemberAuthor

    BTW one tricky thing in this is kernel arguments...cc #401

    And also related to this, we should probably go to some effort to preserve the original kargs.


    An entirely different way to implement this would be to retain a pinned version of the original installed deployment. Some people will want to do that, and we already effectively support it with ostree admin pin. However...rolling back to that in the general case will imply rolling back to something pretty outdated, which we don't want to encourage. So I think we should focus more on better capturing and maintaining the bits of state that we want from that which mostly I think boils down to kargs.

  4. cgwalters commented on Sep 4, 2024

    @cgwalters
    MemberAuthor

    One question came up tangentially related to this too - why does the current install integration test suite not work on an ostree based system?

    First there's two things; the to-disk code; that works everywhere, it's easy we just use loopback.

    For the alongside install tests, it's basically because of this. We'd need to be sure to use an alternative stateroot vs the booted one, etc.

  5. vrothberg commented on Oct 10, 2024

    @vrothberg
    Contributor

    I'd love to have such a reset functionality for bootc-{switch,update} as well.

  6. kfox1111 commented on Oct 16, 2024

    @kfox1111

    Maybe an option to reset state on just a single file in etc or a path under etc too, rather then a complete reset.

  7. Malix-Labs commented on Jan 10, 2025

    @Malix-Labs

    Hello folks, is there a clear path of what to do next to make this happen?

  8. cgwalters commented on Jan 17, 2025

    @cgwalters
    MemberAuthor

    So #137 landed some important preparatory code here. However...that's covering the "reinitialize system from a different bootc container image". What we obviously could streamline is the flow of "reinitialize system from the booted image".

    Probably something like bootc install to-existing-root --from-booted? And we need to bikeshed what state preservation options we support.

  9. added
    area/etc-var
    on Mar 28, 2025
  10. imbev commented on Jun 5, 2025

    @imbev
    Contributor

    How should /home and /etc/passwd be handled?

  11. cgwalters commented on Jun 30, 2025

    @cgwalters
    MemberAuthor

    Opened #1389 for this

  12. cgwalters commented on Jun 30, 2025

    @cgwalters
    MemberAuthor

    How should /home and /etc/passwd be handled?

    I think in the core design (as used by #1389) it's ~trivial to copy over whatever state one wants from the previous root. But it'd definitely be nice to add some sugar for this.

  13. cgwalters commented on Aug 4, 2025

    @cgwalters
    MemberAuthor
  14. mrguitar commented on Aug 4, 2025

    @mrguitar
    Contributor

    But it'd definitely be nice to add some sugar for this.

    I'm trying to think of areas users may hurt themselves with this. I'm not sure we can add sugar for everything, but I agree w/ @imbev that users & /home dirs are a good starting point. Other contenders could be fstab or mount unints, host ssh keys (probably not that important), Networking (static IPs or bonds), hostname? I wish we had a clean way to reapply whatever anaconda did and/or cloud-init. In lieu of that, maybe some command flags to preserve some things items will help w/ foot guns. $0.02

  15. imbev commented on Aug 4, 2025

    @imbev
    Contributor

    But it'd definitely be nice to add some sugar for this.

    I'm trying to think of areas users may hurt themselves with this. I'm not sure we can add sugar for everything, but I agree w/ @imbev that users & /home dirs are a good starting point. Other contenders could be fstab or mount unints, host ssh keys (probably not that important), Networking (static IPs or bonds), hostname? I wish we had a clean way to reapply whatever anaconda did and/or cloud-init. In lieu of that, maybe some command flags to preserve some things items will help w/ foot guns. $0.02

    Anaconda could be used with the /root/anaconda-ks.cfg generated by the initial installation, but that is an additional dependency.

    I agree about the value of the factory reset having flags and file config options for each part.

  16. cgwalters commented on Aug 5, 2025

    @cgwalters
    MemberAuthor

    Note that in the current design we will always default to a nondestructive factory reset by creating a new stateroot. Then users are required to clean up the prior stateroot when they're happy. If it doesn't work, then a rollback into the previous deployment undoes everything.

  17. mrguitar commented on Aug 5, 2025

    @mrguitar
    Contributor

    Yeah I get that. I think we both want to avoid users resetting their systems, rebooting, and not being able to log in. :) Is the sugar you were thinking of doing the copy for the user? Or were you thinking it could work differently?

  18. cgwalters commented on Sep 8, 2025

    @cgwalters
    MemberAuthor

    My instinct here is to land some experimental form of this ASAP and gather feedback from ~real world experience.

  19. cgwalters commented on Sep 11, 2025

    @cgwalters
    MemberAuthor

    Anaconda could be used with the /root/anaconda-ks.cfg generated by the initial installation, but that is an additional dependency.

    Yes! We had a team chat around this issue and for sure it'd be awesome to have Anaconda be useful in this setup to do a reinstallation into a new stateroot.

    In theory we could have something like factory reset plugins /usr/lib/bootc/factory-reset.d or something that could help guide users who did an install with anaconda to also do a factory reset that way? Or well, a fedora-derivative feature flag that

    bootc-image-builder/osbuild are not really designed for this, but maybe could be reworked to do so.

  20. cgwalters commented on Sep 22, 2025

    @cgwalters
    MemberAuthor

    Ideally we minimize "magic" here; admins should know where the data is coming from and why it's preserved.

  21. cgwalters commented on Sep 22, 2025

    @cgwalters
    MemberAuthor

    As far as "being able to log in", one pattern we use for https://github.com/bootc-dev/bcvk (and is also used by podman-bootc) is https://github.com/bootc-dev/bcvk/blob/aae33b4a252fea309bd38bfd3dba992187656b22/crates/kit/src/sshcred.rs#L16 where we use systemd credentials to add a tmpfiles.d unit that injects a SSH key via SMBIOS (virt level creds). Notably, factory reset at the bootc level won't get rid of that key.

  22. ScatteredCognition commented on Sep 29, 2025

    @ScatteredCognition

    How should /home and /etc/passwd be handled?

    I'm not a dev, just a hobbyist, but I'd like to provide my thoughts regarding the matter.
    Atleast on Silverblue with OStree, when I attempted a "Factory Reset" (see this) the GNOME OOTB/firstboot wizard appeared just like during the first boot after a fresh install and all the relevant files were auto-generated.

    Instead of copying/migrating files like /etc/passwd, bootc or another program could provide a firstboot/OOTB experience.
    I was thinking something like a systemd service like bootc-firstboot.service, which checks for a file named /etc/bootc-firstboot-complete (could be another file) and if it doesn't exist, prompts the user to configure their locale, keyboard layout and setup users just like the GNOME OOTB/firstboot wizard, or maybe even prompt the user for a "setup file" that contains all that information.

  23. cgwalters commented on Sep 29, 2025

    @cgwalters
    MemberAuthor

    I was thinking something like a systemd service like bootc-firstboot.service,

    What would it provide over systemd-firstboot and gnome-initial-setup (and other tools like Ignition or cloud-init)?

    Now one issue right now is the Fedora bootc base image has this https://gitlab.com/fedora/bootc/base-images/-/blame/main/minimal/manifest.yaml#L18 but that's effectively a legacy bug. Though changing it would require analysis of consumers.

  24. ScatteredCognition commented on Sep 29, 2025

    @ScatteredCognition

    I was thinking something like a systemd service like bootc-firstboot.service,

    What would it provide over systemd-firstboot and gnome-initial-setup (and other tools like Ignition or cloud-init)?

    systemd-firstboot is exactly what I was describing. I thought something like this didn't exist as other spins like Kinoite and such couldn't survive --no-merge "Factory Reset" deployments.

  25. cgwalters commented on Jul 2, 2026

    @cgwalters
    MemberAuthor

    I think bootc install factory-reset --print-etc-diff might be a good replacement for ostree admin config-diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/etc-vararea/installenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions