Skip to content

S06-05 - Disks

Purpose: A VM’s system disk and data disk: how the data disk keeps what the guest flushes, and how the guest mounts it. How the host formats it is in S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk..

A VM has two writable disks:

The data disk is a raw sparse image file. Its nominal size is the most it can grow to. That size is a setting, read when a disk is made and bounded in code. A new disk takes almost nothing on the host until the guest writes to it. It is attached with automatic host caching and full synchronization. On macOS that is VZDiskImageStorageDeviceAttachment with VZDiskImageCachingModeAutomatic and VZDiskImageSynchronizationModeFull. So every write the guest flushes reaches permanent storage on the host.

A raw image gives the host back the space of data the guest deletes. An ASIF image does not (X05-fs-benchmarkX05-fs-benchmark: Filesystem benchmarkData disk with default versus relaxed write-through settings, against the host, on the NFR02-fs-speed workloads.). On the data volume, mounted nobrowse as “The mount” says, on macOS 27.0.1 the space comes back when the volume is unmounted or mounted again, not when the guest deletes. That is at a clean guest shutdown, or at the mounts of a cold boot (X08-data-diskX08-data-disk: Data disk for homesGuest user homes on a second disk, surviving a system-disk replacement., “Follow-up (I228I228 (closed): X08-data-disk follow-up: measure that a host-made data volume stays unencrypted and returns freed spaceX08-data-disk (PR #227) recommends option A: the host formats the data disk as APFS.)”). A restore from saved state (S06-06-devices-and-warm-startS06-06-devices-and-warm-start: Devices, Warm Start and TimeA VM's devices and resources, saving and restoring its state, and how the guest clock follows the host., “Warm start”) doesn’t mount again, so it doesn’t give the space back. Until then the file’s st_blocks still count the deleted data.

The space a data disk takes on the host comes from the file’s st_blocks, never from an image tool (SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too.). That space counts for SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped., and for the free-space check of S09-policy-credentials-auditS09-policy-credentials-audit: Policy, Credentials, Certificates and AuditWhere policy comes from, how secrets are held, how TLS inspection is trusted, and what is recorded..

Each VM bundle is a directory whose name ends in .noindex. So Spotlight doesn’t index the disks in it.

With these settings, npm ci on the data disk ran at about 71% of the host on a loaded host. That is under the 80% goal of NFR02-fs-speedNFR02-fs-speed: FilesystemThe workspace is on guest-native storage.. The goal is not a release gate.

A VM’s third disk is the read-only guest tools disk (S06-12-guest-agentS06-12-guest-agent: Guest AgentWhat wb-guestd, the service in the guest, does for the host, and how it updates itself., “Guest tools disk”). A VM bundle holds these files, each at its fixed name:

File What it holds
hw.bin the hardware model
mid.bin the machine identifier
aux.wbstore the auxiliary storage
sys.wbdisk the system disk
data.wbdisk the data disk
tools.img the copy of the guest tools disk

A spike puts an APFS clone of its own bundle at the bundle path, and that bundle names its guest-written files aux.img, sys.img and, when it has a data disk, data.img (“Names on the host” below). Whoever makes the clone renames those files in the clone to the names above, before wb-vmd opens it:

Terminal window
cd <data>/vms/macos-<slot>.noindex
mv -n aux.img aux.wbstore
mv -n sys.img sys.wbdisk
mv -n data.img data.wbdisk # only when the spike bundle has a data disk

Each file of an APFS clone is a separate file, so the rename doesn’t touch the spike bundle. A clone with the spike’s names is refused with bundle-file-missing.

Before it opens any of them, wb-vmd checks each one (S04-02-vm-providerS04-02-vm-provider: VM Provider and StreamsHow wb-vmd hands guest connections and the NIC endpoint to other processes, the fixed device set of a VM, and where wb-proxyd takes a stream's identity from., “The device set is fixed and checked”):

  • a missing file is refused with bundle-file-missing;
  • a file that isn’t a regular file with one link, such as a symbolic link, or whose real path isn’t inside the bundle’s real path, is refused with device-set-file-outside-bundle.

Any other file in the bundle is ignored. Device configuration never comes from the bundle.

wb-vmd boots only a bundle under <data>, which it takes from the user database (S04-04-vm-processesS04-04-vm-processes: Per-VM ProcessesOne wb-vmd for each VM, the wb-vmd-layer entry of the Claude Code layer build, the wb-vmd-recipe entry of a named image's recipe, and wb-diskfmt, which formats a VM's new data disk., “Slot checks”). The needs-vm tests boot their VMs under a data root of their own, so they never touch the real <data> of the Mac they run on. Only a test build has a test data root:

  • wb-vmd built with the Swift compile condition WB_TEST_DATA_ROOT takes <data> from the section __TEXT,__wb_test_data, which the test links into it. A missing section is refused with vmd-test-data-invalid, and so is one that isn’t valid UTF-8, holds a NUL or a newline, isn’t an absolute path, or is PATH_MAX bytes or longer. A build with the condition also has the marker section __DATA,__wb_test_build.
  • wb-diskfmt built with the Go build tag wbtestdataroot takes <data> from main.testDataRoot, which the test sets with -ldflags -X. It refuses to start without an absolute one.

The root is fixed when the program is linked. wb-hostd gives wb-vmd only its slot variable (S04-04-vm-processesS04-04-vm-processes: Per-VM ProcessesOne wb-vmd for each VM, the wb-vmd-layer entry of the Claude Code layer build, the wb-vmd-recipe entry of a named image's recipe, and wb-diskfmt, which formats a VM's new data disk., “The slot”), so neither program takes the root from its environment or from a request, and nothing the guest sends can move the root. The shipped wb-hostd takes <data> only from the user database. In a test, wb-hostd runs as the Go test binary, which takes <data> from a variable that only test code reads. Everything else is the same as in a release build: the slot checks, the real-path checks of the bundle and its files above, and the sandbox each program confines itself to (S04-03-self-sandboxingS04-03-self-sandboxing: Self-SandboxingHow each host daemon confines itself at startup, and the wb-launcher that starts confined programs on macOS.). The host shares no directory with the guest (SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise.), and it attaches no guest disk (SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too.).

app:bundle never sets the condition or the tag. The bundle check refuses a program with either section, in any segment, and a Go program whose build information holds the tag (S17-01-bundleS17-01-bundle: The BundleWhat a Wraith Box bundle holds, and how mise run build builds and signs it., “The entitlement check”), so a test build never ships.

The system disk, the auxiliary storage, the data disk and the saved state are guest-written once the guest has run. A file in the bundle that a guest writes has no extension that Launch Services opens as a disk image, no .img or .dmg, so a double click doesn’t make the host attach a guest-written image (SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too.). The saved state has no fixed name in the bundle yet, and the name it gets follows this rule.

The guest tools disk keeps .img. The host writes it, and the guest gets it read-only (S06-12-guest-agentS06-12-guest-agent: Guest AgentWhat wb-guestd, the service in the guest, does for the host, and how it updates itself., “Guest tools disk”).

Claude Code state and commits not yet pushed on the data disk are kept through a host crash or power loss. Tool caches may be lost. Caches share the one data disk, because full synchronization costs the NFR02-fs-speedNFR02-fs-speed: FilesystemThe workspace is on guest-native storage. workloads nothing measurable.

That full synchronization keeps every write the guest flushed through a host crash rests on Apple’s headers. X05-fs-benchmarkX05-fs-benchmark: Filesystem benchmarkData disk with default versus relaxed write-through settings, against the host, on the NFR02-fs-speed workloads. killed only the VM’s processes, and lost nothing the guest had flushed. So the target holds for what the guest flushes.

The system disk doesn’t need to keep anything through a crash, because a fresh clone of the image can replace it (S06-03-image-updatesS06-03-image-updates: Image UpdatesHow a VM gets a new image's system disk while its data disk and project users stay, and the guest admin password of each VM., “Updates”).

The host doesn’t check or repair a data disk (SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too.). wb-guestd refuses a data disk that it can’t mount, as it refuses a missing one (“Mounting the data volume” below). What was on that disk is lost.

wb-hostd never deletes a data disk on its own. The user runs wb vm reset-data (S05-03-management-commandsS05-03-management-commands: Management CommandsThe commands of wb other than the agent commands.). It deletes the old file, and has wb-diskfmt make a new one.

The host formats each new data disk before any guest has run with it, in the confined shim wb-diskfmt. That is the one exception SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too. makes, and S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk. has its steps and the checks before a VM starts with its disk.

wb-guestd mounts the data volume after first contact with wb-hostd, when the volume UUID arrives. wb-hostd sends it with GuestService.MountData before any other call, after every accepted hello of a VM run, the first one included. wb-guestd mounts the volume before it starts anything as a project user. The mount point is /private/var/wbhomes, a fixed path outside /Volumes, which holds the homes.

  1. wb-guestd waits up to 30 s for the volume with the UUID that the host recorded at format time. It identifies the volume only by that UUID.
  2. It checks that diskutil reports the volume unencrypted, both at rest and by FileVault. A report that doesn’t say counts as encrypted.
  3. By then Disk Arbitration has mounted it at /Volumes/<name>, without nosuid. So wb-guestd unmounts it.
  4. It mounts it at the home path with diskutil mount -mountOptions nobrowse,nosuid,nodev,owners, and runs the check of the next section on the mount.

wb-guestd gives up on the mount after 40 s in all, and answers with the refusal. wb-hostd waits 45 s for the answer.

An encrypted volume, a missing one, or one that fails the check is refused with the rule. wb-hostd keeps the VM running and the link up, and refuses every session start in the VM with that rule and the fix: stop the VM with wb vm stop, then wb vm reset-data (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.). wb vm status shows the refusal. A missing data disk record in state.db is refused the same way, but its fix doesn’t name wb vm reset-data, which deletes every home.

A mount that wb-guestd leaves unanswered for 45 s, or a call that fails with UNAVAILABLE, drops the link, and the next link asks again. Each accepted hello sets the mount back to pending, so no session starts on a new link until its mount succeeds.

The mount isn’t repeated while the guest runs. Once a process has run as a user whose home is under the mount point, macOS refuses another mount there until the next boot. So after a reconnect, wb-guestd finds the volume mounted already and only checks it. When the host still asks for the first mount, it checks the mount, then claims the root as the next section says, then checks the root.

wb-guestd reads the mount’s flags again with statfs. Guest root can change them in place with mount -u. It gains nothing by that, because guest root is already root.

No session starts unless that exact volume is mounted at the home path with every flag. The refusal is logged with the mount found and the rule (SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another.). Without nosuid, a setuid-root file that guest root left in a home gives a project user root, also after a swap.

The host formats the volume as the host user, so the guest may see the mount root with another owner or mode. On a volume’s first mount, wb-guestd logs the root’s owner and mode as it found them (“data volume root before its first claim”). It then gives the root to root:wheel with mode 755, by fchown and fchmod on a descriptor opened without following a link. wb-hostd records the first mount that succeeded in state.db and asks for this only until then. A reformat of the data disk clears the record.

wb-guestd checks with lstat, never following a link:

  • that the mount root is a real directory owned by root:wheel, with mode 755;
  • that each home is a real directory owned by its user’s kept UID and GID, with mode 700.

A home that fails is refused to its user, with the rule logged. The other users go on.

A new home is made with mkdir on a path that doesn’t exist yet. It is never made by createhomedir into an existing path. It is then given to its user with fchown on the descriptor of the new directory, or lchown. So a link put in its place is never followed.

When it creates a user, wb-guestd refuses a UID or GID that owns any top-level entry on the volume other than that user’s own home. It logs the rule.

wb-guestd keeps session records in a root-owned directory on the data disk (S06-09-session-lifecycleS06-09-session-lifecycle: Session LifecycleA session's states from wb claude to its summary, how it starts and ends, its deadlines, and when its VM may be saved.). That directory is checked the same way. Its contents are parsed as untrusted input, because guest root may have written them.

Full synchronization, not the relaxed modes

Section titled “Full synchronization, not the relaxed modes”

Claude Code state and commits not yet pushed are kept. Tool caches may be lost. A data disk the guest can’t mount after a crash is lost.

Bundle names that a double click doesn’t mount

Section titled “Bundle names that a double click doesn’t mount”

Status: Draft