Skip to content

Add factory reset capability #399

Open

Description

@bgilbert

Under the immutable infrastructure model, we encourage users to handle config changes by reprovisioning their systems, rather than using configuration management or manually modifying the running system. This is okay in virtualized setups or in the cloud, and is also okay on bare metal where PXE infrastructure or IPMI-assisted ISO boot is available. But on single-node bare metal setups without external infrastructure, manual reinstall is impractical. (See e.g. this discussion.)

For this use case, it might help to have a command which receives an Ignition config to use for reprovisioning, copies it into /boot, sets first-boot kargs, and reboots. Then the initramfs, before running the usual first-boot steps, would need to restore the system to a pristine state. That process might look a lot like #94, or might look more like clearing /var and resetting /etc from /usr/etc. If those are in non-standard locations, perhaps the user-mode command could add kargs which tell the initramfs where to find them.

Because we'd be deleting user customizations before rerunning Ignition, this approach wouldn't[*] get into unsupported territory of using Ignition for configuration management. It would slightly complicate OS maintenance, though. At present we can freely change the Ignition initrd glue in ways that are incompatible with old installs (e.g. by changing first-boot kargs) because old installs will never run Ignition again. Supporting factory reset of old nodes would presumably add some additional constraints.

[*] Presumably it'd be infeasible to delete every possible user customization, so that statement might be optimistic.

Activity

  1. bgilbert commented on Feb 27, 2020

    @bgilbert
    ContributorAuthor

    Discussed in the community meeting today.

    • If we committed the Ignition config to the ostree repo, that could make this a bit easier.
    • coreos-installer used to be in the initramfs, which technically allowed every system to reinstall itself outright (assuming network access). We could investigate running the new coreos-installer from the initramfs again, but it requires lsblk, udevadm, and gpg.
    • We've discussed splitting the live PXE root squashfs out to a separate stage2 (Publish the initrd and rootfs images separately for PXE booting #390) which could be useful here: assuming network access, the existing installed kernel and initrd could boot themselves into a live PXE image and rerun coreos-installer from there. That doesn't let air-gapped systems reprovision without external assistance, though.
      • Assuming network access, we could also fetch the image before the reboot and stash it somewhere on disk. But if the install fails and overwrites the image in the process, you don't get a second chance.
      • To solve the air-gapped case, we could: 1) before reboot, assemble a live squashfs from the ostree we already have, 2) from the initramfs, mount the old root filesystem and copy the squashfs into RAM, 3) create a temporary partition at the end of the disk and copy the squashfs into it for safety, 4) run coreos-installer, and if it fails, recreate /boot and the safety partition, 5) reboot into the new system. That's complex though.
    • We didn't explore it in the meeting, but rerunning coreos-installer is not mandatory if there's a good way to delete user customizations from the existing system. We probably won't be able to get the system to 100% pristine state though.

    There was a general sense that the feature would be nice, but there was also concern about implementation complexity depending on the approach taken.

  2. jlebon commented on Mar 19, 2020

    @jlebon
    Member

    Note with the stage 2 approach, as long as the stage 2 binary is the initrd we append to the base one, it should contain both the osmet file and the root squashfs, so it should be possible to do the re-install completely offline.

  3. jlebon commented on Apr 17, 2020

    @jlebon
    Member

    Related OSTree issue: ostreedev/ostree#1793

  4. cgwalters commented on May 22, 2020

    @cgwalters
    Member

    Also, if we shipped the .osmet file in e.g. /sysroot/fcos.osmet, then we could always support a factory reset back to the aleph image. If we wanted to support reset back to the current ostree commit we'd need a tool to fetch it out of band.

    (This all said I think a lot of cases are going to be happy enough with the "ostree level" factory reset and not "wipe and replace disk image", particularly because the former can be made transactional)

  5. cgwalters commented on Apr 9, 2021

    @cgwalters
    Member

    As is today, it will work in many basic scenarios to just do:

    $ unshare -m /bin/sh -c 'mount -o remount,rw /boot && touch /boot/ignition.firstboot'
    $ reboot
    

    A much stronger version would look like touch /run/factory-reset and we go back into the initramfs at shutdown time and do e.g. rm /var/* -rf && rsync -rlv --delete /usr/etc/ etc/.

    The strongest version here of course is re-fetching and re-imaging the target disk from the initramfs, but that's even more involved.

  6. jlebon commented on Apr 9, 2021

    @jlebon
    Member

    Also, if we shipped the .osmet file in e.g. /sysroot/fcos.osmet, then we could always support a factory reset back to the aleph image. If we wanted to support reset back to the current ostree commit we'd need a tool to fetch it out of band.

    Truly shipping the osmet file in the image is impossible because it's a circular dependency. So it would probably instead require coreos-installer to propagate it there manually at install time. But the problem is that the osmet file is tied to the OSTree commit of the aleph version, so if the node upgraded at all, we would need to fetch the aleph OSTree commit. One thing we could easily do is have coreos-installer add a ref to it it's not GC'ed, but then every node is paying that storage cost.

  7. bgilbert commented on Apr 9, 2021

    @bgilbert
    ContributorAuthor

    $ unshare -m /bin/sh -c 'mount -o remount,rw /boot && touch /boot/ignition.firstboot'
    $ reboot

    This won't remove any existing customizations, so I don't think we should encourage it.

  8. jlebon commented on Oct 25, 2021

    @jlebon
    Member

    A variation on #399 (comment) using kexec would be:

    • download the rootfs CPIO corresponding to the version we're at from stream metadata
    • concatenate base OSTree initrd with rootfs initrd and target Ignition config initrd
    • kexec with base OSTree kernel + concatenated initrd and --append 'coreos.inst.install_dev=... ... etc, to reinstall on the same device

    Since the rootfs CPIO includes the osmet file, no network is required during install. But air-gapped systems will need a way to obtain the rootfs initrd in the first place.

    Would require some tweaks to support pointing at a local Ignition config from coreos.inst.* kargs, but if we're wrapping all this in a e.g. coreos-installer reinstall, then we could also just generate a live Ignition config and do away with coreos.inst.* kargs entirely.

  9. jlebon commented on Dec 13, 2021

    @jlebon
    Member

    A variation on #399 (comment) using kexec would be:

    Opened a proof of concept for this in coreos/coreos-installer#712.

  10. dustymabe commented on Feb 16, 2022

    @dustymabe
    Member

    We discussed this in the community meeting today.

    12:04:26    dustymabe | #agreed For our factory reset capability we'll use kexec and initially
                          | require either network access or local copies of the install media to
                          | exist. In the future we may generate intall media from the existing system.
                          | We also will limit our scope to just re-installing FCOS on FCOS and
                          | disallow/discourage running it from other distros.
    
    
  11. 25 remaining items

  12. cgwalters commented on Nov 7, 2024

    @cgwalters
    Member

    FTR some things related to this continue on the bootc side in bootc-dev/bootc#404

  13. the-dipsy commented on Dec 14, 2024

    @the-dipsy

    As someone unfamiliar with bootc, OSTree and the intricacies of CoreOS and ignition, I'm finding parts of the puzzle but can't figure out, what exactly I'd currently need to do to reset which parts of my deployment.

    Given a CoreOS installation with a generic ignition file that only loads a remote ignition file to replace itself with, what's a light weight way to reset /etc and /var, load a new remote ignition file from the same location as before and have it at least setup my files and configurations accordingly (ideally including the ability to boot into the previous state in case something goes wrong)? Is that already possible?

    Thanks for the great work 😊

  14. the-dipsy commented on Apr 25, 2026

    @the-dipsy

    I built a factory reset/quick reprovisioning solution as part of a library with many other abstractions for CoreOS. Would be happy to have native support someday anyways of course.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions