COPIES(7)Miscellaneous Information ManualCOPIES(7)

copies — first-boot scripts, copies and sizes

‘new -s’ runs a script once, as , on the first boot. /dev/stdin reads it from your side:

$ cat setup.sh
doas pkg_add -I git go
git clone https://github.com/alice/app
$ ssh chroot.dev new -n app -w -s /dev/stdin < setup.sh

Copying a running VM copies its memory too: the copy resumes with the same processes. Prepare a VM once, copy it for each job:

$ ssh chroot.dev cp app job-1 -w
$ ssh vm+job-1@chroot.run 'cd app && go test ./...'
$ ssh chroot.dev rm job-1

The memory brings the state of random number generators inside running programs. The system generator, arc4random(3), which rand(3) and random(3) also use, starts a new sequence in the copy; a program's own generator does not. In a PostgreSQL session opened before the copy, () returns the same values in both VMs, while () and new sessions differ. Restart such programs, or reconnect, in the copy.

A copy, like a new VM or a restored backup, gets its own secrets. Its kernel makes new network secrets, and wg(4) sessions start over with a new handshake; the WireGuard keys stay the source's, so a peer follows whichever of the two sent last. It has its own ssh host key, and shortly after it answers ssh it gets new iked(8) and isakmpd(8) keys, /etc/soii.key and random seeds; cron(8) and pflogd(8), if running, restart. The copy's IKE key is not the source's: give its IKE peers the new public key, and restart iked(8) or isakmpd(8) if it runs in the copy.

Asking for different cpus, memory or disk copies only the disks; the copy boots cold, as after a crash of the source: writes still in its cache are not in the copy. Run sync(8) on the source first:

$ ssh vm+app@chroot.run sync
$ ssh chroot.dev cp app big -m 1G

Memory in MiB or with an M or G suffix, data disk in GiB or with a G or T suffix. Resizing restarts the VM; disks only grow. The data disk is mounted on /home. A VM without one gets it with -d; on the next boot the contents of /home are copied to it.

$ ssh chroot.dev resize -c 2 -m 512M -d 4G app

cp(1), new(1), resize(1), chroot.dev(7)

chroot.devOctober 12, 2026COPIES(7)