new --attach) or
onto an already-running VM (disks attach) — and its data survives
suspend/resume and VM destruction — the disk keeps living (and billing) until
you remove it. Disks are billed per GB-hour while they are READY
(~$0.1667/GB/month).
Disks are durable but not backed up — removing a disk (or deleting files
on it) is permanent.
Once mounted, the disk is owned by the VM’s normal login user (not root),
so it’s writable without sudo out of the box.
disks new
Create a disk. The command returns immediately with the disk in aCREATING
state; it becomes READY on its own, usually within seconds (check with
disks ls).
disks ls
List your disks.Attached To names the VM the disk is currently attached to, with
(attaching...) or (detaching...) while an attach/detach is still in
flight. A disk in ERRORED state failed to provision — run disks get <name>
for the error, then disks rm <name> to clean it up and create it again.
disks get
Show a disk’s details — status, size, region, cost, and which VM it’s attached to.ERRORED disks the provider error is shown (for example, a volume quota
being exhausted) so you know whether recreating will help.
disks rm
Remove a disk and all of its data, permanently. Refused while any VM (including a suspended one) is still attached to the disk — destroy the VM first.disks ls at once
and its name is instantly reusable, while the volume is deleted in the
background. disks rm also works on CREATING disks (cancels provisioning)
and ERRORED disks (cleanup).
disks attach
Attach aREADY disk to an already-running VM.
attaching...
state; disks get/disks ls show ATTACHED once the disk is actually
mounted inside the VM. The disk must be READY, in the same region as the
VM, and not attached to another VM; the VM must be RUNNING and have a
managed SSH key (the same requirement as machine0 ssh) — a VM created with
your own public key can’t be attached to post-hoc. Up to 5 disks can be
attached per VM, and mount paths can’t be nested inside one another. Not yet
supported on GPU sizes or NixOS VMs.
Disks attached with disks attach persist across reboots and suspend/resume,
same as disks attached at VM creation.
disks detach
Detach a disk from the VM it’s attached to.detaching...
state; the disk disappears from the VM (unmounted and disconnected) once the
job finishes. If the VM has an open file handle on the mount path, the detach
retries rather than forcing it; if it still can’t unmount after a few
minutes, the attachment returns to attached — stop whatever is using the
mount path and run disks detach again.
Like disks attach, detaching needs the VM RUNNING with a managed SSH key
(the same requirement as machine0 ssh) — the command fails immediately with
the reason otherwise. A disk attached to a VM created with your own public
key can’t be detached at all (the server can’t SSH in to unmount safely);
destroying the VM releases the disk.
A disk still attaching... can’t be detached yet — wait for the attach to
finish (or fail) first, then retry.
Attaching disks: new --attach
Attach disks when creating a VM with the repeatable --attach flag on
machine0 new. Each use takes two values: the disk and
the absolute path to attach it at.
/, _, -), cannot be
inside system directories (/etc, /usr, /var, …), and cannot be nested
inside one another (e.g. /data and /data/code) — this applies across all
disks attached to the VM. The disk must be
READY, in the same region as the VM, and not attached to another VM. Up to
5 disks can be attached per VM. Attachments survive reboots and suspend/resume
— on resume the disk is re-attached with its data intact. Disks are not yet
supported on GPU sizes or NixOS VMs.
Creation-time attachments work on any eligible VM (they don’t need SSH), including
one created with your own public key (-k) — but note that such a disk
can’t be detached later (disks detach needs server SSH
access); destroying the VM is what releases it.
To attach a disk to a VM that’s already running (instead of at creation
time), use disks attach / disks detach.