# ADR-016: Separate System Software and Persistent Device Data ## Context This example uses system images and an A/B layout. The device keeps the current system while preparing a new version in the other slot. An image installer can replace all contents of its target area. Device identity, calibration, settings, and application data must survive that operation. Both retained system versions may need these files. The device has enough storage for two system versions and a separate persistent data area. The product can define which data formats the retained versions support. ## Decision Store system software in the system slots. Store device identity, calibration, device settings, and application data outside the areas replaced by ordinary system image updates. Keep the running system files read-only in this example. Programs write changing files to the persistent data area. The platform defines the locations and access rules for those files. An image may include default configuration. Device settings are stored separately, with a defined rule for how the application combines them with the defaults. A normal system release must not overwrite device identity or calibration. Share persistent data between the slots only when the supported recovery versions can use it. Before changing a data format, define and test compatibility or a restore path. If recovery uses a saved copy, define what happens to data written after that copy was made. The product must state when returning to an older system stops being supported. Confirmation alone does not prove that later data changes remain compatible with that system. ## Decision Drivers - Installing a system image must not erase information that belongs to the device. - Returning to the previous system must preserve a usable data path. - The boundary between release files and changing device files must be clear. - Normal application writes should not change the system software under trial. ## Alternatives Considered ### Keep Device Data Inside Each System Image This is a simple layout, but replacing an image would erase the data unless the installer copies it elsewhere first. The copying and restore steps would need their own failure handling. ### Keep a Separate Data Copy for Each Slot This can help isolate data changes during a trial. It needs more storage and rules for copying data, choosing the active copy, and handling new records after a return to the old slot. It may be appropriate when shared data cannot support both versions. ### Keep One Writable System With All Data This can suit package-based updates. It does not meet this example's requirement to prepare and replace a complete system image while retaining the current system. ## Consequences ### Positive - System image replacement preserves device-specific files. - New application records can remain available after a return to the previous system. - The areas that the image installer may change are easier to define. ### Negative - The platform must arrange paths and access to persistent files. - Shared data needs compatibility rules for retained software versions. - A shared data failure can affect both slots. - Copies or backups used for data recovery need extra storage and cleanup rules. ## Applicability and Limits Use this approach when system software is replaced as an image and device data must survive that replacement. Separation may use partitions or other storage areas outside the installer's target. A directory inside a partition being overwritten is not sufficient. This choice does not protect against failure of the whole storage device. It also does not make data writes safe under power loss or make migrations reversible. Those need separate mechanisms and tests. Key storage and access protection need a security design. Placing identity files outside a system slot is only a rule about their lifetime. ## Related Documents - [Chapter 05: Storage Layout](../docs/05-storage-layout.md) - [ADR-004: Full-System Image Updates](ADR-004-full-system-image-updates.md) - [ADR-014: Trial Boot and Confirmation for System Updates](ADR-014-trial-boot-and-confirmation.md) - [ADR-017: Keep Recovery State Outside Replaceable Software](ADR-017-keep-recovery-state-outside-replaceable-software.md)