# Seaweed Block
[](docs/releases/README.md)
[](https://github.com/seaweedfs/seaweed-block/actions/workflows/test.yml)
[](go.mod)
[](LICENSE)
**Local-first block storage for AI agents.**
*Run locally. Persist incrementally. Resume anywhere.*
Seaweed Block gives each agent sandbox or microVM its own block disk on the host's local storage, and checkpoints the
changed data to your own [SeaweedFS](https://github.com/seaweedfs/seaweedfs). Writes and `fsync` complete locally;
checkpoints, named snapshots and restores carry the workspace's state beyond that host. High density per host is a
design goal; see [Vision](#vision).
**[Quick start](#quick-start)** · [How it works](#how-it-works) · [Project status](#project-status) ·
[Documentation](#documentation)
## Why not just use...
| | Local disk | Conventional network block storage | Seaweed Block |
|---|---|---|---|
| Where writes and `fsync` complete | On the host | Typically on a remote storage service | On the host |
| Network in the I/O path | No | Typically, for every read and write | No, for data on the host; a restored or moved volume fetches chunks on first read |
| If the host is lost | The state is lost with it | The volume typically survives | The state survives up to its last confirmed checkpoint |
| Resume on another host | Copy the data yourself | Typically, detach the volume and attach it there | Move the volume there, or restore a snapshot into a new volume there (placed by the cluster spec) |
| What persistence sends | Nothing | Typically every write, as it happens | Only the whole 4 MiB chunks that changed, at each checkpoint |
## Run, checkpoint, snapshot, restore
1. **Run.** Start a volume on the host where the agent runs. The guest attaches it over NVMe/TCP or iSCSI, formats it
with its own file system, and works at near-local speed.
2. **Checkpoint.** The changed chunks go to your SeaweedFS: on demand (`sw-block ops chunk cut`), periodically (the
holder's `--chunk-capture-interval`, 5 minutes or more), with the default daily snapshot, and when you stop the
volume (`sw-block volume stop`).
3. **Snapshot.** `sw-block volume backup --name ` (or `sw-block ops chunk snapshot`) names a point in
time. Snapshots share chunks with each other.
4. **Restore.** A restore makes a new volume from a snapshot, on the host that its placement in the cluster spec
names. It serves at once and fetches chunks on first read.
The commands and what each needs: [snapshots, restore and verification](docs/operations-manual.md#5-snapshots-restore-and-verification).
## Features
- **Near-local speed for agent workloads.** Writes and `fsync` complete on the host's disk, with no network round
trip, and every guest `fsync` reaches it.
- **Any file system, unchanged tools.** The guest sees a plain block device, so `git`, `npm` and builds run as on a
local disk.
- **Incremental checkpoints.** Only the changed 4 MiB chunks upload: on demand, periodically, or with the daily
snapshot.
- **Snapshots and instant restore.** Named snapshots share chunks, and a restored volume serves before its data
arrives.
- **Safe moves between hosts.** Epochs and leases fence the old host, so a stale host cannot publish over the
workspace's state.
- **Self-hosted and open source.** Your data stays in your SeaweedFS. Apache-2.0, written in Go.
## Use cases
- **AI coding agents** whose repositories, dependencies and build caches must outlive the sandbox.
- **Agent sandboxes and microVM platforms** that give each sandbox its own disk.
- **Long-running agents** that stop, resume and move between hosts.
- **Also:** Kubernetes block volumes through the CSI driver (alpha), and replicated volumes for workloads that need
synchronous copies (`sync-quorum`, `sync-all`; preview).
## One engine, two durability profiles
Agent workspaces are the focus. The same block engine (write-ahead log and extent, NVMe/TCP and iSCSI frontends,
blockmaster's epochs) also runs replicated volumes, for workloads that need copies on other hosts before `fsync`
completes (`sync-quorum`, `sync-all`).
| | Checkpointed volume | Replicated volume (preview) |
|---|---|---|
| Built for | Agent workspaces: many independent, portable disks | Workloads that need online copies on other hosts |
| When `fsync` completes | Once the data is on the host's local disk | With `sync-quorum` or `sync-all`, once a quorum or every replica has it (the default `best-effort` waits for none) |
| After a host is lost | An operator's forced move continues from the last checkpoint in SeaweedFS | With `--cluster-spec` and the lifecycle loop enabled (`--lifecycle-product-loop-interval`, off by default), blockmaster fails a `sync-quorum` or `sync-all` volume over to a replica when its fencing round decides; the operator then starts the guest on the new primary's host (no path failover in the guest). `best-effort` is not failed over automatically; the operator's forced failover may lose the last acknowledged writes |
| Snapshots, restore, moves | Yes | Not yet: the two profiles cannot be combined in v1.1.x |
| Status in v1.1.x | Supported | Preview, with [known limits](docs/releases/replicated-volumes-preview.md) |
The two biggest limits of the preview: a replica that falls behind the retained log needs a manual re-add, and a
primary cut off from blockmaster is not stopped by a lease, so it may serve stale reads and, under `best-effort`,
accept writes that are later lost. Do not use replicated volumes for data you cannot lose.
A workload chooses the durability it needs: a checkpointed workspace does not pay for synchronous replicas, and a
replicated volume does not wait for checkpoints.
## Performance
Metadata-heavy agent work runs at local-disk speed, timing the operation itself (with the guest's final `syncfs`, 11-23%
slower); `fsync` latency and `fsync`-bound work are 1.3 to 1.5 times local. These are lab runs of pre-release builds
(the first four rows on the `walstore` engine, the last two on `walstore-chunk`) on Firecracker microVMs over NVMe/TCP
loopback, median of 3: measurements, not SLOs. Every number and how it was measured, with the build where it was
recorded: [workspace measurements](docs/workspace-measurements.md).
## Quick start
A trial on a disposable Linux host, not for data you keep. You need `nvme-cli`, `sudo`, and SeaweedFS's `weed`
binary, tested with SeaweedFS 4.53 (from its [release page](https://github.com/seaweedfs/seaweedfs/releases/tag/4.53),
asset `linux_amd64.tar.gz`, which holds the one `weed` binary).
```bash
TAG=v1.1.1
curl -fsSLO https://github.com/seaweedfs/seaweed-block/releases/download/$TAG/sw-block-$TAG-linux-amd64.tar.gz
curl -fsSLO https://github.com/seaweedfs/seaweed-block/releases/download/$TAG/SHA256SUMS
sha256sum -c --ignore-missing SHA256SUMS && tar -xzf sw-block-$TAG-linux-amd64.tar.gz
export PATH="$PWD:$PATH" # so the sw-block commands that mini prints run as shown
./blockvolume --version # must print the tag's commit
# blockvolume keeps one lock per volume here, so only one live process serves a volume on a host:
sudo install -d -m 0755 -o root -g root /run/sw-block
sudo install -d -m 0755 -o "$USER" -g "$(id -gn)" /run/sw-block/locks
./sw-block mini --dir ./swb-mini --weed /path/to/weed
```
A failed start leaves `--dir` behind: start again with a new `--dir`, or on the same one with `--reuse`.
**What it shows today:**
- `mini` starts `weed mini`, `blockmaster` and one `blockvolume`: volume `v1`, 256 MiB, on loopback.
- It never runs `sudo` itself. It prints the `nvme connect` command that attaches `v1`, and the status, check and
snapshot commands. After the connect, `sudo nvme list` shows the disk's device (for example `/dev/nvme0n1`).
- Snapshots of `v1` work at once, through the `sw-block ops chunk snapshot` command it prints. A scheduled
`sched-