Capstone: Rebuild a Workstation From Notes

LESSON

Linux Workstations: Ownership, Reproducibility, and Repair

008 25 min beginner CAPSTONE

Capstone: Rebuild a Workstation From Notes

By the end of this lesson, you will be able to...

  • design a recovery dossier that separates machine configuration, package trust, services, secrets, valuable data, and host-specific facts;

  • stage a workstation reconstruction so that each change has a predicted result, acceptance evidence, and a bounded recovery action;

  • review a failed rebuild without confusing a copied command, a declarative generation, or a repository clone with proof that the workstation is usable.

Idea in one sentence: A recoverable workstation is not a pile of setup commands; it is a small, versioned recovery argument that says what to restore, in what order, what evidence proves each layer works, and what remains deliberately manual.

Core Insight

Maya's new laptop field is blank while her old machine is unavailable. A workstation is recovered when its important promises can be checked again, not when it merely looks familiar. The recovery dossier makes those promises inspectable: it separates state classes, orders their dependencies, and records the evidence that distinguishes a working layer from a plausible-looking one.

That is why the final artifact is an argument rather than an installation script. Automation can execute a good argument, but it cannot supply the missing trust decision, secret, host fact, or acceptance condition that the argument never named.

The Scenario

Maya has replaced her laptop cedar with a fresh machine called field. Her old machine still exists, but she treats it as unavailable for the exercise: no copying its home directory, no asking it which command worked last month, and no exporting every credential “just in case.” She has only the recovery dossier she prepared during this track, a backup of her notes, and the official installation media for the operating system she chooses.

Her definition of useful is deliberately modest:

That is not the same as recreating every preference. A font cache, old downloads, and a perfect panel layout can wait. The capstone judges repairability and explainability, not visual similarity.

The tempting recovery plan is short:

install Linux
clone dotfiles
install packages
copy home directory
keep trying commands until it feels normal

It can work when the machine is simple and the owner remembers every hidden dependency. It fails under pressure. A package may have come from an unrecorded source. A service may depend on an environment file that was never in Git. A file can exist but belong to the wrong user. A NixOS configuration can build while the user service or personal data is still absent. The plan produces activity, not evidence.

The stronger model is a recovery dossier: a versioned set of notes that turns a rebuild into small claims. Each claim names the object being changed, the source of trust, the expected result, the evidence to collect, and the smallest recovery action if that result is missing.

Constraints Before Tools

Maya writes constraints before deciding whether a step is a shell command, an Arch-style manual record, or a NixOS declaration. This prevents a tool from quietly deciding the design.

Constraint Design consequence
The machine may be offline after the first boot Keep installation media, network prerequisites, and the local location of recovery notes explicit; do not assume a repository is reachable.
The notes may be read by another careful person Store references and procedures, not passwords, private keys, recovery codes, or personal document contents.
field has different display hardware from cedar Give host facts their own record or module instead of copying a global setting.
A change can fail halfway through Prefer small stages with a visible checkpoint over one opaque setup script.
A useful machine needs both declared and changing state Keep configuration, secrets, data backups, and regenerable caches on distinct recovery paths.
Maya needs to repair the machine later Record what proves the result, not only the command that was run.

These are not universal rules. A fully automated installer can be an excellent choice when it is reviewed, tested, and fits the hardware. A manual sequence can be a good choice when the machine is unusual or the learner needs to inspect each transition. The requirement is the same in both cases: the recovery path must expose ownership and evidence.

Design Goal: A Dossier Another Person Can Use

Maya's dossier is a small repository plus protected references outside it. The repository is not a backup of her whole life. It is the explanation of how to restore the machine safely.

recovery-dossier/
  README.md
  hosts/
    field.md
  packages/
    explicit-packages.md
    third-party-or-foreign.md
  config/
    dotfiles/                 # non-secret configuration only
    nixos/                    # if this host uses NixOS
  services/
    note-preview.md
  data/
    restore-notes.md
  evidence/
    acceptance-checks.md
  decisions/
    manual-boundaries.md

The directory names are a teaching model, not a mandatory layout. What matters is that a future reader can find the answer to six questions:

  1. What does this step change? A package database, a path, a unit, a user-owned configuration file, or a data store are different objects.
  2. Why do we trust the input? An official repository, a reviewed configuration commit, a backup source, or a protected secret-provisioning process each needs its own statement.
  3. Who owns the result? The package manager, root, Maya's normal user, an application, or a backup process may own different parts.
  4. What should be true afterward? “The command exited successfully” is weaker than a visible condition such as “the service is active and returns its health response.”
  5. What evidence records that condition? A package query, file metadata, a service status and log excerpt, a build result, or a restored document can earn the claim.
  6. What is the bounded recovery action? Revert one configuration generation, remove one broken user config, re-provision one secret reference, or restore one data item—without deleting unrelated state.

This connects the whole track. The shell is a control surface, so every action needs a target and blast-radius prediction. Permissions are an access decision, so the dossier names which account must read a file. Packages import provenance and dependencies, so an unrecorded install source is not a harmless omission. Services have their own state and environment, so a successful interactive command cannot prove that a boot-time unit works. Declarative configuration helps describe a desired state, but it does not convert a secret, a note archive, or a host fact into configuration.

Proposed Model: Rebuild in Evidence-Bearing Stages

Maya does not aim to restore everything in one pass. She builds a ladder. A failed stage must leave enough evidence to choose the next check rather than repeat the whole rebuild.

Stage Intended result Evidence to record If it fails, contain the change
0. Read the dossier The recovery scope and exclusions are understood A written list of what will not be restored yet: private keys, caches, old downloads, and unreviewed scripts Stop before mutating the machine; clarify the dossier
1. Establish the base host field boots, has storage, a normal user, and network access appropriate to the plan Host name, device facts, user identity, and a basic connectivity observation Repair this base layer; do not install the personal stack yet
2. Recreate trusted software Required packages and the package source are known Package list with source/provenance notes; a query showing each package is installed Remove or correct only the package decision; do not copy binaries from cedar
3. Apply non-secret configuration Shell, editor, and Git preferences have the intended owner and host scope Reviewed diff plus an editor launch and a basic Git configuration check Revert the relevant configuration file or generation
4. Restore service behavior note-preview can start with its declared dependencies and runtime inputs Unit status, relevant log lines, and a local health check Diagnose the unit, its paths, identity, and inputs before changing packages
5. Provision sensitive and changing state The allowed credential reference works and one known note restores correctly A permitted authentication check and a restored-note check; never the secret value itself Re-provision the reference or restore data through its own path
6. Record the result A later rebuild can start from observed facts rather than memory Timestamped acceptance evidence and a short list of remaining manual steps Mark the recovery incomplete instead of calling it done

The table gives an ordering rule: establish the thing a later check depends on before using that check as evidence. For example, Maya cannot diagnose an application service from logs until the base system can store and read logs. She cannot claim Git access is repaired because a public clone works if the real task requires a protected repository. She cannot treat a successful NixOS build as proof that a service is ready: a build is evidence about a candidate configuration, while runtime checks establish that the intended process actually has the inputs it needs.

Two administration paths, one recovery standard

The stages work for both administration styles introduced earlier in the track.

For an Arch-style host, the dossier may record an explicit package list, the configured repositories, any foreign or locally built packages, and the reasons they exist. Pacman can query the local package database and check whether package-owned files are present, but those facts do not prove that Maya's editor configuration or personal service is usable. The evidence needs to continue into the next stages. Arch Wiki: pacman

For a NixOS host, the dossier may put the system configuration and host module under version control, then use a test or switch workflow with a rollback plan. NixOS generations make configuration changes inspectable and can provide previous boot or switch targets when retained; they do not recreate an external account, private key, or user data backup. NixOS Manual: changing configuration and rollback

This is the trade-off, stated precisely: declaration reduces unrecorded drift for the state it describes, while explicit manual records can make unusual choices visible. Both approaches still need a boundary for secrets, mutable data, and host facts. Neither is a substitute for an acceptance test.

Walkthrough: The Service That Worked Only in a Terminal

At stage 4, Maya's note-preview service does not start. Her first thought is reasonable: the package must be missing. She ran the program from her terminal yesterday, and it responded on a local port.

The first evidence changes that model. The package query shows the executable is installed. The unit status says the service exits soon after start. Its log mentions that NOTES_TOKEN is missing. The following synthetic unit fragment makes the boundary visible:

[Service]
User=maya
WorkingDirectory=/home/maya/notes
EnvironmentFile=/home/maya/.config/note-preview/runtime.env
ExecStart=/usr/local/bin/note-preview --listen 127.0.0.1:8811

The terminal test used an environment variable exported in an interactive shell. The service starts in its own configured environment. The program file exists; the service's input does not. Reinstalling the package would add noise, not fix the failure.

Maya walks the dossier's evidence chain:

Question Observation Inference Next bounded action
Does the executable exist? The package and executable are present This is not first a package-presence problem Leave packages unchanged
Can the service account read its working directory? The normal user owns the notes directory and the unit runs as that user The path is plausible; inspect the configured input next Do not change ownership blindly
Does the referenced runtime file exist? runtime.env is absent on field The secret-delivery step was not completed Use the protected provisioning process to create or reference it
Is the file safe to commit? It contains a token It is a secret, not dotfile content Keep only an example/template in the dossier repository
Does the repaired unit work? The unit stays active and the local health check returns the expected result The service recovery claim is now earned Record the check and the secret reference, not the token

The capstone does not require a particular secret manager. It requires an interface: who can provision the value, where the service reads it, what happens if it is absent, and how Maya revokes or replaces it. That is enough information to recover the service without teaching a broader threat-modeling program.

So far: Maya did not solve the problem by remembering a magic command. She used the earlier service model: distinguish package presence, process identity, working path, configured environment, and runtime evidence. Each check ruled out one plausible cause.

Failure Review: What a Successful Rebuild Can Still Hide

Maya completes stages 1 through 5. The desktop looks familiar. That is encouraging, but it is not the final proof. She reviews the recovery path for failures that visual similarity can hide.

Hidden failure Why the initial result is misleading Evidence that exposes it Recovery boundary
A configuration file is owned by root but the editor runs as Maya The file exists and may work for a privileged test Inspect owner and permissions while using the normal account Correct the single file's ownership; do not recursively change the home directory
A foreign package was installed manually and never recorded The application opens today Compare the explicit package record with the installed source and note why it is outside the normal repository path Record, replace, or remove that one package decision
A NixOS configuration builds but the new setting is not the boot default A build artifact exists Record whether the intended generation was tested, switched, or made the boot target, then check runtime behavior Use the documented generation/rollback boundary rather than editing generated files
Notes were synchronized but an expected history is absent A folder exists with current files Open a known note and inspect the expected restore signal, such as its title and revision history Use the data restore path, not a configuration rollback
A cache was copied to make an app feel fast The application starts quickly Remove or regenerate the cache in a controlled test Keep it excluded unless the regeneration cost is explicitly accepted

The common error is treating presence as correctness. A file can be present but unreadable. A process can run but receive the wrong environment. A configuration can be declared but not active. A backup can copy bytes without restoring the data the learner needs. The dossier needs an acceptance check for the user-facing claim, not merely for the previous command.

Trade-offs and Deliberate Manual Steps

A recovery dossier costs time. Writing acceptance checks, recording a third-party package, and separating data from configuration feel slower than cloning everything. That cost is real. On a small personal machine, some details may remain manual because automating them would be harder to review than doing them carefully once.

Maya records these deliberately manual boundaries:

This improves the next rebuild because another person can see what they must supply and what they must not copy. It can still fail when a dependency, account provider, hardware device, or backup source has changed since the notes were tested. The boundary signal is simple: an acceptance check requires a hidden assumption that the dossier never named. When that happens, add the assumption and retest; do not hide it inside a longer setup script.

Evidence and Readiness

Before calling field recovered, Maya runs a tabletop review. She gives the dossier to a careful peer and asks them to explain the next action at each stage without using cedar or guessing. The peer does not need to execute destructive commands. They need to find the correct object, source, evidence, and recovery boundary.

Use this rubric for the review:

Criterion Ready Not ready
Scope Defines the minimum useful workstation and explicit exclusions Says only “restore my setup”
Ownership Names the user, service, package manager, backup, or secret process that owns each important state class Mixes all state into one home-directory copy
Trust Records source/provenance for packages and configuration Says “install whatever worked before”
Ordering Places base host, software, configuration, service, and data checks in dependency order Uses a service or data check before its prerequisites exist
Evidence Gives an observable acceptance condition for every stage Treats a successful command or attractive desktop as proof
Repair Has a local rollback, revoke/re-provision, restore, or regenerate action Recommends reinstalling or copying everything for every failure
Boundary Labels secrets, mutable data, caches, and host-specific facts Publishes values, treats backups as configuration, or assumes all hosts match

If one row is not ready, the appropriate result is not failure as a person. It is an identified recovery gap. Add the missing decision or evidence, then repeat the relevant stage. That is exactly what makes the platform maintainable.

Final Challenge: Write and Tabletop-Test Your Dossier

Create a recovery dossier for a real or imagined Linux workstation. You do not need to reinstall a machine for this exercise. Design the path, then tabletop-test it against one failure.

Your dossier must include:

  1. a one-sentence definition of the minimum useful workstation;
  2. six or more ordered recovery stages, each with its object, trusted input, acceptance evidence, and bounded recovery action;
  3. one package provenance decision and one package verification check;
  4. one configuration item, one secret reference, one mutable-data restore action, one cache policy, and one host-specific fact;
  5. a service that could fail because its runtime environment differs from an interactive shell;
  6. a failure trace that shows at least two rejected hypotheses before the repair;
  7. a list of intentionally manual steps and the constraints that justify them.

A strong answer does not need many commands. It shows dependency order, distinguishes state classes, and proves each useful claim with an observable check. A weak answer says “clone the repo, install packages, restore backup” without naming what may leak, what may drift, what owns the files, or what tells the next person that the machine is actually usable.

Resources

Key Takeaways

PREVIOUS Dotfiles, Secrets, and Personal Platforms