Files
seaweedfs/seaweed-block/README.md
T
Ping QiuandClaude Opus 5.5 a5686e7fa7 Sync seaweed-block v1.1.1 into seaweed-block/ (#13411)
Brings seaweed-block main (v1.1.1 plus the docs and a test fix after it)
into seaweed-block/ as one commit. Only files under seaweed-block/ change,
and the subtree equals seaweed-block main exactly. The module's full
history stays in the seaweed-block repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 19:04:53 -08:00

232 lines
16 KiB
Markdown

# Seaweed Block
[![tag](https://img.shields.io/github/v/tag/seaweedfs/seaweed-block?sort=semver&label=release)](docs/releases/README.md)
[![CI](https://github.com/seaweedfs/seaweed-block/actions/workflows/test.yml/badge.svg)](https://github.com/seaweedfs/seaweed-block/actions/workflows/test.yml)
[![Go](https://img.shields.io/github/go-mod/go-version/seaweedfs/seaweed-block)](go.mod)
[![License](https://img.shields.io/github/license/seaweedfs/seaweed-block)](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)
<p align="center">
<img src="docs/assets/seaweed-block-lifecycle.svg" alt="The Seaweed Block lifecycle. Run locally: agent VMs on host A write to the host's local disk, where writes and fsync complete with no network round trip. Persist incrementally: checkpoints send only the changed 4 MiB chunks to your SeaweedFS in the background, and named snapshots share those chunks. Resume anywhere: host B restores a snapshot into a new volume, or takes a volume over in a planned move; it serves at once and fetches chunks on first read. Normal I/O to locally available data stays on the host." width="100%">
</p>
## 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 |
<p align="center">
<img src="docs/assets/seaweed-block-storage-models.svg" alt="Three ways to give an agent VM a disk. Local disk: all I/O stays on the host, fast, but the state is tied to that host. Network block storage: I/O typically crosses the network to a remote volume, so the state outlives the host, but the network is in the I/O path. Seaweed Block: normal I/O to locally available data stays on the host's local disk, and changed chunks go to your SeaweedFS in the background, so it runs at near-local speed and the state outlives the host up to its last checkpoint." width="100%">
</p>
## 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 <volume> --name <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
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/measured-results-dark.svg">
<img src="docs/assets/measured-results-light.svg" alt="Time on Seaweed Block relative to a local disk, over NVMe/TCP loopback: npm ci 1.00, git clone 1.02, untar 100,000 files 1.04, cold find and stat 0.97, 2,000 create plus write plus fsync 1.52, guest fsync median 1.31." width="100%">
</picture>
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-<time>` snapshot also appears soon after the start. A restore into a new volume does not run inside `mini`
yet; use the standalone setup for it.
- To stop: unmount `v1`, run the `sudo nvme disconnect` that `mini` printed, then press Ctrl-C.
**Next:**
- Other ways to install (the release image, a build from the tag): [operations manual](docs/operations-manual.md#1-install-the-binaries-and-units).
- Services, restore and a second host: [standalone deployment](docs/standalone-deployment.md) and
[two hosts and a planned move](docs/operations-manual.md#appendix-b-two-hosts-and-a-planned-move).
- Kubernetes (alpha): [Kubernetes quick start](docs/quickstart-kubernetes.md), with v1.1.1. v1.1.0's generated pod
cannot start.
## How it works
- **Local execution.** `blockvolume` serves the guest's block device over NVMe/TCP or iSCSI on the same host. A write
lands in a local write-ahead log, and `fsync` completes once the data is on the host's disk. The log then drains
into a local extent.
- **Incremental persistence.** A checkpoint (a *cut* in the CLI and the manuals) uploads the volume's changed 4 MiB
chunks to SeaweedFS. It then advances the volume's HEAD root with a conditional update on its generation and epoch.
A snapshot names a root and shares chunks with the others, with no backing chain.
- **Recovery and mobility.**
- A restore makes a new volume that serves at once and fetches each chunk from the snapshot on first read.
- One `blockmaster` issues epochs and leases, and the holder of a checkpointed (single-replica) volume serves only
under its current lease.
- A planned move first seals the volume with a final checkpoint, then revokes the old holder, waits for its recorded
release, and grants the next epoch on the new host, which loads chunks on first read.
- The store refuses a HEAD update from a stale holder, even before that holder notices it was replaced.
<p align="center">
<img src="docs/assets/seaweed-block-hero.svg" alt="Write path: a microVM writes over NVMe/TCP or iSCSI to blockvolume, which completes write and fsync on its local WAL. Background path: a checkpoint uploads changed 4 MiB chunks to SeaweedFS and updates HEAD on generation and epoch; blockmaster issues epochs and leases; a stale holder's update is refused." width="100%">
</p>
More: [agent workspace design](docs/design/agent-workspace-design.md), [volume lifecycle](docs/volume-lifecycle.md),
and the [TLA+ specifications](docs/spec/README.md) of the protocols where a bug would lose data.
## Durability model
| Level | Reached when | Where the data is | What it protects against |
|---|---|---|---|
| Local synced | the guest's `fsync` returns | the holder host's disk | a crash or restart of the processes on that host |
| Remotely checkpointed | a checkpoint is confirmed (after its commit in SeaweedFS) | SeaweedFS | the loss of the host: a forced move continues from the last confirmed checkpoint |
| Named snapshot | a snapshot command answers ok | SeaweedFS, kept by name | a restore into a new volume at that point (in v1.1.x, not for a snapshot of a restored volume) |
- **Writes since the last confirmed checkpoint are lost if the host is lost.**
- **The default schedule is one snapshot a day.** It is attempted, not guaranteed, and it is not a recovery-point
objective. Periodic checkpoints (`--chunk-capture-interval`, 5 minutes or more) shorten the window. A persistent
agent should checkpoint at its task boundaries.
- **`sw-block volume stop` takes a checkpoint by default** (`--no-cut` skips it). A holder stopped any other way
(`systemctl stop`, a kill, or the loss of its host) takes none.
- **No production SLO, RPO or RTO is claimed.** Details: [operator guide](docs/operator-guide.md).
## Project status
| Capability | v1.1.x |
|---|---|
| Local single-replica volumes (`walstore-chunk`) | Supported |
| NVMe/TCP and iSCSI | Supported; in a standalone setup the guest runs on the holder's host |
| Incremental checkpoints | Supported |
| Named snapshots and lazy restore into a new volume | Supported |
| Planned moves between hosts (operator-run, fenced) | Supported |
| Volumes up to 1 TiB | Supported; above 256 GiB only at format level 1 (new clusters start at it; upgraded clusters run `sw-block cluster finalize-format`) and only after every host runs v1.1 |
| Replicated volumes (`replication_factor` above 1) | Preview: no snapshots, restore or moves; a replica that falls behind the retained log needs a manual re-add ([limits](docs/releases/replicated-volumes-preview.md)) |
| Kubernetes CSI | Alpha; in v1.1.x deleting a PVC may leave its volume behind, and that volume cannot be removed until v1.2 |
| Remote guests in a standalone setup, authenticated remote NVMe/TCP | Not in v1.1.x |
| Templates, instant fork | Not in v1.1.x |
Use tagged releases only: `main` is unreleased work. Each release's conditions are in the
[capabilities](docs/releases/capabilities.md) table and the [release notes](docs/releases/README.md).
## Vision
Directions, not commitments; no dates.
- **Lightweight execution:** more volumes per host and less overhead per volume.
- **Instant workspaces:** shared templates, fast creation, branching.
- **Continuous persistence:** efficient rolling checkpoints.
- **Portable state:** recovery, migration and resume across hosts with less operator work.
- **Storage efficiency:** remote space that is reclaimed and reused, and rolling persistence with low write
amplification.
- **Flexible durability:** replicated volumes out of preview, and replicas combined with checkpoints and snapshots in
SeaweedFS.
## Documentation
| To | Read |
|---|---|
| Try it, run the services, restore a snapshot | [Standalone deployment](docs/standalone-deployment.md) |
| Install, upgrade, finalize, monitor, read typed errors | [Operations manual](docs/operations-manual.md) |
| Size a host, choose a recovery point, handle host loss | [Operator guide](docs/operator-guide.md) |
| Move, revoke, delete | [Volume lifecycle](docs/volume-lifecycle.md) |
| Run on Kubernetes (alpha) | [Kubernetes quick start](docs/quickstart-kubernetes.md), [Kubernetes status](docs/kubernetes-status.md) |
| See what each release supports | [Capabilities](docs/releases/capabilities.md), [release notes](docs/releases/README.md) |
| Check the numbers | [Workspace measurements](docs/workspace-measurements.md) |
| Read the architecture and formal specifications | [Agent workspace design](docs/design/agent-workspace-design.md), [core design](docs/design/block-design.md), [TLA+ specifications](docs/spec/README.md) |
## Community and license
Questions and bug reports: [GitHub Issues](https://github.com/seaweedfs/seaweed-block/issues). To build and test:
`go build ./... && go vet ./... && go test -short ./...` (the unit checks; CI also runs the process-level suite).
Seaweed Block builds on [SeaweedFS](https://github.com/seaweedfs/seaweedfs). License: Apache-2.0.