# Firecracker Snapshot Restore: A Practical Guide

> How Firecracker snapshot restore works: the API calls, Full vs Diff, File vs Uffd, fsync, clock and entropy pitfalls, and measured timings.

- URL: https://flockvm.com/learn/firecracker-snapshot-restore
- Last updated: 2026-11-10

A Firecracker snapshot freezes a running microVM into two files, guest memory and device/vCPU state, so that a new Firecracker process can resume it exactly where it stopped. The API is four calls. The hard part is around them: file sizes, when they reach the disk, the guest clock, and what happens if you restore the same state twice.

Every API call here follows the [Firecracker v1.17.0 documentation](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/docs/snapshotting/snapshot-support.md) (released 2026-09-10). The timings come from the host we ran in Paris at the time, retired on 2026-11-10 ("our host" below): an Intel Xeon E3-1230 V2 (Ivy Bridge), 31 GiB of RAM, RAID1 SATA SSDs, Ubuntu 24.04 with kernel 6.8, Firecracker v1.17.0, guests with 2 vCPUs and 4 GiB of RAM, measured on 2026-10-30 and 2026-10-31. flockvm's VMs now run on another server, in France. Your disk will change the numbers, not the trade-offs.

## What does a Firecracker snapshot contain?

Two files that Firecracker writes, plus the disks, which it does not:

| File | Holds | Size on our host (4 GiB guest) |
|---|---|---|
| microVM state (`snapshot_path`) | KVM and vCPU state, emulated devices, MMDS configuration | 18-24 KB |
| guest memory (`mem_file_path`) | every page of guest RAM | 4.0 GiB, written in full, not sparse |
| disk files | your root filesystem and other drives | unchanged; "managed by the users" |

Not in the snapshot, per the docs: the logger and metrics configuration, the MMDS data store (its configuration is kept), the vsock backend and serial emulation. The disk is the bigger trap: Firecracker `fsync`s the block devices at snapshot time but does not copy them. Once the disk changes, the memory image no longer matches it, so we treat every snapshot as single use.

The state file carries a 64-bit CRC, checked before loading; nothing protects the memory file. Snapshot files are trusted by design: authenticate and encrypt them yourself if they cross machines.

## How do you take and restore a snapshot, step by step?

Pause, create, stop the process, then load into a fresh process and resume. These are the requests from our host notes, sent over the API socket (paths are inside the jailer's chroot; our daemon now sends `sync_snapshot_files: false`, see below):

```
# 1. Freeze the vCPUs (9-10 ms on our host)
PATCH /vm              {"state":"Paused"}

# 2. Write the two snapshot files
PUT   /snapshot/create {"snapshot_type":"Full","snapshot_path":"/vmstate","mem_file_path":"/mem","sync_snapshot_files":true}

# 3. Kill the Firecracker process; keep the TAP device and the disk

# 4. New Firecracker process (through the jailer), then, before any other configuration:
PUT   /logger          {"log_path":"/firecracker.log","level":"Info","show_level":true}
PUT   /snapshot/load   {"snapshot_path":"/vmstate","mem_backend":{"backend_type":"File","backend_path":"/mem"},"resume_vm":true,"clock_realtime":true}
```

The rules that matter, all from the official docs:

- `PATCH /vm`, `PUT /snapshot/create` and resuming are only allowed after boot. `PUT /snapshot/load` is only allowed **before** the VM is configured; the logger and metrics are the only things you may set first.
- If the target files exist, `snapshot/create` truncates and overwrites them.
- The loaded VM stays `Paused` unless you pass `"resume_vm": true` (or send `PATCH /vm {"state":"Resumed"}` afterwards).
- The new process needs the same host resources under the same paths: disk files at the same path, TAP devices with the same names, the vsock socket with the same name. `network_overrides` (added in 1.12.0) and `vsock_override` (1.16.0) in `snapshot/load` let you change the TAP name and the vsock socket path.
- If the load fails, Firecracker exits. Keep a cold boot from the disk as the fallback.
- `mem_file_path` in `snapshot/load` still works but is deprecated: use `mem_backend`.

Killing the process is optional: `PATCH /vm {"state":"Resumed"}` continues the same VM after a snapshot. We kill it to free the host's RAM.

## Full or Diff snapshot: which one should you use?

| | Full | Diff |
|---|---|---|
| Memory file | every page of guest RAM | pages dirtied since the last snapshot (or boot), as a sparse file |
| Resumable alone | yes | generally no: merge it onto a base with `snapshot-editor edit-memory rebase` first (exception: the first Diff of a VM that was booted, not restored) |
| Needs | nothing | `track_dirty_pages: true` in `/machine-config` or `/snapshot/load` for exact tracking; otherwise Firecracker uses `mincore(2)`, which only works with swap off |
| Cost while running | none | KVM dirty-page logging costs CPU and "negates most of the benefits" of huge pages |
| Status in v1.17.0 | generally available since 1.13.0 | developer preview |
| Use it for | pause and resume, one-off snapshots | frequent checkpoints of a large VM that changes little |

Merge layers in the order they were taken, and use the state file from the same call as the last layer merged. `track_dirty_pages` is not saved in the snapshot: set it again on every `snapshot/load`.

We use Full only: our VMs pause once per idle period, and a Full file can be thinned afterwards (below). Diff pays off when you checkpoint a big VM often and little of its RAM changes.

## File or Uffd memory backend?

Firecracker does not read the memory file at load time. With `File` it maps it `MAP_PRIVATE`: pages load when the guest touches them, writes go to copy-on-write anonymous memory. Loading is fast, and the file must stay in place for the life of the VM.

| | `File` | `Uffd` |
|---|---|---|
| `backend_path` | the memory file | a Unix socket where your page fault handler listens |
| Who serves page faults | the host kernel | your own process, through userfaultfd (`UFFDIO_COPY`) |
| Extra code | none | a handler you write and monitor (an example ships in the repo) |
| 2M hugetlbfs pages (`huge_pages: "2M"`) | rejected | supported |
| Failure mode | none of its own | if the handler dies, Firecracker hangs on the next fault, "forever" |
| Host setup on kernel 6.1+ | none | access to `/dev/userfaultfd` (the jailer exposes it in the jail) |
| Pick it when | the snapshot sits on a local disk | you prefetch pages, stream memory from the network, or need hugetlbfs |

On our host, `LoadSnapshot` with `File` takes 5-21 ms and sshd answers 45-74 ms after the load request, so Uffd has little to win for us. The cost of lazy loading shows up later, as slow first touches when the file has left the page cache.

## How fast is snapshot and restore?

Our measurements, 2 vCPUs and 4 GiB of guest RAM, Firecracker v1.17.0, no CPU template:

| Step | `sync_snapshot_files: true` | `sync_snapshot_files: false` |
|---|---|---|
| `PATCH /vm` Paused | 9-10 ms | 9-10 ms |
| `snapshot/create` Full | 17.7-22.5 s | 2.0-7.2 s, depending on the host's writeback backlog |
| kill, move files, clean up | about 0.6 s | about 0.6 s |
| new process until the API answers | 35 ms | 35 ms |
| `snapshot/load` with `resume_vm` | 15-21 ms | 16-20 ms |
| load request → guest sshd banner | 45-64 ms | 48-74 ms |

Source: flockvm `host/README.md`, 2026-10-30. End to end through our host daemon (`host/flockd/README.md`, 2026-10-31): a pause takes 2.6-3.3 s on a quiet host, 7.5-17 s while the host writes other data back; a resume takes 0.30-0.43 s to `running` with sshd answering, 0.67-0.82 s to an SSH login from a Mac in France.

**Snapshot creation is bounded by the disk, not by Firecracker.** With `fsync`, writing 4 GiB took 17.7-22.5 s, which is 4,096 MiB ÷ 22.5 s ≈ 182 MiB/s to 4,096 MiB ÷ 17.7 s ≈ 231 MiB/s on these SATA SSDs. A full snapshot also faults every guest page in, so the file is as big as the RAM you gave the VM, not the RAM it uses.

**Restore is cheap because no memory is copied.** After resume, a process started before the pause has the same PID, 1 GiB in tmpfs matches its md5, `boot_id` is unchanged, and an outside SSH session kept running. The docs are more careful: packet loss is expected and connections are "not guaranteed" to survive.

## Should sync_snapshot_files be true or false?

`sync_snapshot_files` arrived in Firecracker 1.17.0 and defaults to `true`: Firecracker `fsync`s both files before the request returns. With `false` it returns as soon as the data is in the host page cache; "same-host reads still see the full contents" and only durability across a host crash is lost. Block device files are `fsync`ed either way.

We run with `false`, which turned up two problems.

**The page cache is charged to the VM's cgroup.** Under a `memory.max` limit, writing a 4 GiB memory file pushes the process into reclaim. Our daemon lifts `memory.max` before the pause.

**Finalizing the snapshot right after the pause slows down an early resume.** A memory file is 4 GiB even when the guest uses little of it. `fallocate --dig-holes` removes the zero pages: 4.0 GiB became 177 MiB for an idle VM, and 1.2 GiB for a VM holding 1 GiB of random data in tmpfs, in about 16 s; the restore still works. Our first version dug the holes and then `fsync`ed right after each pause. Measured on 2026-10-31 (commit `b2f4b3a`, `host/flockd/README.md`):

| Resume a few seconds after the pause | Resume time |
|---|---|
| while `--dig-holes` runs | 1.2-3.6 s (7 runs); `LoadSnapshot` itself 5-63 ms, then sshd 0.6-3.2 s later |
| while the `fsync` runs (fsync first) | 3.2-12.3 s (4 runs) |
| neither: the kernel writes the file back on its own | 0.73-0.94 s, idle or busy VM; 0.32 s when resumed 30 s after the pause |
| after the snapshot is finalized | 0.30-0.50 s |

Digging holes evicts pages from the page cache while keeping the disk busy, so the guest faults them back from a busy disk. The `fsync` hurt for a reason outside Firecracker: our daemon's SQLite commit waited behind gigabytes of writeback (ext4, `data=ordered`). The fix: finalize (holes, then `fsync`) only once the VM has stayed paused for 2 minutes; a resume, stop or delete cancels the wait.

The cost: a host crash in the ~2.5 minutes after a pause loses the memory state. The disk survives and the VM boots cold. If that is not acceptable, keep `true` and its 18-23 s snapshot.

## Why is the guest clock wrong after a restore?

The docs say a restored VM resumes with its wall clock "continuing from the moment of the snapshot creation". On x86_64 with the `kvm-clock` clock source and a host kernel 5.16 or later, `"clock_realtime": true` in `snapshot/load` advances the clock at restore time. It is opt-in since Firecracker 1.16.0, which fixed the monotonic clock jumping by the paused time by default (CHANGELOG #5809). The docs warn that the guest sees the clock jump suddenly.

What we found: our guests used the `tsc` clock source, on which `clock_realtime` has no effect. After each restore the clock lagged by the paused time until systemd-timesyncd fixed it about 18 s later. Booting with `clocksource=kvm-clock` plus `clock_realtime: true` put it within ±0.01 s of the host at resume; timesyncd stays as a safety net.

## What breaks when you restore one snapshot more than once?

Restoring one snapshot into several VMs is what people call forking a VM. The docs: "we consider resuming execution from the same state more than once insecure", because whatever the guest assumed unique is duplicated. Snapshot A, terminate it, load once in B: secure. Resume A **and** load in B: both insecure. What gets duplicated:

- **Kernel entropy.** Firecracker always enables the VMGenID device. Guests on Linux 5.18 or later reseed their kernel random number generator when it changes at restore. The docs still recommend the full reseed (`RNDADDENTROPY` then `RNDRESEEDCRNG`) to avoid a race, a `virtio-rng` device, and deleting `/var/lib/systemd/random-seed`.
- **Everything above the kernel.** Cached random numbers, identifiers and tokens "will still be replicated". VMClock's `vm_generation_counter` lets userspace notice a restore; it needs guest kernel patches merged in Linux 7.0.
- **Network identity.** Every copy comes back with the same TAP name, MAC and IP. The docs' example puts each clone in its own network namespace (jailer `--netns`) and rewrites addresses with iptables NAT; `network_overrides` handles the TAP name.
- **vsock.** The device is reset at `snapshot/create`; on resume open vsock connections are closed, listening sockets survive. Clients must reconnect.
- **`boot_id`** stays the same; bind-mount another file over it if that matters.

flockvm does not fork VMs today: each snapshot is restored once, into the same VM, the docs' secure case. How flockvm's pause and resume use these snapshots is in [How flockvm works](/docs/get-started/how-it-works#pause-and-resume). Forking is what flockvm is building next, and this list is its checklist. E2B and Daytona already fork with memory, and so does Morph Cloud, which calls it branching; see [flockvm vs E2B](/compare/flockvm-vs-e2b), [flockvm vs Morph Cloud](/compare/flockvm-vs-morph-cloud) and [E2B alternatives](/compare/e2b-alternatives).

## Can you restore on another host or another Firecracker version?

The docs require a software and hardware configuration identical to the one the snapshot was taken on.

- **Firecracker version.** Each binary supports one snapshot format version, separate from its own (`firecracker --snapshot-version` prints it). The bitcode encoding allows no backwards-compatible change, so any state change bumps `MAJOR`. In practice it moves often: 9.0.0 in v1.15.1, 10.0.0 in v1.16.0, 11.0.0 in the v1.16.2 patch release, 12.0.0 in v1.17.0 (`SNAPSHOT_VERSION` in `src/vmm/src/persist.rs`). Treat every Firecracker upgrade as a snapshot break, or upgrade with no paused VM.
- **Host kernel.** Same kernel is fine. Across kernels it "is considered unstable"; the docs list one known-good case on AWS metal instances (5.10 to 6.1, same instance type, one direction only).
- **CPU.** Another CPU model needs a CPU template common to both hosts; without one on x86_64, `MSR_IA32_TSX_CTRL` writes are lost. Our Ivy Bridge restores fine with no template on the same host; the static templates (T2, T2S, C3, T2CL) target Skylake and later, so moving would need the same CPU or a custom template from `cpu-template-helper`.
- **arm64.** No restore between GICv2 and GICv3 hosts.
- **cgroups v1.** The docs report high restore latency and "strongly recommend" cgroups v2.

## What other pitfalls show up in practice?

- **Never write to a loaded memory file.** It backs guest RAM and modifying it "corrupts the guest memory". Since `snapshot/create` overwrites existing files, the next snapshot to the same inode corrupts the running VM: always write a new file. Unlinking the old one is safe.
- **Plan disk for RAM-sized files.** 7 paused 4 GiB VMs need 7 × 4 GiB = 28 GiB before thinning. The docs say integrators "must" enforce quotas if users trigger snapshots; our daemon refuses a pause when free disk is below the memory size plus a reserve.
- **Do not snapshot during early boot.** VMGenID injects an interrupt at restore; if the guest kernel has not finished booting, it may not handle it and can crash. Take snapshots after boot.
- **The filesystem stalls after a big write.** After a multi-GiB snapshot, a new process sometimes took seconds to create its API socket (we wait up to 10 s), and a resume took up to 1.3 s (ext4 journal stalls).
- **Used RAM stays in the file.** `--dig-holes` only removes pages that are all zeros, and there is no balloon device on our VMs to hand memory back, so a VM that once filled its RAM keeps a large memory file.

## Where flockvm uses this today

flockvm gives each coding agent its own Firecracker microVM; pause and resume are the sequence above (Full, `sync_snapshot_files: false`, `File`, `kvm-clock` with `clock_realtime`, deferred finalize). Sign-ups are open (Google, GitHub or an email link) with a [7-day free trial](/pricing), card required and nothing charged for 7 days, and it runs on one host in France (OVHcloud), up to 15 `small` VMs at a time (see [EU data residency](/eu-data-residency)), billed per second. No fork, secrets proxy or region outside France yet.

Choosing rather than building? [Firecracker as a sandbox](/firecracker-sandbox) covers what you build around Firecracker, and the managed options, [running Claude Code agents in parallel](/learn/run-claude-code-agents-in-parallel) goes from worktrees to one VM per agent, and [coding agent swarms](/use-cases/coding-agent-swarms) covers swarms of 10 to 20 agents, the next step flockvm is building. For a managed service built on these snapshots, [flockvm vs CodeSandbox SDK](/compare/flockvm-vs-codesandbox) compares one that forks and resumes Firecracker VMs from memory.

## Sources

- [Firecracker v1.17.0 docs: Snapshot support](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/docs/snapshotting/snapshot-support.md) (accessed 2026-10-31)
- [Firecracker v1.17.0 docs: Handling snapshot memory loading (userfaultfd)](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/docs/snapshotting/handling-page-faults-on-snapshot-resume.md) (accessed 2026-10-31)
- [Firecracker v1.17.0 docs: Snapshot versioning](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/docs/snapshotting/versioning.md) (accessed 2026-10-31)
- [Firecracker v1.17.0 docs: Entropy for clones](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/docs/snapshotting/random-for-clones.md) (accessed 2026-10-31)
- [Firecracker v1.17.0 docs: Network connectivity for clones](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/docs/snapshotting/network-for-clones.md) (accessed 2026-10-31)
- [Firecracker v1.17.0 docs: Snapshot editor](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/docs/snapshotting/snapshot-editor.md) (accessed 2026-10-31)
- [Firecracker v1.17.0 API definition (firecracker.yaml)](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/src/firecracker/swagger/firecracker.yaml) (accessed 2026-10-31)
- [Firecracker CHANGELOG (1.13.0 to 1.17.0)](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/CHANGELOG.md) (accessed 2026-10-31)
- [Firecracker v1.16.2 CHANGELOG (#6100: snapshot format bump)](https://github.com/firecracker-microvm/firecracker/blob/v1.16.2/CHANGELOG.md) (accessed 2026-10-31)
- [Firecracker v1.17.0 snapshot format version (persist.rs)](https://github.com/firecracker-microvm/firecracker/blob/v1.17.0/src/vmm/src/persist.rs) (accessed 2026-10-31)
- [Firecracker release v1.17.0 (published 2026-09-10)](https://github.com/firecracker-microvm/firecracker/releases/tag/v1.17.0) (accessed 2026-10-31)
- [Morph Cloud docs: Branch](https://cloud.morph.so/docs/documentation/instances/branch) (accessed 2026-10-31)
- [Morph Cloud docs: Snapshots (memory and disk state)](https://cloud.morph.so/docs/documentation/instances/creating-snapshot) (accessed 2026-10-31)
