Snapshot
Also called Checkpoint
A snapshot is a saved copy of the state of a sandbox or virtual machine, taken so that work done so far does not have to be done again. Restoring it returns a machine to the saved moment. The snapshot records the state as it was at one instant, even if the machine keeps running afterwards. Changes made after that instant are not part of it and are lost on restore.
A restore can recover from a mistake, or resume the machine on another host. It can also fork one machine into many, each starting from a state that took minutes to build. Agents and test systems use this to try several paths from the same starting point and keep the one that works. Snapshots taken at intervals also act as checkpoints for long jobs, so a failure costs only the work since the last one.
A snapshot can hold only the disk, or the disk together with memory and processor state. That choice decides whether a restored machine boots from scratch or picks up in the middle of its work. A disk-only snapshot is smaller and easier to move between hosts and hypervisor versions. A full snapshot ties the restore to a compatible hypervisor and processor, because the saved state describes that exact virtual hardware.
Disk snapshots
A disk snapshot is a saved copy of a filesystem or a block storage volume. With copy-on-write storage it takes almost no time, because the snapshot keeps the current blocks and new writes go elsewhere. A snapshot of a running machine may catch files mid-write, much as if the power had been cut at that moment. Tools often pause writes or flush caches first, so the filesystem inside is consistent.
Restoring a disk snapshot is like booting a computer whose disk was copied. The files are there, but no process is running and every program starts from the beginning. Anything that lived only in memory is gone, such as unsaved work or a warm cache. Programs that write their state to disk often lose the least.
Disk snapshots are small and simple, since they hold only what was written to disk. Their cost is time, because the restored machine still has to boot and load its runtime. Providers often keep them in object storage and copy only the blocks that changed since the previous snapshot. A restore on a new host may then fetch blocks lazily, which slows the first reads after boot.
Memory snapshots
A memory snapshot is a saved copy of the memory of a machine, together with the state of each vCPU and of the virtual devices. Restoring it resumes processes mid-instruction, with open files in place. The hypervisor pauses the guest while it saves, so memory and device state describe one consistent moment. The guest takes no part and does not need to know that the snapshot happened.
Hypervisors such as Firecracker support memory snapshots for microVMs, and CRIU does a similar job for Linux processes. These snapshots are larger, but they skip the boot and runtime init that dominate start-up. A restored interpreter, for example, comes back with its libraries loaded and its caches warm. CRIU works from outside the process, collecting its memory and open resources through kernel interfaces.
A restore does not have to read the whole memory file first. It can map the file and load each page only when the guest touches it, so the machine resumes almost at once. Pages the guest never touches are never read at all. The trade is a stream of small stalls right after the restore, which some platforms reduce by prefetching the pages that past restores needed.
Identical copies
Identical copies are machines restored from one memory snapshot, each believing it is the same machine. They break assumptions that software makes about being unique. A program normally creates its identity once, at install or first boot, and never checks it again. After a restore, every copy carries the same identity forward without knowing that the others exist.
The danger is greatest where software relies on randomness for security. Two copies that hand out the same keys or session IDs let one user predict the secrets of another. Cryptographic code is the most exposed. Signature schemes such as ECDSA leak the private key outright when the same random nonce signs two different messages.
Linux offers a virtual machine generation ID that changes on every restore. Programs that watch it can detect the restore and regenerate their state, but software has to be written to look for it. Recent Linux kernels use it to reseed their own random number generator without help. The safest course is often to take the snapshot before any secrets exist, so each copy creates its own after the restore.
| Problem | Description |
|---|---|
| Random numbers | Random number generators produce the same values in every copy until they are reseeded with fresh entropy. |
| Unique IDs | Values such as UUIDs, machine IDs and MAC addresses repeat across copies. |
| Clocks | The guest wakes with the time of the snapshot, and timers that depend on it misbehave until it is corrected. |
| Network connections | Connections open at snapshot time point at peers that have moved on. |