--- title: Treat each generation as a boot environment; roll back with beadm activate area: be impact: CRITICAL tags: [boot-environments, beadm, generations, rollback, solnix-rebuild] verified: 2026-11-04 --- # Treat each generation as a boot environment; roll back with beadm activate On Solnix generation N is the boot environment `solnix-N`: let `solnix-rebuild` create and activate BEs, and roll back by activating an older BE and rebooting. `beadm destroy` cannot be undone and takes the BE's snapshots with it, so ask the user first and never destroy the running BE (marked `N`) or the next-boot one (`R`). **Antipattern** ```sh # do not run these; the destroy is irreversible pfexec pkg update # no pkg/IPS on Solnix pfexec beadm create mytest # not a generation: solnix-rebuild rollback may pick it later pfexec beadm create solnix-7 # when generation 7 is built, boot destroys it (-f -F) to re-create it pfexec beadm destroy -F solnix-4 # no prompt, maybe the only good fallback ``` **The Solnix way** ```sh solnix-rebuild list-generations # system-N-link profiles, then beadm list pfexec solnix-rebuild switch # activate now (live SMF) AND create + activate BE solnix-N for boot pfexec solnix-rebuild boot # create + activate BE solnix-N; the running system is unchanged pfexec solnix-rebuild test # activate now only: no new generation, no BE, boot default unchanged pfexec solnix-rebuild rollback # = boot --rollback: beadm activate another BE (see below); then reboot beadm list # Active: N = running now, R = on reboot, NR = both, T = next boot only pfexec beadm activate solnix-3 # pick a specific generation for the next boot # a risky boot-time change: switch/boot already made the new BE the permanent default, so first put the default # back on the known-good BE, then boot the new one once (boot-environment-safety.md): pfexec beadm activate solnix-4 # known-good BE: R again pfexec beadm activate -t solnix-5 # boot-once; beadm list shows solnix-5 as T and solnix-4 as R or NR # if solnix-5 boots and is healthy: pfexec beadm activate solnix-5 (now NR) # ask the user first; never the BE marked N or R: pfexec beadm destroy solnix-1 # prompts; destroys the BE and all its snapshots ``` `rollback` activates a BE from `beadm list` (every imported pool) that is not marked `R`, and prints `rolling back: beadm activate `. Check that it named the generation you meant; if not, `beadm activate` the right one. With no `--flake` and no toplevel, `switch`, `boot`, `test` and `build` use the flake in `/etc/nixos` (when it has a `flake.nix`) and the configuration named by `hostname`. **The illumos way** (OpenIndiana, OmniOS, SmartOS) ```sh pfexec pkg update # OpenIndiana: clones the BE, updates the clone, activates it beadm list pfexec beadm create -d "before driver" pre-driver # a manual BE before risky changes pfexec beadm activate openindiana-1 # roll back to the pre-update BE, then reboot ``` `pkg` names the BEs it creates from the `auto-be-name` image property. `beadm destroy` asks for confirmation. **The difference.** BEs and `beadm` are the same illumos mechanism; what differs is who makes them. On Solnix `solnix-rebuild switch|boot` creates `solnix-N` per generation and also records it as a `system-N-link` profile; on OpenIndiana `pkg update` creates the BE, and Solnix has no `pkg`. The Nix store is shared by all BEs; solnix-install's layout also shares homes and most of `/var` (proven on scratch pools only: design-var-state.md, "PLANNED (not yet run)"). A rollback changes the system, not what those shared datasets hold. **Check.** `beadm list` shows exactly one BE with `R` (the one you want to boot), and after the reboot that BE shows `NR`. **Unverified** - Which BE `rollback` picks. The script sorts `beadm list -H` on field 6, which beadm(8) Example 18 shows is the Policy column, not Created, so the pick may follow name order (`solnix-9` after `solnix-10`). Not measured. **Where sources disagree.** design-generations.md §0, product.md pillar 5 and illumos-domain.md say `/nix/store` is inside the BE, and design-generations.md §1.1 says no `nix-env --profile` is used; the code (lib/make-be.nix, default.nix) has one shared `/nix` and runs `nix-env -p ... --set`. §1.2 says BE names never collide; the code destroys an existing `solnix-N` (`beadm destroy -f -F`). This rule follows the code. **After a rollback.** The system profile is not moved back: `list-generations` still marks the newer generation current, and a later `solnix-rebuild switch` with no `--flake` and no `/etc/nixos/flake.nix` re-activates that newest generation (and re-creates its BE). Pass the toplevel or the flake you want: `rollback` only runs `beadm activate`. **Sources** - [docs/design-generations.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/docs/design-generations.md) (solnix 5a8e5ce), §0 The model; §1.1 Runtime tools; §1.2 The generation registry; §2 Switch / rollback recipe - [modules/system/activation/default.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/system/activation/default.nix) (solnix 5a8e5ce), `switchToConfiguration` (switch, test, boot, `be="solnix-$gen"`, "destroying to re-create"); `solnixRebuild` (rollback, flake default, list-generations) - [docs/boot-environment-safety.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/docs/boot-environment-safety.md) (solnix 5a8e5ce), The rule (`beadm activate -t`, `T`, `-T`) - [lib/make-be.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/lib/make-be.nix) (solnix 5a8e5ce) and [modules/system/activation/install-be.sh](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/system/activation/install-be.sh) (solnix 5a8e5ce), header: one shared `/nix` for every generation - [docs/design-var-state.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/docs/design-var-state.md) (solnix 5a8e5ce), The layout; Proof cleanup (rollback looks at every imported pool) - [Handbook: ZFS boot environments](https://solnix.io/docs/handbook/boot-environments#the-beadm-commands) (site 307b67f), The `beadm` commands (List, Activate, Destroy); Safe upgrade and rollback, end to end - [beadm(8)](https://solnix.io/docs/man/beadm.8) (illumos, CDDL), SUBCOMMANDS list (Active field N, R, NR, T; -H), activate -t/-T, destroy -f/-F/-s, create -d; Example 18 - [.kiro/steering/illumos-domain.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/.kiro/steering/illumos-domain.md) (solnix 5a8e5ce), ZFS root + boot environments (stale on the store's location) - [.kiro/steering/product.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/.kiro/steering/product.md) (solnix 5a8e5ce), No IPS/`pkg` in the end product; pillar 5 - [OpenIndiana handbook: Managing Boot Environments](https://docs.openindiana.org/handbook/getting-started/#managing-boot-environments), Why use multiple boot environments?; beadm command reference; `auto-be-name` note - [OpenIndiana handbook: Updating packages](https://docs.openindiana.org/handbook/getting-started/#updating-packages), `pkg update` output ("A clone of openindiana-1 exists and has been updated and activated")