Storage migration and recovery
Storage migration moves a legacy sandbox from loose disk and checkpoint files into the current protected layout. The user-facing path inspects the saved host state first, explains whether the data is ready or needs action, and repairs only after it can bind the work to one sandbox and a safe set of storage sources.
Upgrade boundary
The upgrade boundary separates legacy storage from the protected layout used by current starts and storage operations. A ready sandbox needs only normal readiness checks. A legacy sandbox must pass inspection and then complete a guarded import before it can use the current layout.
The catalog and saved host configuration define which disk roles belong to the sandbox. Legacy journals can describe possible views within those roles, but they cannot grant access to another disk or to an unrelated path. This keeps migration tied to the sandbox's stored identity and configuration revision. References: sdk/…/protected_state.rs• L34-70, crates/…/types.rs• L13-26, crates/…/types.rs• L29-50
The normal user path is:
- Inspect the selected sandbox or local home with
msb doctor --sandbox NAMEormsb doctor --all. - Start an eligible sandbox with
msb start NAME, or usemsb self repair --sandbox NAMEwhile it is stopped. - Stop a verified writer when repair reports that a sandbox or related sandbox still holds the storage.
- Review unresolved disk state instead of selecting a candidate by guesswork.
- Start the repaired sandbox after it reports that protected storage is ready.
The storage migration execution and compatibility page covers the migration plan, source conversion, journal, and compatibility safeguards in more detail.
Storage diagnosis
Storage diagnosis is a bounded, read-only check that reports the state of one or more local sandboxes without opening the normal local backend or changing catalog records, permissions, guards, configuration, or disk contents. It keeps running sandboxes running, so its result is provisional until repair performs a locked recheck. References: sdk/…/storage.rs• L29-99, sdk/…/storage.rs• L147-160
Diagnostic states
Each sandbox receives one stable status. The status describes the next user action rather than the internal file format.
| Status | User meaning | Next action |
|---|---|---|
ready | The protected layout is complete. | Use the sandbox normally. |
eligible | The legacy view is complete and can be upgraded after revalidation. | Start it or run repair while stopped. |
maintenance_required | The view is eligible, but macOS needs an explicit maintenance window. | Stop legacy writers across all homes, then use interactive repair. |
recovery_required | The system cannot safely choose or complete a view. | Preserve the source and investigate the report. |
in_progress | A durable transition exists. | Resume the recorded operation through repair. |
unavailable | Inspection could not establish the state. | Resolve the reported access, catalog, or configuration issue and inspect again. |
The report also marks whether the sandbox is running, whether protection is registered, which guest mount owns each disk role, and the conservative space estimate for selected disks. A protection record does not by itself prove that filesystem migration is complete. References: sdk/…/storage.rs• L39-99, crates/…/types.rs• L53-97, crates/…/storage_doctor.rs• L86-159
Diagnostic scope
The command accepts one named sandbox or an explicit all-sandboxes selection. It does not silently turn an empty selection into a whole-home scan. JSON output is intended for automation and returns exit code 0 for ready or eligible results, 2 when action is needed, and 3 when at least one requested sandbox could not be inspected. References: crates/…/storage_doctor.rs• L43-79, sdk/…/storage.rs• L117-140, sdk/…/storage.rs• L262-276
Repair flow
Repair is the controlled path from diagnosis to protected storage. It repeats inspection for the exact accepted targets, discovers current writer blockers, asks for consent before any graceful stop, and runs the import only for targets that still pass the checks.
This diagram shows how a provisional report becomes either a ready stopped sandbox or an investigation result.
flowchart TD
A[Diagnose selected sandbox] --> B{Protected layout ready?}
B -->|Yes| C[Report ready]
B -->|No| D[Reinspect exact target]
D --> E{Writer or related sandbox blocks repair?}
E -->|Yes| F[Ask for graceful stop consent]
F -->|Decline or changed| G[Keep target unresolved]
F -->|Accept| H[Stop observed generation]
H --> D
E -->|No| I{Safe eligible view?}
I -->|No| J[Preserve sources and show report]
I -->|Yes| K[Record and complete protected import]
K --> L[Report ready; sandbox remains stopped]
Repair keeps each target independent. A successful repair does not hide a failure for another target, and cancellation does not undo a completed stop or import. If a repair attempt may have written progress, the original files and recovery records remain the source for the next investigation. References: crates/…/interactive.rs• L241-367, crates/…/interactive.rs• L369-447, crates/…/interactive.rs• L739-783
Writer consent
Migration requires exclusive control of the selected storage. Repair can identify a running target or a related sandbox that shares a legacy source. It stores the observed sandbox and run identity in the stop request, then rechecks that identity before asking the local backend to stop it. A replacement generation cannot inherit consent from an older one. References: sdk/…/storage_repair.rs• L19-75, sdk/…/storage_repair.rs• L165-267, crates/…/interactive.rs• L449-527
The command never stops an ephemeral sandbox as a repair shortcut because stopping it may remove its storage. A stopped catalog row also does not prove that the old runtime has released its files. Repair waits for recorded process teardown and asks again when that proof is missing. References: sdk/…/storage_repair.rs• L193-223, sdk/…/storage_recovery.rs• L154-186
macOS maintenance
macOS uses a wider maintenance boundary for legacy storage. The selected catalog cannot prove that old VMs in other homes or old tools will not write the same files, so the user must confirm that all legacy writers have stopped and that new writers are excluded until repair finishes. New or already protected sandboxes do not need this confirmation. References: sdk/…/protected_state.rs• L208-253, crates/…/interactive.rs• L393-422
Recovery investigation
Recovery investigation applies when the system finds more than one plausible disk view or cannot prove which view is current. The user sees safe summaries grouped by disk role, such as the root disk or an owned mount, but ordinary repair does not choose one. This prevents a convenient candidate from silently discarding later guest writes.
When the complete alternatives can be captured safely, a separate recovery preview can make private copies for inspection. A restricted reader examines those copies only. It never attaches the original layers, and a later confirmation must match the reviewed candidate identity and bytes under fresh locks. References: crates/…/storage_doctor.rs• L119-139, crates/…/types.rs• L82-97, crates/…/preview.rs• L23-34, crates/…/preview.rs• L173-247, sdk/…/storage_preview.rs• L64-107, sdk/…/storage_preview.rs• L155-195
The current CLI keeps this candidate selection out of normal repair. If the state remains unresolved, scripted repair returns an investigation result and interactive repair offers a diagnostic report. It leaves the original disks, migration marker, and catalog unchanged when no repair was attempted. References: crates/…/repair.rs• L121-172, crates/…/interactive.rs• L655-727, scripts/…/legacy_storage_preview.py• L89-99, scripts/…/legacy_storage_preview.py• L224-257
Safe coexistence
Legacy and current sandboxes can coexist only where their storage ownership is clear. An unrelated protected VM may continue to run while another sandbox is inspected or migrated. A legacy VM that writes the selected disks, or a related child or parent that exposes the same storage, must be stopped or excluded before capture.
The migration boundary also protects older tools from reading a partially converted sandbox. Once protected migration begins, the layout presents an upgrade-required state until the complete disk group is ready. The importer publishes all disk journals as one protected group, retains external write-through bindings at their original paths, and leaves the legacy inputs for verification. References: crates/…/engine.rs• L107-181, sdk/…/protected_state.rs• L194-245, scripts/…/legacy_storage_migration.py• L598-628
The coexistence rule is therefore per storage group rather than per machine or per catalog. A running sandbox that does not share the selected sources is outside the migration boundary. A related writer is inside it even when its own name is not the repair target. References: sdk/…/protected_state.rs• L208-218, sdk/…/storage_repair.rs• L237-266, scripts/…/legacy_storage_migration.py• L418-425, scripts/…/legacy_storage_migration.py• L518-525
Failure interpretation
Repair reports use stable, short failure classes instead of copying raw storage errors, guest data, credentials, or host paths into terminal output. These classes tell the operator whether to preserve data, stop a writer, fix access, retry after a changed state, or seek support. References: crates/…/report.rs• L20-36, crates/…/report.rs• L62-120, crates/…/report.rs• L257-312
An unsuccessful operation is not proof that data is damaged or that the source is missing. The safe response depends on what happened: an untouched source can remain unchanged, a completed stop may have written guest state, and an attempted repair may have recorded durable migration progress. In every case, keep the original storage and recovery records until the next inspection establishes a safe state. References: crates/…/report.rs• L241-255, crates/…/interactive.rs• L647-649
Change checklist
When these files or sections are changed, remember to consider these:
- Keep diagnostic status, CLI exit codes, JSON fields, and repair next-step text aligned.
- Keep catalog identity, saved configuration revision, disk-role bindings, and candidate IDs bound together across inspection and repair.
- Keep writer discovery and generation-bound stop consent aligned with related sandbox and snapshot aliases.
- Keep macOS maintenance confirmation separate from local catalog inspection and from ready storage.
- Keep unresolved recovery views non-authorizing until private capture, review, and final revalidation all agree.
- Keep protected-layout publication atomic across every configured disk role and preserve the resume record after interruption.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A legacy writer or related sandbox still holds selected storage | Capture can observe changing bytes or an incomplete disk group | Discover blockers, obtain consent for the observed generation, and reacquire state before repair |
| A stopped row still has a live recorded runtime process | Repair may race teardown and open files held by the old process | Check process ownership before private preview or migration |
| Legacy metadata names multiple plausible views | Repair could discard later guest writes | Report candidates for investigation; do not select one in normal repair |
| Migration stops after durable progress begins | The sandbox may be fenced and cannot safely use either old or new layout | Retain the operation record and original files, then resume or investigate |
| macOS writers exist in another home | One catalog scan cannot prove source quiescence | Require explicit cross-home maintenance confirmation |
| A repair target changes after inspection | A stale report could apply to a new sandbox generation or source | Bind identity and configuration revision, then revalidate under locks |
Key files
| File | Why to read it |
|---|---|
| sdk/…/storage.rs | Defines the read-only storage diagnosis and user-visible status model. |
| crates/…/storage_doctor.rs | Shows diagnosis output, scope, exit codes, and next-step guidance. |
| crates/…/repair.rs | Shows scripted repair behavior and the boundary between diagnosis and mutation. |
| crates/…/interactive.rs | Shows target selection, stop consent, cancellation, partial outcomes, and investigation flow. |
| sdk/…/storage_repair.rs | Shows generation-bound blocker checks and safe graceful stops. |
| sdk/…/storage_recovery.rs | Shows the stopped-sandbox recovery contract and retained originals. |
| sdk/…/protected_state.rs | Shows how saved host authority, maintenance rules, and protected admission connect. |
| crates/…/types.rs | Defines inspection states, candidate summaries, and identity-bound selections. |
| crates/…/preview.rs | Shows private recovery captures and revalidation before adoption. |
| crates/…/engine.rs | Shows durable migration intent, fencing, group capture, and protected publication. |
| scripts/…/legacy_storage_migration.py | Demonstrates upgrade, writer coexistence, refusal, restart, and post-migration qualification. |
| scripts/…/legacy_storage_preview.py | Demonstrates unresolved-state investigation without candidate selection or source mutation. |