Skip to content

Latest commit

 

History

History
87 lines (58 loc) · 8.77 KB

ARCHITECTURE.md

File metadata and controls

87 lines (58 loc) · 8.77 KB

Recover a native checkpoint

Русский

Use arch-m2m native for a checkpoint that contains CRIU images. These images include executable memory state. Recovery requires compatible CPU capabilities and kernel features, the registered Arch executables and libraries, the approved CRIU runtime, and the matching arch-m2m control files.

verified checkpoint --restore--> instance A --save--> new checkpoint
                                      |                     |
                                  attach/use             restore
                                                            |
                                                            v
                                                        instance B

A checkpoint is a directory of saved data. An instance is a live tree with its own owner record. Selecting a default instance sets the target of commands such as ls and save. Changes made after capture belong to the running instance until the next save.

Initialize a destination

Run these commands as root outside tmux. Set criu_runtime to the absolute path of a separately supplied and unpacked CRIU runtime that matches the package profile. It must include the launcher, binary, libraries and manifest.

criu_runtime=/path/to/approved-criu-runtime
arch-m2m native doctor --criu-runtime "$criu_runtime" --json
arch-m2m native init --criu-runtime "$criu_runtime"

doctor checks the environment. init requires a new state directory and copies the pinned controls and CRIU runtime into it. Supply a verified seed checkpoint and all of its required parent checkpoints, each under its own name in /srv/arch-m2m/native/checkpoints/. Retain file ownership, permissions, timestamps, links and relative paths. The package contains profiles and control code. An initial application checkpoint must come from a qualified source.

Restore, use and save

In this example the provisioned checkpoint is named seed-01. Give each restored instance and each new checkpoint an unused name.

arch-m2m native checkpoints
arch-m2m native verify seed-01
arch-m2m native restore seed-01 --name work-01 --use
arch-m2m native status
arch-m2m native ls

Use the session name shown by ls to attach. After detaching all clients, save the instance while its applications are at supported input boundaries.

arch-m2m native attach work
arch-m2m native save saved-01
arch-m2m native verify saved-01

To exercise recovery independently, restore a second instance without --use. This keeps the first instance selected. Test the second copy before relying on the backup, taking account of shared external files and network services.

arch-m2m native restore saved-01 --name recovery-01
arch-m2m native --instance recovery-01 status
arch-m2m native --instance recovery-01 ls

After a reboot, restore the required checkpoint into a newly named instance. A native backup should include the checkpoint chain, bundled files and matching software. A copy of images/ alone is insufficient.

What the controller checks

  • Before saving, the controller verifies the instance's owner, pidfds, start times, namespaces and cgroup. It takes an exclusive lock, checks that all clients have detached, and freezes the applications. The controller and CRIU remain runnable. The cleanup path requests thaw even if capture fails.
  • While the applications are frozen, it checks their supported input states, descriptors, mappings and terminal relationships and records bounded files. A completed dynamic checkpoint includes hashes of the CRIU images, files, tool versions and required parent evidence. verify checks these dependencies and CPU compatibility. A successful independent restore also exercises process creation and terminal readiness.
  • During restore, the approved CRIU patches support the expected PTY count and arrange early inheritance of the controlling terminal by children. The controller checks the saved session/TTY relationship first. It verifies the restored tree's resources and waits for the applications to reach their input boundaries before publishing the instance.
  • If a projected nano backing file acquires a new inode or device number, the native helper checks its contents, metadata and editor graph before updating nano's cached stat information. A file that was actually changed fails the checks. The PTY comparison permits the kernel's open-added O_LARGEFILE flag for the same slave character device while checking the remaining flags, device and terminal settings.

Files and refusal conditions

The instance uses the host Arch programs and network. PID, mount, proc, devpts, temporary storage and time resources have separate views. Selected files such as a Bash history file or nano document are projected at their logical paths from private instance storage. Writes to a projected file affect that instance's copy. Other paths can remain shared with the host and other restored instances.

Native filesystem inventory version 2 records UID, GID, mode, modification time, symlink targets and regular-file hardlink groups. Links with both names in private /tmp or both in the captured nano tree retain the same inode relationship after restore. Links to files outside those trees, hardlinked symlinks and hardlinked per-file user projections are refused. Historical inventory version 1 can verify only the metadata that the old checkpoint recorded; previous captures may already contain independent copies where the original had hardlinks.

A configured HISTFILE must exist as a supported regular file at capture. Bash can also have HISTFILE unset, empty or set to /dev/null. If a shell points to a new history filename, create the file under the intended path, permissions and owner inside the source instance before capturing. A selected old checkpoint that explicitly records an absent history file cannot be restored by this profile. An ancestor with that historical condition may still supply capability evidence for a later independently valid snapshot.

The native save profile supports pinned single-threaded root processes, internal PTYs, idle shells and the supported foreground nano state. Examples that cause capture to refuse include attached clients, active SSH connections, background jobs, an executing script, external pipes, unknown devices and deleted or writable regular-file descriptors. Use the error to bring the source back to a supported state. A failed attempt may retain diagnostic files. Give the next attempt a fresh name.

The native profile bounds a tree at 256 application processes and 2,048 descriptors per process. User files selected beneath /root and /home are bounded at 16 MiB per file, 64 MiB in total and 1,024 files. Private temporary storage has limits of 64 MiB and 4,096 entries. The editor configuration limit is 4,096 entries. Back up other files and coordinate independent writers before taking a snapshot.

For movement between Intel and AMD using typed application data, see Semantic portability.

Native toolkit updates

Package upgrades replace the executable and profiles in /usr. Initialized state has a separate, pinned copy of the toolkit. Since version 0.4.0 the launcher checks that copy before native save, verify and restore. Terminal access to an existing instance remains available during maintenance. Installing the package alone does not update a running instance's toolkit.

The watchdog needs a delegated cgroup v2 subtree with writable cgroup.kill (Linux 5.14 or later). An unsupported freezer environment is refused before applications are frozen. If the controller exits during an armed save, the watchdog retains the operation lock and freezer while detached workers finish. It grants up to 240 seconds after controller loss for ordinary completion, including the internal 180-second CRIU dump timeout. At the deadline it cancels remaining workers with cgroup.kill and waits for the worker group to empty before thawing. A preflight helper can be cancelled immediately.

For an existing 0.3.0 or 0.4.0 deployment, retain a verified recent native checkpoint, its complete capability-parent chain, the approved CRIU closure and the matching old installation. Use a separately initialized 0.5.0 state root on a compatible test system first. Run arch-m2m native init with the trusted closure, copy the whole checkpoint chain into its new checkpoints/ with original ownership and metadata, then native verify and restore a new instance. Confirm the application state and perform a fresh save and independent restore. Do not replace an active state directory. For a same-host change, schedule a cutover after preserving the final state, stop the previous instance in the maintenance window and keep the old state available for rollback. Never edit a snapshot manifest, toolkit hash or evidence gate to satisfy the new profile.