NAME
new — create and
boot a VM
SYNOPSIS
ssh |
chroot.dev new [-w]
[-c cpus]
[-d disk]
[-i image]
[-m memory]
[-n name]
[-s script]
[--integration name
...] |
DESCRIPTION
new creates a VM and boots it. Without
-n the name is random. The VM counts against the
plan's limits for the account, with all its other VMs, stopped ones
included; see billing(1). A suspended
account cannot create VMs.
The VM gets a private IPv4 and a public IPv6 address, both shown; see chroot.dev(7). The public address is open to the internet on every port: anything that listens on the VM answers there, to anyone, whatever share(1) says. Filter it with pf.conf(5) in the VM before starting services.
The options are as follows:
-ccpus- Number of cpus. The default is 1.
-ddisk- Size of the data disk in GiB, or with a G or T suffix.
-iimage- Image to start from. The default is
base. -mmemory- Memory in MiB, or with an M or G suffix. The default is 128 MiB. The base image adds 512 MiB of swap in /var/swap.
-nname- Name of the VM: lowercase letters, digits and hyphens, up to 63 characters. It is also the hostname and the HTTPS name.
-sscript- Run script once as
puffy
on the first boot. ‘
\n’ is a line break; /dev/stdin reads the script from standard input. -w- Wait until the VM is ready: ssh answers with its own host key and the
account's keys. With
-s, wait as well for the script to end, for at most 10 minutes. Print how long each took. A script that exits with an error fails the command with its last line of output; the whole output is in /var/db/vmagent/setup.log on the VM. If the VM is not ready within 60 seconds, the command fails with its last vmagent: lines. Either way the VM is kept, and log(1) shows the rest of its console. --integrationname- Attach the account's integration name to the VM; repeatable. See integrations(1).
EXAMPLES
Create a VM named web and wait for ssh:
$ ssh chroot.dev new -n web -w
More memory and a data disk:
$ ssh chroot.dev new -n db -m 512M -d 4G
Install packages on the first boot:
$ ssh chroot.dev new -n app -w -s /dev/stdin < setup.sh
On -current, while a new package snapshot reaches the mirrors, the listing that pkg_add(1) reads can name a version whose file is already gone, and the install fails with “Couldn't install”. A script can try another mirror when that happens:
doas pkg_add -I go || doas env PKG_PATH=https://ftp.openbsd.org/pub/OpenBSD/snapshots/packages/amd64/ \ pkg_add -I go
SEE ALSO
billing(1), cp(1), integrations(1), log(1), pkg_add(1), resize(1), rm(1), share(1), pf.conf(5), chroot.dev(7), copies(7)