Computers

Branch a computer

Create a computer with its own copy of the source's data disks

Branch demo as demo-branch, change the branch's data, and confirm demo stays the same. A branch of a running computer starts from the source's image and private copies of its data disks, and keeps the same environment and size. To restore saved memory as well as disks, create and restore a checkpoint.

You need the CLI installed and signed in, with a selected workspace where you have the admin or editor role. Use demo from Create a computer, and keep the name demo-branch free.

The example writes a file to your home directory, which lives on the computer's persistent disk and is where commands start. That disk exists only when the deployment has a storage pool. Files written elsewhere in the container's writable filesystem don't carry over when you branch a running source.

Branch

nevia status demo

You can branch a ready or sleeping computer with no pending transition or running operation. This example uses ready so you can run commands on both computers. If demo is sleeping, wake it first.

Write a small scratch file:

nevia exec demo -- sh -c 'printf "original\n" > branch-note && sync'

A running source can reuse a disk snapshot less than five seconds old, so wait five seconds after writing the file. Otherwise the branch may miss it:

sleep 5
nevia branch demo-branch --source demo --wait
nevia status demo-branch

demo-branch should be ready, with no pending transition. The source keeps running; disk writes pause briefly while it takes a fresh snapshot.

Check the copy

Read the file on the branch:

nevia exec demo-branch -- cat branch-note

It prints original. Overwrite the branch's copy, then read both files:

nevia exec demo-branch -- sh -c 'printf "branch\n" > branch-note'
nevia exec demo-branch -- cat branch-note
nevia exec demo -- cat branch-note

The branch prints branch. The source still prints original.

Clean up

If you protected the branch, clear protection before deleting it. Deleting it also removes any checkpoints you took of it, and fails while a live computer restored from those checkpoints exists.

Delete the branch and its data:

nevia rm demo-branch --yes --wait

Remove the source's scratch file:

nevia exec demo -- rm branch-note

See Computer lifecycle states for deletion constraints and nevia branch for command options.

On this page