| SWMTOOL(8) | System Manager's Manual | SWMTOOL(8) |
NAME
swmtool — install
and repair scrotwmos, and run byol's own VMs and containers
SYNOPSIS
swmtool |
command [argument ...] |
DESCRIPTION
swmtool lays the scrotwmos appliance down
on a disk and changes it afterwards. The install stick runs
plan and install. The rescue
world, or the stick's shell, runs the rest. A byol box runs
vm, its own VMs on Void's qemu, and
ct, its own containers, Void roots
(ct start | stop |
restart | list |
top | console,
ct enable | disable |
exec, ct create |
clone | rm |
pass | port,
ct image list | check |
rm | build void,
ct allow | deny),
itself.
Who may run what:
- Any user
help,plan,survey,release sign,release verify,kernel-verify,install--dry-run,vm list,vm top,vm image listandct top. A state that only root reads shows as?.- An allowed user
- on their own containers, once root ran
ct allow:ct list,top,create,clone,rm,pass,port,ct start,stop,restart,console,exec,enableanddisable. Theirct createtakes no-P,-por static-a, and theirct startno--temp. - Root alone
- every other command:
ct allow,deny,image,ct list-a,ct top-a, and everyvmcommand but the three above. Eachvmcommand that writes root's files (image build,image rm,create,clone,start,stop,restart,enable,disable,rm,port,runandterm) run by another user printsvm <command>: needs root, such asvm stop: needs root, and exits 1 before it does anything.vm consoleandvm passread what root alone may read: another user gets an error.
The root vm commands first check each
program and file they run; any missing: vm: missing
<packages>; xbps-install -S <packages>, exit 1.
swmtool installs no package.
At a question a password and a username are not shown as they are
typed: the username picks the world. A recovery phrase is, and on a terminal
the screen and its scrollback are cleared once a phrase is taken. Ctrl-C at
any question, the stick's update's too, ends it:
interrupted: nothing taken, and the command stops as
it does at the end of its input, by its own way out
(session and world write
nothing and exit 3; session removes what an add
made).
An installed disk holds a boot partition, labeled
ESP, an encrypted data partition,
swmdata, and, last, the ESP's twin, which is a copy
of the ESP. Each world has its own master key. Its disk images in swmdata
are encrypted under keys that only that master key opens.
keys.wrap, on the ESP, has one entry for each
username. An entry opens its world's master key with that username's
password and nothing else. So root on the machine can erase a world but
cannot read one: every command that touches a world asks for that world's
credentials. A change to a world's configuration takes effect at that
world's next boot.
Credentials and shared options
passwd, update,
update-boot, firmware
refresh, totp,
session, and world ask for
the username. The username is typed with no echo, like the password. No
message names it. unlock,
add, update-root,
open, close,
points, and share take the
username as an argument.
The repair commands share these options:
--passwordsfile- Read the credentials from file instead of the terminal: one username password pair per line. The file is a pipe on -, the standard input, or a regular file of the caller's own, mode 0600 or tighter; 8 KiB at most.
--espdev- Use dev as the boot partition, mounted only while
the command runs. Without it, the one partition labeled
ESPis taken. None gives ‘ESP: none’. Two or more, on a terminal and without--passwords, are listed with their disk, size, bus, model, and kind. ‘Update [part]:’ asks which. Enter takes the first of kind dom0, or forrecoverthe first of kind byol; with none of that kind, the first. Otherwise they are refused: ‘ESP: 2 found; --esp <part>’. Foradd,update-root,open,points,share,unlock, andrecover, ‘ESP [part]:’ asks instead. With swmdata open, all butrecovertake the boot partition on its disk and ask nothing. --repourl- Fetch packages from url, an http or https URL, or an
absolute path. For
session,world, andfirmware, it replaces the default Void mirror. Foradd,update, andupdate-root, it is added to the root's repositories. With neither it nor--passwords, they ask “Package repository”, and Enter takes the default Void mirror.
Installing
plan[-Bdom0|byol] [-Klayout] [-ofile]- Ask the install questions and write the answers as a plan, in the format
of swmtool-answer(5), to
file or the standard output. The plan is checked by
install's parser before it is written.-Bgives the base instead of asking for it, and-Kthe keyboard layout; a layout given that is not valid is refused. The install stick asks for the keyboard layout first and puts its console in it at once, so every later answer, a password too, is typed in it; it then asks update, the appliance or byol, and gives both toplan. install[--dry-run|--which-disk] [--force] [--allow-real-disk] [--batch] [--passphrase-filefile] [--passwordsfile] [--place-passwordsfile] [--logfile] plan- Lay down what plan describes. The plan, the release,
the disk, and the passwords are checked before anything is written, and so
is every package the plan names: one that no repository has is named, and
it, or a mirror out of reach, refuses the install with nothing written. It
asks for each username's password twice, unless
--passwordsgives them. It fetches the machine's firmware, partitions the disk, and builds every world from the package repository. A byol plan's sessions are built the same way, each root byfill root, and named in /etc/scrotwmos/swm-wl.conf. Every root is dark (GTK and Firefox). A byol's root is dark only withdark = yes. The terminal's and the bar's fonts are 18 pixels, or 28 on a screen of 170 dpi or more.keys.wrap is written near the end and the boot loader last, so a failed install boots nothing. A failure before keys.wrap also removes what the install wrote on the ESP. A failed byol install unmounts its root and closes its root's mapper, so the same command runs again; what it cannot undo it names, with the command to run. The images left in swmdata are under a disk key that is gone.
--dry-run- Check the plan, the release, and the disk. Print the steps. Ask, fetch, and write nothing.
--which-disk- Print the disk the plan names, after an install's checks of it, and stop. Read and write nothing else.
--force- Erase a disk that holds data, as
erase = yesdoes. Without either, such a disk is refused. A disk in use is always refused. --allow-real-disk- Write a real disk. Without it, only a loop device is written.
--batch- Ask nothing.
--passphrase-filefile- For a byol plan: byol's one password (the login's, the boot's, and the
disk's) from the first line of file, a file as
--passwordstakes: - is the standard input. Without it, asked for on a terminal unless--batch: twice, or, when the plan holds apassword_hash, once, until it is the one the hash is of. A wrong password is refused. --place-passwordsfile- For a byol plan with
restore(swmtool-answer(5)): the place's password, from the first line of file, a file as--passwordstakes. Without it, asked for on a terminal unless--batch. A restore is an install whose root comes from the place: the disk laid out as for an install, the root's image pulled from the place and mapped by the key the place holds, and none of the root's fill. The new box boots the old box's root. The place is a directory that the user mounted, read on the box by a root child process; the box's kernel parses its file system. --logfile- Append the output of the tools
swmtoolruns to file, a regular file of the caller's own.swmtool's own steps, warnings, and questions stay on the standard output and the standard error.
Opening a world
unlock[--passwordsfile] [--espdev] user- On the install stick, which has no world open: open swmdata at
/swmdata with user's
credentials, so that
open,points,share,totp,world, and eachplacecommand butplace listandplace openwork.session,add,update, andupdate-rootopen it themselves and close it after.add,update-root,open, andsharerefuse a swmdata from another disk. Only a power off closes it. open[--rw] [--pointn] [--passwordsfile] [--espdev] [--sessionname] user- Mount the root and home of the world that user opens
at
/mnt/user/root
and
/mnt/user/home,
read-only unless
--rwis given.--pointn also mounts point n of the home, numbered aspointslists them, always read-only, at /mnt/user/point: a file copied from it to the home, opened with--rw, is put back.--sessionname mounts the root of that world's session, a container's or a VM's, at /mnt/user/root instead, with no home, and refuses--point. closeuser- Unmount and lock what
openorplace openopened.
Passwords and keys
passwd[--passwordsfile] [--espdev]- Change one username's password. It asks for the username, the password, and the new one twice. Only that username's entry in keys.wrap changes. Nothing is encrypted again.
totpon|off[--passwordsfile] [--espdev] [--stubpath | url] [release]totpon|off[--espdir]- The TOTP codes: the loader shows a loader code before the prompt, and the
boot asks a login code first. On a byol box, its ESP mounted at
/boot/efi or dir with
EFI/scrotwmos/keys.wrap on it, the codes are
byol's; else they are the dom0's, its ESP found as
updatefinds it. A byol disk found from the install stick is refused: runswmtooltotpon the byol box.byol's codes need
preboot tpm passwordfirst, and a terminal: the secrets are shown.onasks for the username and the password, makes two secrets and shows them one at a time, loader then login, as letters, an ‘otpauth://’ URI and a QR code, asks that one's code back, and seals them with the TPM's key. It refuses when the RTC is not the system clock: the loader reads the RTC.offasks for the username and the password and seals the key alone. Each makes a new TPM key, so an old sealed file opens nothing.From the install stick, the dom0's TOTP codes, the box's, for every world, the decoy too. It asks one world's username and password, any world's. The install offers them with its other questions, before the disk is written, and lays them with keys.wrap. It writes keys.wrap, so swmdata must be open (
unlock): a change of worlds cut off before is taken back first.onmakes two secrets and shows them one at a time for the phone's authenticator app, ‘dom0-loader’ then ‘dom0-login’, as letters, an ‘otpauth://’ URI and a QR code, asks that one's code back and clears the screen. The TPM seals them to the loader, which must be the stub beside release, or what--stubnames (the stick's by default); no copy is kept. keys.wrap then says the codes are on, and which seal. Each boot then shows the loader code before the prompt: if it shows none, or one that is not the phone's, the boot has been tampered with; type nothing and power off. Then it asks the login code, first, before the username and the password; Return on an empty login code shows a fresh loader code. A seal taken off the ESP while keys.wrap says on, or one put on while it says off, halts the boot after the password.update-bootwith a new stub turns the old codes off, then asks for new ones; with no tty, a no, or new ones not typed back, they stay off. With the codes on and a new stub, it needs swmdata open (unlock), or it writes nothing: before it writes keys.wrap it takes back a change of worlds cut off before. A keys.wrap whose mark does not agree with the ESP is said, codes gone, before the codes are turned off. Enroll on the box's own screen: a serial console keeps the secrets in its log. When the TPM gives no code (a firmware update, a new board), the boot halts:off, thenon.offmarks keys.wrap off, then takes the seal out; the next boot asks the username and password alone. The codes are a second factor of sorts: a copy of the disk, or anyone who can write the ESP and has a world's password, opens a world with its password alone. preboot passwd[--espdir] [--luksdev] user- On a byol box, change its one password. Elsewhere, as on the install
stick, it refuses: byol only. The login and the screen lock ask for it.
The boot asks for it as user, to start the newest
kernel, or as rescue, to pick a kernel from a list. dracut asks for it as
the disk's passphrase when the boot's key does not open the root. Use this
command, not passwd(1), which changes
the login's alone. It asks for the password and the new one twice, or
reads them as three lines. The boot's keys are in
EFI/scrotwmos/keys.wrap on the ESP,
/boot/efi or dir. The disk
is the one /etc/kernel/cmdline names, or
dev. Nothing is encrypted again. The login changes
first, then the disk, then keys.wrap. To finish a
stopped run, run it again with the same answers.
Anyone who can read keys.wrap can guess the password offline, at the cost of bcrypt_pbkdf, not of the disk's argon2id. The ESP is mounted
umask=0077: only root reads it.A damaged LUKS header loses the root, even with the password. Keep a copy of it on media of your own, stripped to the disk key's keyslot, so that an old password never opens it. As root:
umask 077 cryptsetup luksHeaderBackup /dev/<root> \ --header-backup-file /mnt/usb/root.hdr cryptsetup luksRemoveKey /mnt/usb/root.hdr cryptsetup luksDump /mnt/usb/root.hdrluksRemoveKeyasks for the password and removes its keyslot, whatever its number. The dump shows one keyslot left, pbkdf2's.With the TPM and the password (
preboot tpm password), the root has no password keyslot. Strip the recovery phrase's keyslot instead:cryptsetup luksKillSlot /mnt/usb/root.hdr 31. After a restore,preboot passwdadds no keyslot. A password change leaves the copy good. Make it again aftercryptsetup reencryptand afterpreboot make, which gives the disk a new key. To restore it, with the root closed, from a live system:cryptsetup luksHeaderRestore /dev/<root> \ --header-backup-file /mnt/usb/root.hdrThen boot: the boot's key opens the root, which needs the ESP. Then run
preboot passwd. The disk opens with its key alone, and the command gives the disk the new password's keyslot again, which dracut asks for. A damaged header and a dead ESP together are total loss: the copy holds no password's keyslot, and byol has no ESP twin.With the TPM and the password (
preboot tpm password), the root has no password's keyslot:luksRemoveKeyasks for the recovery phrase instead: its 12 words, lower case, one space apart. After a restore, runpreboot tpm password off, thenpreboot tpm password, which gives the disk the recovery phrase's keyslot again. preboot tpmon|off|password|password off|seal|pending|phrase[--espdir]- On a byol box: whether the TPM opens the disk with no password, or with
the password only. Elsewhere, as on the install stick, they refuse: byol
only.
onasks for the password once, lays the tree's boot stub on the ESP, adds a TPM slot to keys.wrap, keeps its key in /etc/swm/tpm.kek, and seals. The password slots stay: the stub asks for the password whenever the TPM does not open the disk. A boot the TPM opened starts with the screen locked.offremoves the TPM slot, each sealed file, and the key. The boot asks for the password again. It does not revoke: a copy of the ESP from before, put back, boots by the TPM again.onandoffrefuse whilepasswordis on.passwordmakes the boot take the TPM and the password together: neither opens the disk alone. It asks for the username and the password, shows the recovery phrase, and asks for the phrase again. The phrase is 12 words, from the box's own keys, the same every time, shown on a terminal alone. Then it seals, puts the phrase in keyslot 31 of the root's LUKS, removes the password's keyslot, and replaces the password slots of keys.wrap with TPM and password slots and a recovery phrase slot. When the TPM does not open the disk (a changed boot, a new board, the TPM cleared), the boot halts and asks nothing:swmtoolrecover, from the install stick, takes the phrase. So do dracut andswmtoolupdate.swmtoolrecoverandswmtoolupdatetake each word's first four letters, in any case; dracut takes the words in lower case, one space apart. Without the phrase, the disk does not open. To finish a stopped run, run it again.password offasks for the username and the password, puts the password's keyslot back, makes the boot the TPM alone again, and removes the phrase's keyslot.phraseasks for the username and the password and shows the recovery phrase again.sealseals each kernel listed in EFI/scrotwmos/kernels to what its boot measures: the stub on the ESP (a new one the kernel hook laid, too), the Secure Boot state, the kernel, its initrd, and the command line. The kernel hook runs it, and so does a service at each boot the password opened. Nothing is written to the TPM. After a seal, a pending boot (an install's, or arecover's) loses its password slots, and a password's keyslot 0.pendingdoes that alone: the same service runs it at each boot the TPM and the password opened. recover[--espdev]- On a byol disk whose boot takes the TPM and the password
(
preboot tpm password), from the install stick or any Linux with the disk attached, as root, when the TPM does not open it: the boot halts with ‘TPM gave no key: recover from install stick’ or ‘boot changed since last seal: tampering suspected; power off’. It finds the ESP and the root asupdatedoes. It asks for the recovery phrase (shown as typed), the username and a new password twice, and changes nothing unless the phrase opens the recovery slot of keys.wrap. It opens the root by the disk key and reads the TPM's key from /etc/swm/tpm.kek; with TOTP codes on, it asks whether to drop them (a lost phone). Before any change it checks the login (a UID of 1000 or more), the keyslots against their roles (keyslot 0 the password, 1 the disk key, 31 the phrase; a password keyslot anywhere but 0 is an error), and that the root's own boot stub never asks the phrase (a system from beforerecoveris refused:updatefirst); a key file that is there but bad is replaced only when asked. Then, in this order: it sets the login's password on the root, by the root's own chpasswd; kills a password's keyslot 0 when the disk key is at 1, and gives keyslot 31 the phrase again when the header has it not (no password keyslot is added); writes the key file with a new key (the codes after it unless dropped; with no key file, none); runs the root's kernel hook for each kernel, which lays the kernels, initrds, command line and boot stub of the root on the ESP; wraps keys.wrap's TPM and password slots again under the new password and the new key, with password slots beside them; and removes each sealed file and the phrase marker. The recovery slot and keyslot 31 stay: the phrase is the same. A stop says what changed and what the boot does then; running it again finishes it. The next boot asks for the new password once, as an install's first boot does; its seal service seals if the TPM answers, and the password slots go: the TPM and the new password from then on. It exits 0 when the recovery is done, also when the disk did not close after it, which it says. preboot makeesp user luks-device layoutpreboot tpm ready[--espdir]--rootdirpreboot tpm password[--espdir]--rootdir--luksdev- The installer's steps for a byol. Each reads the password on the standard
input.
makeadds a new disk key to a keyslot of luks-device and writes esp/EFI/scrotwmos/keys.wrap with user's and rescue's slots and the disk key, sealed, and names layout, which the boot reads the password in.ready, fortpm = yes, makeson's slot and key, the key under--rootdir, and seals nothing.password, fortpm = password, reads the username and the password, one a line. It makes a new key under--rootdir, adds the recovery phrase as keyslot 31 of dev, and adds the TPM and password slots and the phrase's slot to keys.wrap. It shows nothing and seals nothing, and the password's slots and keyslot stay. The first boot opens with the password, and the boot shows the phrase until a key is pressed; once itssealseals, it removes them. esp restore[--espdev]- Make the ESP again from its twin, the last partition of an appliance disk.
Every change to the ESP copies it there (doc/design-points-later.md, F).
Run it in rescue, from the stick (Ctrl-C at a question). Run it when the
loader does not start, or when the ESP does not mount or does not open. No
password is asked for. The twin is found by its label, and the ESP beside
it; or the twin beside
--esp, which must be an appliance's ESP. Refused, with nothing written: a twin that is not whole (a file that does not read, or a copy cut off, its files not of the one time of its keys.wrap), and a twin older than a whole ESP's keys.wrap, which would bring back what a later change took away. Otherwise the ESP's file system is made again and the twin is copied onto it, its time kept. If it is cut off, run it again.
Updating
update[--force] [--passwordsfile] [--espdev] [--repourl] [--kernelsdir | url] [--stubpath | url] [release]update-boot, thenupdate-root, with one set of questions: the package repository, then the slots' usernames and passwords. Both slots' credentials are checked before anything is written, and asked for again on a terminal after a wrong one. swmdata is opened with slot A's and closed after, done or not. With swmdata already open, afterunlockor in rescue, it refuses before it asks anything: useupdate-bootandupdate-root. After an A/B world's update, a NOTE says that rescue and the decoy are not updated. To update each, runupdateagain with its username and password as slot A and slot B empty.On a byol disk (its ESP has EFI/scrotwmos/keys.wrap) with no release, it lays this stick's scrotwmos instead: the tree under /usr/lib/scrotwmos, the install's scripts and config, the boot stub and each kernel's initrd, and then each session's root as
update-rootupdates a world's, the stick's packages first. A root from beforevmgets what the install lays for it: thevmuser when it has none (an owner's ownvmis kept), the build range ofvm image build voidwhen it has none, andlan0of a wired uplink when it has no /etc/sv/dhcpcd/lan0. Every root gets the NAT bridgevmnat0: its service /etc/sv/vmnat, on, and /etc/qemu/bridge.conf without theallow lan0andallow vmnat0an install before wrote, the file's other lines kept;lan0and the VMs are left as they are. The root is the partition on the ESP's disk whose LUKS uuid is the onerd.luks.uuidnames in the ESP's EFI/scrotwmos/cmdline; none, or two, is refused. A config file still as the install wrote it (each is recorded in /etc/scrotwmos/generated) takes the release's. An edited one is left. It is shown when the release changes that file, and a line the release adds to it is shown, to add by hand. The root's /etc/kernel/cmdline getsrootflags=prjquota, said, unless it names a project quota already:ct's disk limits are on from the next boot. It asks for the password that opens the disk. A wrong one changes nothing, and on a terminal, it is asked for again. A release older than the box's is refused without--force. With the TPM on, it says that the next boot asks for the password once; with the TPM and the password, it asks for the recovery phrase, and seals each new kernel from the stick with the root's key, as the kernel hook seals it. A seal that fails, or a stick the firmware measured otherwise than the disk, leaves a next boot that may halt:recoveropens it. Nothing of the user's changes.update-boot[--force] [--passwordsfile] [--espdev] [--stubpath | url] [release]- Put a new release on a world: this changes what boots, not a root.
release is a path or an http or https URL to a
signed release, checked before anything is asked. Without it, the release
beside
swmtoolis used: on the stick, /opt/scrotwmos/release/dom0.signed. It asks for slot A's username and password, then slot B's. Slot A gets the new release, and slot B gets what A had. B then always boots the last release that ran. An empty slot B username updates slot A alone: the decoy and the rescue world have one slot each, and an A/B world's B keeps its release. A write that stops inside slot A's pair leaves a world with no B unbootable untilupdate-bootruns again, from rescue or the stick. A release older than A's is refused, and so is an update that would give B a release older than B's.--forcelifts both refusals.The release's stub, the loader the firmware starts, comes with it: swmstub.signed beside the release, or what
--stubnames, a path or an http or https URL. When the sibling is missing,swmtoolleaves the stub and says so. A named one must read. The stub must be signed by the release key, carry this release's version and date, be a stub and not a boot image, and pin the release key the slots are signed with: a key rotation is a new install. It is written first, and only when the loader differs, so a write that stops anywhere leaves a loader that boots, and a rerun changes only what it meant to.A box whose loader is gone or will not start boots the stick. Its
update-boot, from a stick at least as new as slot A, writes the loader before the slots. An older stick needs--force, which also puts the stick's release in A. update-root[--passwordsfile] [--espdev] [--repourl] [--kernelsdir | url] user- Update the VM kernels in the world's kernel store, then every package in
every root of the world that user opens: the world's
own root and each session's. A session essential the release added since
the world was installed is brought in first. Then every package, the
user's too, is updated. The kernels come from the release's
kernels/ beside
swmtool, or from--kernels: a release's kernels/ directory, or its http or https URL. Every kernel is checked against the signed index before the store changes, and the old set stays whole until the new one is laid. This does not change what boots. A root that is an empty file, asplace worldleaves one with no copy on the place, is made anew first, from the release, as the install makes a session's root: the base system only. The session's own packages, and a VM's GPU drivers, come back withadd. With no--repoto make it from, it is refused, and nothing changes. Each root's package manager runs in a jail that sees only that root, and its output is shown only when it fails. The rescue world's root is in use while rescue runs. Update it from the install stick. With swmdata shut, as on the install stick, it opens swmdata first with user's credentials, asupdatedoes, and closes it after. add[--passwordsfile] [--espdev] [--repourl] [--sessionname] user package ...- Install package into the root of the world that
user opens, in the jail of
update-root, or with--sessionname into the root of that world's session, a container's or a VM's. It opens and closes a shut swmdata asupdate-rootdoes. firmware scan[--repourl]- Show the firmware this machine's devices need, each file from the Void repository, and the total. Nothing is written.
firmware refresh[--repourl] [--passwordsfile] [--espdev]- Fetch the firmware again and give it to one world, whose usernames and passwords it asks for. The new firmware goes on the boot partition beside the old, and only that world's slots take it, from their next boot. Refresh each world that needs it.
Worlds and sessions
world[--passwordsfile] [--newfile] [--espdev] [--repourl]- Add or remove a whole world. It asks for the credentials of a world
already there, then whether to add or remove. To add, it asks
plan's world questions and asks for the new usernames' passwords, or reads them from--newfile, in the format of--passwords. A new container world takes the language of a world on the box, elseC.UTF-8. To remove, it asks for the credentials of the world to remove, or reads them from--new. It takes the world's usernames out of keys.wrap first, then deletes its images, its kernel store, and its points. The world used to open cannot be removed. session[--passwordsfile] [--espdev] [--repourl] [--releasedir] [list|dump]- Change, add, or remove the sessions of a world. It asks for the world's
credentials, lists its sessions, and asks which one to change, or
add. A session can change its network and process limit. An extra session can be removed.addasksplan's session questions and a container's process limit, and builds the session's root. A container takes its world's language, and package sets default toshell. On a box with a GPU besides the display GPU, a VM is asked whether it takes that GPU. For an NVIDIA GPU, yes installs thenvidiapackage set in the VM's root there and then: the root must not be in use.listshows each session's settings and images, anddumpprints both slots' configuration. Neither needs swmdata. On the install stick, it opens swmdata with slot A's credentials and closes it, asupdatedoes.On byol there are no worlds or slots. On the running box, as root, with /etc/scrotwmos/swm-wl.conf and /etc/sv/swm-wl/run, nothing is asked first. From the stick, it finds the byol disk as
updatedoes, asks ‘Password:’ once, and opens and mounts the root until the end. It lists the sessions and asks which, oradd.addasks the install's session questions (name, isolation, workspaces, network, package sets and packages, and the share), builds the root as the install does, a container's in /srv/<name>, a VM's disk in /var/lib/scrotwmos/vm/<name>.img, and writes the session's lines. A container takes the box's keyboard language. A session picked can change its network, add packages to its root, join or leave the share, or be removed: its lines go, its root only on a yes, and its home stays. A root and its packages come from the release's repository, besideswmtoolon the stick, or--releasedir on the running box. On the running box, it ends with ‘RESTART: swm-wl’: the compositor takes the change at its next start. joinputs session of the world that user opens in the world's share: one directory, at /share, on an image of its own under that world's key, made at the first join. Only the sessions put in it see it, and no other world's. A session not in it has no route to it.parttakes session out of the share, from the world's next boot. The share and its data are kept.joinasks for the password of user, then slot B's username and password. Run it from the world's rescue: it is refused on the install media. To finish a join or part cut off between the two slots, run the same command again.
Points and backups
points[--share|--root] [--backn] [--passwordsfile] [--espdev] [--sessionname] user- List the points of the home of the world that user
opens, newest first, numbered as
--pointtakes them: each one's local time and its age. A point is the home as it was at that hour. The booted world's root monitor takes one each hour the home changed, keeps every one of the last day, one a day for the week before, then one a week for two years at most. It takes none while the store has less than 5% free. Under 1%, it deletes them all.--backn rolls the home back to point n instead, in rescue, the world not open. Nothing is lost: the home as it was becomes this hour's point, 1 in the list, and every other point stays, so--back1undoes it. The next copy to the world's place is a whole one.--sharedoes the same for the world's share, every file's owner, group, and mode as they were at that hour. A world with no share is refused.--sessionname does it for that session of the world: a VM session's points are of its disk, which holds the guest's home, and--backrolls the whole disk back.--rootdoes it for the session's root, the system it runs: its points are taken the hour after rescue changed it (add,update-root), and--backneeds the world not open. A VM session's root is its disk. place init[--passwordsfile] [--espdev] [--sessionname] [at] user place path- Make the backup place of the world that user opens:
the directory path on place,
which keeps its other files. place is one of:
- disk
- A USB disk, such as /dev/sdb: the directory on
its one file system, or on the one
--uuidnames. nfs:IP:/export- An NFS export, by its server's address. It must be
sync, notasync: an async server says a write is done before it is on its disk, and a copy checked as written can still be lost. smb://account@IP/share- An SMB share, logged in to as account.
Once the place is made, or adopted, the world's recovery phrase is shown, as
place phraseshows it; off a terminal, run that to see it.The place commands take, as at:
--uuiduuid- A disk's file system that holds the place, by its UUID in lowercase,
as
lsblk -fshows it. It is needed only on a disk with more than one. --taptap- A network place's: the tap ttvm's NIC is put on, up and on a bridge, made as in EXAMPLES. A tap that is not there, or is down, is refused. The server sees the box's own address: export the place to it.
--ipip- The VM's address on it, as the kernel's
ip=takes it, client::gateway:netmask:::off, the client in100.64.0.0/10, as every VM's is. The VM resolves no name: the server is named by its address. --accountfile- An SMB share's account password from file, a
line account password as in
--passwords; Without it, the password is asked for. The account, its password, and the path take no comma: the SMB mount reads one as its next option.
path is made when it is not there. A leading ‘
/’ is the file system's root, and ‘/’ or ‘''’ is the root itself, where F11 makes a place. ‘..’ and links are refused. The file system must keep holes, punched holes, and hard links (XFS, btrfs, or ext4; not vfat or exFAT). Without reflink, every copy is whole, one a day. Two small header files are written there, and the world's record of the place in the store. A place that already holds this home's header, from an earlier install, is adopted with its copies. The boot disk is refused, and so is a world that has a place. With--sessionname, the place is that session's, in its own directory beneath path. A VM session's copies are of its disk, under the disk's own key.The booted world copies each new point to the place while it can reach it: a USB disk while it is plugged in and admitted, at boot or in F7's scan window (or always, with
allow_hotplug = 1in dom0.conf); a network place while the world's network reaches it. Copies are thinned as points are: every copy of the last 24 hours, the newest of each of the last 7 days, and the newest of each week before. No copy is made that would leave less free than the smaller of 5% of the file system and 64 GiB: each copy thins first, and while the copies kept still fill it, F6 says the place is full. While points are off (F11 or dom0.conf), nothing is copied. place show[--passwordsfile] [--espdev] user- Say where the world's place is, or that it has none.
place phrase[--passwordsfile] [--espdev] user- Show the world's recovery phrase: 12 words, from the world's own keys, the same every time. It is shown on a terminal alone, never into a pipe or a file. With a place, they open the world's backups when the password is forgotten, on any box (doc/design-points-later.md, F). Keep them on paper, away from the box and from the place.
place list[--passwordsfile] [--sessionname] [--share|--root] [--check] [--phrase] [at] place path user- List the copies at a place, newest first: each one's hour in UTC, the word
place opentakes, in local time, and its size. A copy whose manifest does not open is said to be damaged. With--phrase, the place opens with the world's recovery phrase, asked for, not the password. Only the place and the world's password are needed: the box need never have seen the world. The place is mounted read-only and nothing on it is written, so a full or read-only place lists too.--checkreads every chunk of every copy against its manifest and says each copy checked, or damaged with how many chunks are bad and the byte of the first. On a place that reflinks, one bad block can harm many copies. place open[--passwordsfile] [--storedir] [--sessionname] [--share] [--damaged-ok] [--phrase] [at] hour place path user- Restore the copy of hour into the store
(/swmdata/images, or
--store), check every chunk of it against its manifest, and mount it read-only at /mnt/user/place, alone or beside anopenof the world, run first. The store must have room for the copy's data and 1% of the store besides. The restored copy holds no name in the store: its close, or a power cut, frees its space. A copy damaged on the place is refused, its first bad chunk named.--damaged-okopens it with each bad chunk as zeros and names the bad chunks, then each file with data in one. A bad chunk in the file system's own blocks can keep the copy from opening at all. The place is mounted read-only. user names the mount and whose password is asked for. The place opens with the password alone, so any name does. With--phrase, the recovery phrase opens it instead, as inplace list.With
--share,place listandplace opentake the world's share's copies instead, in the directory share of the session's: the same password opens them, and a user copies their own files out of the share as it was. place world[--passwordsfile] [--espdev] [--newfile] [--phrase] [at] place path user- Bring a dead box's world back on a new box (doc/design-points-later.md,
F). The world installed here, slot A user, becomes
the dead box's world again, under that world's own keys, so
place restorecan bring back its homes, roots and VM disks. Run it in rescue, with the place there, before the world installed here is ever booted, with the install's username and password. Slot B's are asked for next, or read from--newfile, which holds slot B's line alone, when the world has two slots.The world's file, in the world's directory on the place, opens by the place's header with either slot's password when it is the dead box's. With a new password, give
--phraseand type the recovery phrase. By the password, it runs on a terminal alone: it shows the phrase's first four words to check against the paper, and asks for yes, since anyone with the place and the password could have written that file.The world gets back its sessions, Wi-Fi networks and settings. Each home is made empty, and each root and VM disk an empty file, until
place restoreputs its copy there; it names each one. An image with no copy on the place is named too: a home starts empty; a root or VM disk stays an empty file, and the boot refuses its session, saying so, untilupdate-rootmakes it anew. The world's VM kernels are laid from the release besideswmtool, with no network. This box keeps its own disk key, boot image and fstab, and the GPU and network-card approvals its install made, sealed again under the world's keys, so the world has its network at its first boot.Refused, with nothing written: a world on this box that has those keys already, a world installed here that has points, another number of slots, an image the world names that is here already, a world with a share installed with none, and a rescue with no VM kernels beside
swmtool. If it is cut off, run it again: the next run takes away what the first made, or finishes what it left, and names each image again. place restore[--passwordsfile] [--espdev] [--sessionname] [--share|--root] [--remake-homes] [--phrase] [at] hour place path user- Put the copy of hour in place of the world's home,
every chunk of it checked first. Run it in rescue, for the world
user of this install, with the password of the world
the place was made by, or with
--phraseand the world's recovery phrase. Refused: a place other than the world's, a world whose session is running, and a password change not yet done on the place.On a new box or a reinstall, the copy is first opened as a home under the place's key. A copy that does not open is refused, and the home is kept. Then the home takes the place's key, the world's points go, and the world has the place from then on, as
place initwould adopt it. The world's sessions share one home key, so each other session's home is then restored the same way, with--session, from its own copy on the place, and the restore says so. A session with no copy there is made anew, empty, under the new key with--remake-homes. Without it, the restore is refused and names the session. On the world's own place, the home as it is now is gone unless a point holds it. The points stay. Either way, the next boot's copies go on beside the old ones.--sharerestores the world's share instead, from the directory share of the session's, every file's owner, group, and mode as they were at hour. On a new box, the share takes the place's share key.--rootrestores the session's root, from the directory root of the session's, only on the box whose world made it, or afterplace world: another world does not make the root's key, and the restore is refused.
byol's time travel
On a byol, the root is an image, root.img,
in an XFS store on the disk's LUKS2 volume, mounted at
/swmdata; see
scrotwmos-byol(7).
ttd(8) takes its points and its copies.
These commands ask it over its socket, as root. Each answers in lines; a
refusal's last line starts refused:.
tt status- Time travel on or off, the store's size and free space, each point's hour and size, and the place: its kind, its disk or address, its newest copy, its state, and its last job's end. With no place, the USB disks the box takes as one.
tt on|off- Turn time travel on or off. On, ttd(8)
takes this hour's point at once, unless the store has one of this hour or
this ttd tried one this hour. Then it takes one each hour that the root
changed. The bare tt(8) takes no point at
on: it takes a point only at itstakeorcopy. Off deletes every point, once none is mounted and no job runs. tt take- Take a point now.
tt delete- Delete every point.
tt mount|umounthour- Mount the point of hour,
YYYYMMDD
THHZ, read-only at /points/hour, or unmount it. tt backhour |undo- Make the point of hour the root the next boot boots,
and lay its kernels on the ESP; or, with
undo, the root as it was before the last rollback. The root now is kept as root.prev.img. A secondtt backbefore the boot is refused. A kernel update, or the stick'supdate, cancels a rollback not yet booted. tt placedir- Make the directory dir, an absolute path that the user mounted, the root's backup place: XFS, ext4, btrfs, FAT or exFAT on a disk, an NFS export, or an SMB share. FUSE is refused. A directory that is not mounted is absent: no copy is made, and the points go on. It asks for the place's password twice, the one a restore asks for. The copies follow: the first is the whole root, the next only what changed. They are ciphertext: the root's image is LUKS2. A disk the box boots from is refused.
store make|open|attach|restore|cancel|dev|mount|close...- The store's own steps, which the install, the stick and the initramfs
take: make the store and the root's image in it, open or close them, name
or mount the root, pull the root from a place
(
restore), or cancel a rollback. They are not for use by hand.
Other commands
keyboardlayout |-pplan |-b- Put the console's keys in layout, one the boot
reads, by the console map of
loadkeys(1); with
-p, in the keyboard of plan, read asinstallreads it; with-b, in the layout the installed box's keys.wrap names, US for none. The install stick runs it at its first question, with-pfor a plan on the stick, and with-bbefore an update: every later answer, a password too, is typed in it. survey[--json|--nicaddress]- Print what the machine offers the appliance: the IOMMU, the TPM, the
security tokens, and the PCI devices with their IOMMU groups. Without
root, the ACPI tables and the TPM may show empty. Each GPU shows the rows
the GPU table has for its id. Each GPU but the display GPU is shown as
dom0 holds it, with no driver. With
--json, thegpuobject gives each GPU's rows as indexes into the table, per path (native context, Venus, VFIO, SR-IOV), -1 for none.swmtooldoes not read the bridges on a GPU's path or its group's state. dom0's F9 shows whether a VM gets it.--nicprints only the network function at address, and only when dom0 gives it to no VM: its address, ids, and reason in the words of dom0's F5 (its IOMMU group shared or none, or its row not listed, excluded, or impossible).--jsonand--nictogether are refused. release sign-r|-b|-i-skey.sec-pkey.pub-vversion-ddate-oout kernel- Sign a kernel, or the stub, as a release.
-rsigns a dom0 kernel with the release key.-bsigns the stub with the release key, with no handoff, so the stub refuses it as a boot image andupdate-boottakes it as the stub.-isigns an installer kernel with the installer key.-sand-pname the signify secret and public keys. The public key must be the oneswmtoolwas built with.-vis the version, and-dis the date in UTC seconds. The signed image is checked, then written to out, which must not exist. A secret key's passphrase is read from the standard input. release verify-r|-b|-i-vversion-ddate-mkernel signed- Check an image that a signer sent back: the image
signed must be kernel signed
as
release signsigns it, byte for byte after its header, with the version and date given, under the keyswmtoolwas built with for that kind. A release built with a signer runs it on each image. Exit 0 when the image is good, 1 when it is not. kernel-verify[-iindex] flavor [blobdir]- Check a VM kernel, or an archive a guest's kernel unpacks, as the launcher
will. Run it in a scrotwmos tree: the key is its
kernel/keys/kernel.pub. The index,
blobdir/index or
index in blobdir, must verify
under its signature .sig beside it. The blob that
names flavor must have the index's digest.
blobdir is build/kernel when
none is given. For
nctx-mesaandgpu-fw-family, the archive is then listed as-clists one. kernel-verify-carchive [nctx-mesa|gpu-fw]- List a zstd newc archive, of the kind named
(
nctx-mesawhen none is), as the build does before it signs one. It is refused when it is not one archive and zeros, when an entry is named init, is setuid or setgid, is a hard link, or runs through a link, or when the file or what it unpacks to is larger than the kind's bound. Annctx-mesaarchive holds the directory nctx-mesa and files and directories under it. Agpu-fwarchive holds gpu-compositor/scrotwmd, gpu-compositor/gpu-probe, and lib/firmware/, its links relative and under lib/firmware/nvidia/. fillstep ...- The steps the other commands run to fill a root, a home, a share, or a kernel store. Nobody runs them by hand.
vm start[--temp] name- byol: run the VM name, Void's qemu under runit. The
VM is its qemu command line as YAML,
/var/lib/scrotwmos/vm/name.yaml:
one map, each key an option,
-key, each value one word after it, as written (no YAML typing:no,22:22and0x10stay words), a list the option once an item, an empty value a bare flag. Only maps, lists and plain or quoted scalars are taken: an anchor, an alias, a tag, a directive, a block scalar, a second document, a map under a key or in its list, or a key twice, is refused with its file and line. A value with a comma goes in a block list, not a flow one: in[a,b]the comma parts two items.swmtooladds-namename,process=vm-name,debug-threads=on, QMP on /run/vm/name/qmp, and a console on /run/vm/name/console: a virtconsole (hvc0), or a serial port (COM1) when the YAML hasconsole: serial(console: virtiois the default), and a-sandbox(below); nothing else. A YAML that setsname,qmp,qmp-pretty,monitor,mon,daemonize,readconfig,gdb,s,qtest,incoming,S,run-withorsandbox, a value that startsmon:(a monitor on a chardev), or an idswm*, is refused. The list guards the tool's own options and its hold on qemu, no more: a VM's YAML is root's. qemu runs in the foreground in /var/lib/scrotwmos/vm as the VM's own uid, never root, kvm its one other group, under-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny: no exec, no helper spawned, no new privilege. The uid, its gid the same number, is the start of the VM's line-vm-name:start:65536in /etc/subuid and /etc/subgid, from the containers' window;vm createandvm clonemake it,vm rmspends it, never given again. The VM's disk, seed, UEFI vars and /run/vm/name are that uid's: one VM's qemu reaches no other VM's. A VM from before its own uid, its files thevmuser's, takes one at its next start or clone: each file its YAML's drives name in /var/lib/scrotwmos/vm that thevmuser owns is made the new uid's, said once in its service's log. A disk its YAML names elsewhere is yours to give to that uid. After an update from before the VMs' own uids, restart each VM that is up (vm restartname), or reboot the box: a qemu still running as thevmuser keeps the disk it opened. Its service, /etc/sv/vm-name, is linked in /var/service; runit starts it again after a crash. runit's own stop,sv downor the box's power off, is the VM's power button: the service's control/t sends QMP'ssystem_powerdownand waits 60 s for the guest to power off before runit's TERM. A down file there keeps it from starting at boot. A tap on the bridgelan0:netdev: bridge,id=n0,br=lan0anddevice: virtio-net-pci,netdev=n0,mac=52:54:00:12:34:01. The run makes the tap itself, as root, before it becomes the VM's uid: namedswmq, the MAC's last three bytes and the NIC's number (swmq1234010), not persistent and with no owner, a port of the bridge, up; qemu gets its fd in place of the YAML's word (tap,id=n0,fd=N). A tap of that name held by a running VM, whose MAC ends in the same three bytes, refuses the start: give one of them another MAC. A bridge butlan0andvmnat0, or a bridge NIC with no MAC, is refused. qemu-bridge-helper is not used. The install, or an update of a box with none, makeslan0of a wired uplink, the NIC in it and dhcpcd on it and on the real NICs; a Wi-Fi uplink cannot be bridged: nolan0. Each VM onlan0needs its own fixed MAC inmac=: qemu gives every VM the same one, and a MAC that changes is a new lease. A tap on the NAT bridgevmnat0the same:netdev: bridge,id=n0,br=vmnat0. Every install and update lays it, on any uplink (vmnat): the host the gateway, the guests' addresses fixed, no DHCP, the subnet masqueraded out the host's uplink; guests reach each other, the host and the LAN, and nothing on the LAN opens a flow to them. A VM may have a NIC on each.--temp, or a YAML withsnapshot, runs a temporary VM, for a dirty task: qemu's-snapshot, its writes discarded. Its service is in /run, started once, never at boot, and gone after the VM stops. vm stopname- QMP's
system_powerdown, then, the VM up 60 s on, a kill; with no QMP, the kill at once. QMP that sends no reply in 5 s, its events or not, is no QMP. A kill, here or at the box's power off, leaves /var/lib/scrotwmos/vm/name.killed (a guest that did not power off: no ACPI daemon); a stop the guest ends removes it. vm restartname- Stop, then start; a temporary VM again temporary.
vm list[-v]- Each VM's name, state (
up,temp,down), pid, uptime, boot, mac and ip;-vadds its address onvmnat0, its YAML'svmnat0key, up or down (-when it has no NIC there), stop,killwhen its last stop needed the kill (vm stop),-else, its port forwards (vm port),-none, and the image it was made over (a clone's, its source's;-for one whose YAML names none).bootonwhen it starts with the box (vm enable),offfor its down file:vm disable, or avm startnever enabled;-when not linked in /var/service (never enabled, or a--temprun alone),?when this user cannot read its servicemac- the first
mac=of adeviceornicin its YAML, its first NIC's;-when none: qemu's own MAC, user net;?when its YAML is not read or not a VM's ip- its IPv4 addresses while up, comma separated,
lan0's first: onlan0, its first NIC's MAC's inlan0's neighbor table, read once, nothing sent, none until heard; onvmnat0, its YAML'svmnat0key, the address create picked and seeded, its first NIC or not.-when down, or none known. The table holds the guest once it announces its address with a gratuitous ARP, as dhcpcd, NetworkManager and OpenBSD's kernel do as the lease comes:lan0-linksetslan0'sarp_acceptto 2: an address oflan0's subnet alone. It is the guest's word: never trust it.
Not root,
?for a VM whose state only runit's supervise, root's alone, holds;lan0: nonewhen the box has nolan0. vm top- A top for the VMs, on this terminal: a row each, a second apart, the rows
the VMs
vm listfinds, scrolled to the selected one when the screen holds fewer. The columns:name- the VM; a name too long for the terminal, 80 columns or wider, cut,
~its last stateup,temp,downor, not root,?asvm listsays itcpu%- qemu's CPU time over the second, of one CPU: past 100 with more
rss- qemu's resident memory
read/s,write/s- the disks' bytes a second, QMP's
query-blockstats rx/s,tx/s- the net's bytes a second as the guest sees them, its taps summed:
rx/sthe taps'tx_bytesin /sys/class/net,tx/stheirrx_bytes; a tap is each of qemu's /dev/net/tun fds, its fdinfo'siff uptime- since qemu started
Sizes are humanize_number(3)'s:
340K,1.5G. A-is no value: a VM down, its first second, its QMP not answering in the second, or no tap (user net). qemu's /proc and its taps' counters are read in a child and QMP without waiting: the screen never stalls on a VM. Keys, on the selected VM:uvm startdvm stoprvm restartcvm console; Ctrl-] back to the topUp,Down- select a VM
q- quit
start, stop and restart run beside the screen, their lines on its last line. The terminal is as it was after, whatever ends it:
q, a signal, an error. vm consolename- The VM's console on this terminal, raw; Ctrl-] leaves. The terminal is as it was after, whatever ends it: Ctrl-], the end of input, the console closed, a signal.
vm enable|disablename- Start the VM at boot, or not: its service without, or with, its down file. A temporary VM is never started at boot.
vm createname image size [-sdisk] [-nnics] [-p]- byol: a VM over the base image image,
/var/lib/scrotwmos/vm/images/image.qcow2.
Its disk,
/var/lib/scrotwmos/vm/name.qcow2,
is a sparse qcow2 with the image as its backing file, the VM's uid's. Its
YAML is
machine: q35,accel=kvm,cpu: host,display: none, then the image's fragment, image.yaml beside it, if there is one, then the size's, /etc/scrotwmos/vm/recipes/sizes/size.yaml or else /usr/lib/scrotwmos/vm/recipes/sizes/size.yaml; a key in a later one replaces an earlier one's values. The sizes:small1 CPU, 1G, a 20G disk;medium2, 4G, 40G;large4, 8G, 100G. A size'sdiskkey is the disk's size, not a qemu option;-sgives another. Then the disk's drive, the seed's (read-only), and each NIC's net and device are added.-npicks the NICs:lan0(bridge,id=n0,br=lan0),vmnat0(bridge,id=n0,br=vmnat0), orboth(lan0's n0, thenvmnat0's n1); a bridge the box has not is refused. No-n:lan0when the box has it, elseuser,id=n0. A NIC onvmnat0gets an address from10.83.87.2to.191(the rest left free), no other VM's YAML's: the one past the highest taken, else the lowest free, so a removed VM's comes back last. It is the YAML'svmnat0: 10.83.87.x, the tool's, not qemu's, and goes to the seed; there is no DHCP onvmnat0. The MAC is52:54:00and the first three bytes of the name's sha256, or, when another VM's YAML has that one, of the name with#1,#2, ...update: bootin the YAML is the tool's, not qemu's: it goes to the seed.varsin an image's fragment is the tool's too: a UEFI vars template, copied to /var/lib/scrotwmos/vm/name.vars.fd, the VM's uid's, its pflash drive added;vm clonecopies it,vm rmremoves it. A random password is made;-pasks for one, no echo. An existing name is refused.-nvmnat0orbothover an image from beforevmnat0is refused: its fragment has noseed: 2, and its first boot would set no address. Create and clone hold /var/lib/scrotwmos/vm/.lock from the names, MACs and addresses they read to the YAML they write, and no longer: two at once take two addresses, and one that waits saysvm: waiting for another vm create or clone.-pasks the password before. The build after it, the disk, vars, password and seed, holds /var/lib/scrotwmos/vm/name.build:vm rm,vm start, another create of name, and a clone to it or from it refuse,<name>: being built. The VM is invm listwhile it builds; a build cut short leaves its YAML and its address held, or, cut before its YAML, its build file alone, andvm rmtakes either. A VM's YAML that create or clone cannot read stops it, the file named: its address would be given again.The seed, /var/lib/scrotwmos/vm/name.seed.img, is what the image's first boot reads: a vfat file system, label
SWMSEED, no partition table, made by qemu-img's vvfat driver, no mount. Its files hold one value each, no newline after it:- hostname
- the VM's name
- user
- the byol user,
SWM_USERof /etc/sv/swm-wl/run - authorized_keys
- that user's own key, ~/.ssh/id_ed25519.pub,
alone: the VM is the box's, its login the box user's. With none, or an
empty one,
vm createandvm clonerefuse; a passphrase on it is the user's to choose (ssh-keygen -t ed25519). - update
bootorno- id
- 32 hex digits, new each create and clone: a new one makes the guest make new ssh host keys and machine-id
- passhash
- the password's bcrypt hash; never the password
- nat_mac, nat_addr, nat_gw, nat_dns
- only when the VM has a NIC on
vmnat0: its MAC, its address (10.83.87.x/24), the gateway (10.83.87.1), and the resolver, the gateway again:vmnatsends its 53 on to the host's. A VM made before keeps the host's resolver at its create till made again. The image's first boot sets that NIC static, found by its MAC; its default route after a DHCP NIC's.
vm clonesrc dst- A full copy of the stopped VM src: its disk by
qemu-img convert, no backing file; its YAML with dst's disk and seed, a new MAC for each NIC, a new address onvmnat0when it has one; a copy of its UEFI vars, if it has them, no larger than its image's template; a new seed and password; a new uid. The copy runs as dst's uid in src's group, which reads src's disk alone. Refused while src is up or being built (<src>: being built), or when dst exists. vm rmname [-k]- The VM's YAML, service, seed, UEFI vars, password (zeros written over it
first) and disk, and its uid spent;
-k, before or after name, keeps the disk, its owner the spent uid. Refused while the VM is up. vm passname- The VM's password, /var/lib/scrotwmos/vm/name.pass, root's alone.
vm portnameadd|rmproto:host:guest- A port forward to the VM, added to or removed from its YAML's
forwardlist: prototcporudp, host the host's port and guest the VM's, 1 to 65535. A packet from any device butvmnat0and a session's port, from a source off10.83.87.0/24, to one of the host's own addresses on that port goes to the VM'svmnat0address and its port; the host's own connection to its own address too, but to a loopback address. Thenvmnatis sent its HUP to lay them; not running, its next start does. Refused: a VM with novmnat0address, a host port another VM or container forwards, one the host listens on, and the box's own whether one listens or not: TCP 22, TCP and UDP 53, UDP 67, 68, 123, 546 and 547; a lay skips these too.ct portis the same for a container.vm rmof a VM with forwards or avmnat0address sends the HUP;vm createandvm clonegive none. vm image list- Each base image's name, size and date.
vm image rmimage- The image, its .sha256, .log and .yaml. Refused while a VM's disk has it as its backing file.
vm image build void[--repourl] [--dirdir]- A Void base image for
vm create, made on this box: nothing mounted, no installer. Into /var/lib/scrotwmos/vm/images (or dir): void-YYYYMMDD.qcow2, 8G, sparse, 0444; its .sha256, .log, and .yaml, the qemu options it needs beyondvm create's. Its packages from the box's mirror (or--repo), signatures checked: base-minimal, linux, openssh, dhcpcd, opendoas, openntpd, e2fsprogs. The build runs as root of a user and a pid namespace of its own, its ids the build rangescrotwmos-buildin /etc/subuid and /etc/subgid, never as the box's root: the packages' scripts, dracut, GRUB's tools, sfdisk, mke2fs and qemu-img run there, with no tty, and Landlock lets them write only in the build's work directory and to /dev/null. A kernel without Landlock refuses the build. The work directory is in one of root's, 0700, that only the range's first uid may pass (a POSIX ACL); a file system without POSIX ACLs refuses the build. The range is 65536 ids or more, from 100000 up and below the uids scrotwmos gives sessions and their services; it meets no other line of its file and holds no uid of /etc/passwd or gid of /etc/group (those files alone: LDAP and other NSS sources are not read). Without one, the build is refused before it starts. The install andupdatelay it when it is missing, at the lowest free start, a multiple of 65536. GRUB boots it by BIOS; its console is hvc0. At each boot it reads its seed, a FAT file system labeledSWMSEED: hostname, user, authorized_keys, passhash (bcrypt, the user's password: the console and doas), update (boot:xbps-install -Syu), id (a new one: new host keys and machine-id). Each boot it grows its root to the disk's end, partition and ext4:vm create's disk is larger than the image. sshd takes keys alone, never root. A second build the same day is refused: its image is there already. It is run by root and needs xbps-install, sfdisk, mke2fs, chroot, usermod and qemu-img; GRUB comes from the mirror into a tools root of its own. vm image build fedora-45[--dirdir]- A base image for
vm create, by its OS's unattended net install from a recipe, its OS's version in its name; a new version is a new name. The release's CHECKSUM is fetched and checked by gpgv(1) against the release's key, baked in; the netinst kernel, initrd and installer image (images/install.img) are fetched and checked against the recipe's sha256s. Any mismatch: nothing built, no qemu run. Then a temporary qemu, user-mode net alone, installs the OS into a new sparse qcow2, 16G, from a kickstart and the checked installer image its guestfwd serves (swmtool vm image serve); the packages come from the release's mirrors, each one's signature checked against the same key before any is laid down; a bad one fails the install. The build ends when qemu exits. fedora-45.qcow2, 0444, boots by BIOS; beside it .sha256, .log, the install's console, and .yaml, the qemu options the OS needs past a VM's own: no machine, CPU, memory, disk or net. Into /var/lib/scrotwmos/vm/images (or dir), made root's 0755 when missing. The fetches and the install run as for void: root of namespaces of their own, the build range's ids, never a VM's uid. For KVM the host'skvmgroup is mapped past the range and is the work's one group, and Landlock lets it write /dev/kvm too. No /dev/kvm (no kvm module, or nested virtualization off), or nokvmgroup or one of gid 0: refused before anything is made. The image is root's. It needs qemu, qemu-img, curl and gpgv.Each boot it grows its root to the disk's end, partition and ext4:
vm create's disk is larger than the image. Then it reads its seed: a FAT12 file system on a whole disk, labeledSWMSEED, its files hostname, user (made in wheel), authorized_keys, passhash (a bcrypt hash: the console's and sudo's password; sshd takes keys alone), update (boot: dnf upgrade once a boot, orno), and id: a new one makes new ssh host keys and a new machine-id. vm image build openbsd-8.0[--dirdir]- A base image for
vm createby OpenBSD 8.0's autoinstall, under UEFI. SHA256.sig from cdn.openbsd.org is checked against OpenBSD 8.0's signify key, baked in, then each file fetched against it: cdbr, cdboot, BOOTX64.EFI, bsd.rd, bsd, bsd.mp, base80, comp80, man80, BUILDINFO. Any mismatch: nothing built. An ISO of cdbr, cdboot and bsd.rd, by mkisofs(8), boots by BIOS and UEFI, its console com0. A temporary qemu, OVMF (qemu's firmware JSON) and user-mode net alone, boots it with a new sparse qcow2, 12G; the tool answers the CD's(I)nstall, (U)pgrade, (A)utoinstall or (S)hell?witha; the installer reads its answers and the sets from guestfwd (swmtool vm image serve). Root's password is locked; its ssh key is the build's own, for one prep boot that lays the seed's script and takes the key, that boot's host keys and random seed out again. openbsd-8.0.qcow2, 0444, with .sha256, .log, both boots' console, and .yaml: UEFI, the console a serial port, no VGA. As for fedora-45, the work runs as the build range's root, withkvm, and the image is root's. It needs qemu, qemu-img, qemu-firmware, curl, ssh and mkisofs./ is 8G and does not grow; /home is the disk's last partition and grows to its end each boot, before sshd, once
vm create's disk is larger. Each boot it reads its seed, the sd with no DUID and 2880 sectors: hostname, user (made in wheel; doaspermit persist :wheel), authorized_keys, passhash (a bcrypt hash: the console's and doas's password; sshd takes keys alone), update (boot: syspatch and pkg_add -u each boot, orno), and id: one not the kept one makes new ssh host keys and a new random seed. lan0-link- byol's service /etc/sv/lan0-link, not a command to
type:
lan0follows its NIC's carrier. A bridge has carrier while any port has, and a VM's tap keeps it with the cable out: dhcpcd would keeplan0 'slease and default route, over Wi-Fi's. The NIC loses carrier,lan0goes down and dhcpcd drops its lease; the carrier back,lan0goes up. Each newlan0getsarp_accept1: a guest's gratuitous ARP of its address is a neighbor entry, its MAC and address, forvm list. Nolan0: nothing. vmnat- byol's service /etc/sv/vmnat, not a command to
type: the NAT bridge
vmnat0, laid at each boot and watched. The bridge made when missing, its MAC02:00:0a:53:57:01; its address10.83.87.1/24, the guests' gateway; IPv6 off on it; IPv4 forwarding on; then the rules, in the tableswm-natover netlink, no nft: the subnet masqueraded out any other device, fromvmnat0an invalid or untracked packet and a source not of the subnet dropped, intovmnat0from any other device nothing that is no reply, no IPv6 through it; UDP and TCP 53 fromvmnat0, from the subnet, to the gateway sent on to the host's resolver, the first IPv4 server of /etc/resolv.conf a guest can reach and not on the subnet, the port kept; nothing else sent there. With none (no file, no IPv4 server, a loopback stub alone such as systemd-resolved's127.0.0.53, link-local, or onvmnat0), UDP and TCP 53 fromvmnat0to the gateway's address is dropped, and said once with why: “no DNS”. Only that is dropped: a DNS server of the host's still answers a guest on the host's other addresses, as any port of the host's does. Each guest is pinned, in the bridge family's tableswm-nat, laid beforevmnat0comes up: a frame in from a port ofvmnat0passes only as its guest's own, from the VMs' and containers' YAMLs. IPv4 from a guest's MAC with that guest's address; ARP Ethernet's for IPv4, its source and sender MAC a guest's with that guest's address, or a probe's (sender0.0.0.0) from a guest's MAC whose sender MAC is its source; nothing else: no IPv6, no VLAN tag, no other type. A container's port (swmc*) and a VM's tap (swmq*) send their own MAC alone, and a guest's MAC comes from its port alone. Out a port, at the bridge's forward and the host's own output, a guest's MAC goes to its own port alone, and a VM's tap takes no unicast frame but its guest's. A frame to a link-local destination is dropped at the bridge's input, and no MAC is learned from one. So no container takes another guest's address or MAC, and no guest a free address or the gateway's. A guest with no YAML sends nothing; a second YAML at an address taken is not pinned, and said. A second YAML with a MAC taken is not pinned either.vm create,vm clone,vm start,ct createandct clonesend the service its HUP, which pins the new guest; the new pins take over at once, whole, from the old.lan0is the LAN's: a root container's port there is not pinned; a VM's tap is, by its MAC alone, and sends no DHCP server's (UDP from 67), router's advertisement or DHCPv6 server's (UDP from 547) frame. The holder of a tap's fd may set the tap's MAC, and the bridge would then send it that MAC's frames: the service watches the links and deletes a VM's tap whose MAC was set since it was made, said. Each step sets what it sets: a run again changes nothing. No DHCP:vm createpicks each guest's address. Then it watches, no timer: it joins nftables' change group before the first lay, and on each deletion it hears of,nft flush rulesetor a stop or restart of Void's nftables service, whose finish flushes the ruleset, it counts its rules, each chain's, and lays them again when one is gone or off, then flushes the flows a host outside opened into the subnet meanwhile; said the first time, then at the 2nd, 4th, 8th ... time with the count. Void's nftables service's load at boot is such a flush: no wait. With no /etc/nftables.conf that service's run exits at once and runit runs its finish, a flush, each second: said, and every rule on the box goes each second,vmnat's back each time; give nftables a conf, or turn it off. It watches /etc/resolv.conf too, inotify on /etc and on the directory a link names, or on its nearest ancestor while that directory is not made yet: written in place, replaced by rename, or a link turned to another target, it is read again a quarter second after the last change, the DNS rule alone laid again for the new resolver, the DNS flows to the gateway flushed from conntrack so the next query is the new resolver's, and the resolver said, one line. Its HUP (vm port,ct port, a removal of a guest with forwards, orsv hup vmnatafter a YAML edited by hand) reads every VM's and container's YAML again and lays the port forwards alone again, then flushes from conntrack the flows to the host's own addresses on each added or removed forward's port, said: from any device butvmnat0and a session's port, from a source off its subnet, a packet to one of the host's own addresses on a forward's protocol and port DNAT'd to its guest'svmnat0address and port, at prerouting; the host's own the same at output, but to a loopback address; and accepted intovmnat0. The forwards are counted and laid again with the rest after a flush, eight to a transaction. A forward of a guest with no address, on a host port one before took, or on a port the host listens on by then, is skipped and said; a YAML not read or not parsed is skipped and said, its guest's forwards none. The pins and the rules are laid beforevmnat0comes up, IPv4 forwarding after them. A failure to lay, to read the rules, to flush or to write the DNS rule is said in its log, svlogd's in /var/log/vmnat,vmnat0is taken down, said, and the run ends a minute on: runit runs it again, which lays the rules and brings it up. IPv4 forwarding is the box's, every link's, not the bridge's alone; a byol VM session sets it too. These rules and the session NAT's, whose forward chain drops a flow into a session's client from any other link, hold what crosses into and out ofvmnat0and the sessions' ports, so a guest opens no flow to a client; between two other links of the box no rule of byol's stands. ct start[--temp] name- byol: run the container name, a Void root under
runit with no kernel of its own. The container is its root,
/var/lib/scrotwmos/ct/name/root,
in a wrapper,
/var/lib/scrotwmos/ct/name,
root's, its group the range's, mode 0710: no other host user reaches the
root. Its YAML is
/var/lib/scrotwmos/ct/name.yaml.
A root in the old layout, the range's own
/var/lib/scrotwmos/ct/name,
is moved into its wrapper, and said, before start, restart, enable, exec,
clone or rm takes it. A root made before the host set its NICs has its own
dhcpcd on: its first start since takes that service link away, says so,
and marks its wrapper, so it is done once. A dhcpcd link the container
lays after that is its own and stays. The YAML is read as a VM's is: one
map of plain or quoted scalars and lists, with no YAML typing. Its keys
are the tool's, not a command line:
init- the program the container starts, as its uid 0. A list's item is one
argument; a scalar is split at blanks; 32 words at most. The first
word must be an absolute path. Refused: a program named
init,runitorrunit-init, and any path under /etc/runit/: runit's stages are the box's work. Not given:/usr/bin/runsvdir -P /etc/runit/runsvdir/default, which runs every service the root has on. memory- the cgroup's
memory.max: bytes, or digits with K, M, G or T. With it,memory.swap.maxis 0. cpus- its
cpu.max, 1 to 1024 CPUs. pids- its
pids.max, 1 to 4194304. netnone, a loopback alone;host, the host's network;lan0;vmnat0; or a list oflan0thenvmnat0, each once.mac- one MAC for each NIC, in the order of
net, each of the pool's,52:54:00:xx:xx:xx. vmnat0- the NIC's address on
vmnat0: required with a NIC there, refused without one. lan0- the NIC's address on
lan0, addr/bitsviagw, thendnsaddr if it names its resolver; ordhcp, the host its DHCP client: required with a NIC there, refused without one. A container made before the host set its NICs hasnet: lan0and nolan0key: its start is refused and says the line to add. bind- host:path or
host:path
:ro, each absolute, with no . or ..: a host directory or file seen at path, which must exist in the root, and not under /proc or /sys, nor /dev itself. Under /dev, the container's own, the host side must be a character device, as /dev/dri/renderD128; its file and directories there are made first, and anything else is refused at start. No link may be in the host path, and the container's ids must reach it. 32 at most. forward- the port forwards that
ct portadds.
The container's root is uid 0 of a user namespace over 65536 ids of its own, from 2^30 up: a line
-ct:start:65536in /etc/subuid and in /etc/subgid, a name no account has, sonewuidmapmaps it for no one. Host root never runs in it, and its ids are nobody's on the host. The two files hold 64K each: some 1400 containers; past that,ct createandct cloneare refused. Its service, /etc/sv/ct-name, runs as root only to lay the cgroup /sys/fs/cgroup/scrotwmos-ct/name with its limits, to make /run/ct/name and the NICs, and to fork the process that writes the container's id maps and moves the NICs into it. Then it runs as the container's own run uid for good, never root: the start of its line-ct-name:start:65536in /etc/subuid and /etc/subgid, its gid the same number, from the same window;ct createandct clonemake it,ct rmspends it, never given again. /run/ct/name and its cgroup are that uid's: one container's run reaches no other container's. A container from before its own run uid takes one at its next start, said once in its service's log, and its range'sct:lines, thectuser's, become-ct:lines, said. After an update, restart every container: till then its old run is thectuser's, and a break into it reaches every container not yet started again. runsv starts it again after a crash. A down file keeps it from starting at boot.The container has its own mount, pid, UTS, IPC and cgroup namespaces, and its own net namespace except with
net: host. It runs under a seccomp filter that refuses, among others, every namespace, mount, module, key, BPF and clock call. A denied argument is compared by its low word alone, the int the kernel reads, so a value with its high word set is no way past a rule. A NIC onlan0orvmnat0is a veth: its host end, namedswmc, the MAC's last three bytes and the NIC's number (for example,swmc4b5e570), is a port of the bridge; its other end is the container'sethn. The host sets each NIC before init: lo up, thenethn's address and a default route from the YAML. A NIC onlan0takes itslan0key's address and gateway, with IPv6 on and the router's advertisements taken, so SLAAC, link-local and mDNS work; a NIC onvmnat0takes itsvmnat0address, a route through 10.83.87.1 at metric 2000 (afterlan0's), and no IPv6. Onlan0: dhcpthe host runs the tree's own DHCP client for it, in its net namespace (a keeper the run's uid's withCAP_NET_ADMINalone, its engine its own uid, 499999, which must be no account's and on no /etc/subuid or /etc/subgid line): the lease's address and route, held to the rule of a static address, renewed while the container runs, taken off when lost; a lease refused costs the address, never the keeper; its resolver in /var/lib/scrotwmos/ct/name/resolv.conf, bound read-only over the root's /etc/resolv.conf. No container runs a DHCP client, and none keepsCAP_NET_ADMINorCAP_NET_RAW: it changes no link, address, route, qdisc or filter, opens no raw or packet socket, and makes the kernel load no module for one. The filter also refuses an nftables or xfrm netlink socket, an old table's write (iptables, ip6tables, arptables or ebtables) bysetsockopt(), and an AF_ALG or AF_VSOCK socket. ping goes by ping_group_range: a container with a net of its own, its own; onnet: host, the host's. Onnet: hostthe container has no /sys, and a Landlock scope keeps it from the host's abstract sockets; that needs Landlock ABI 6.The limits: a container shares the host's kernel, and a kernel bug is a way out that a VM does not have. On
net: hostit binds no port below 1024: that network is the host's user namespace's. Moving the ids drops file capabilities.Refused: a YAML that does not read, a root owned by root or not in its range, and a container up in the other mode (
--tempor not). When the container is not up in 15 s, start says so and names its log, /var/log/ct-name/current.--tempruns it over a tmpfs: an overlay on its root, its writes in memory (at most itsmemory, else 1G), gone when it stops. Its service is /run/ct/name.sv, started once, never at boot, and gone when it stops; its log is /var/log/ct-name.temp. ct stopname- runit's stop: each of the container's services down by its runsv (runit's
stage 3), or a TERM to any other init. 60 s on, the run kills its cgroup,
and 75 s on, stop does if the run has hung;
ct list-vthen sayskill. ct restartname- Stop, then start; a temporary container again temporary.
ct list[-v] [-a]- Each container's name, state (
up,temp,down), PID, uptime and boot, asvm listsays them.-vadds:netnone,host,lan0,vmnat0orbothlan0- its address on
lan0: its static one, or, ondhcp, the lease's while it holds one and is up,deadwhen its DHCP keeper ended before it;-none range- its range's first id, its root's owner
stopkillwhen its last stop needed the cgroup's kill,-elseip- while up, its NICs' IPv4 addresses in their order, comma separated: on
vmnat0, its YAML's, or for a user's container vmnat's record's; onlan0, its static one or its lease's. vmnat's record and lease are root's, their directory readable by the user's own group alone, so a user's own list reads them and no other user's.-when down or with no NIC,?for one not known forward- its forwards
disk- its root's blocks used and its disk limit,
1.2G/10G;-with no limit or the project quota off;?for a user, whom the kernel tells no project's numbers
?is a YAML or a root that does not read. As a user,ct listlists their own containers alone.-a, root's alone, adds anownercolumn after the name, and each allowed user's containers after root's, read by what is root's alone, their place's roots/ and their cgroup, never their own files: a row's state and PID its cgroup's, its range its root's owner, its ip vmnat's record's and lease's, its boot and-v's other YAML words?. ct top[-a]vm top's screen, keys and terminal for the containersct listfinds, withmemin place ofrssand each number from the container's cgroup, /sys/fs/cgroup/scrotwmos-ct/name:cpu%- cpu.stat's
usage_usecover the second, of one CPU: past 100 with more mem- memory.current
read/s,write/s- io.stat's
rbytesandwbytes, its devices summed rx/s,tx/s- the host ends of its NICs,
swmc, as a VM's taps:rx/stheirtx_bytes,tx/stheirrx_bytes uptime- since its run started
A
-is no value: a container down, its first second, no NIC (net: noneorhost), or a controller the box could not give its cgroup: io and memory are asked for, and a refusal is said in its log, fatal only for a limit the YAML sets (cpus, memory, pids). Not root and not allowed, every state is?and the status line saysnot root: states unread. Keys, on the selected container, asvm top's:uct start,dct stop,rct restart,cct console(Ctrl-] back to the top),Up,Downandq.An allowed user's
ct topshows their own containers.-a, root's alone, adds each allowed user's after root's, a row user/name, its numbers its cgroup's, none of its NICs';u,d,randcon such a row are refused: they are the user's to use.ct consolename- The container's console on this terminal, raw:
/dev/console, its init's output. A container from
ct image build voidruns Void'sagetty-consolethere, alogin: prompt (TERMxterm-256color); press Enter for a fresh one.ct createturns it on in a container from an older image that ships the service. Under runit'srunsvdir, init leaves the console free for that getty, as Void's stage 2 does. Ctrl-] leaves. The terminal is as it was after, whatever ends it: Ctrl-], the end of input, the console closed, a signal. ct execname [command ...]- command in the running container, as its uid 0, in
its namespaces, its cgroup and its filter; /bin/sh
-l when none. It always has a session of its own: with no pty, it
has no controlling terminal. Each of the caller's terminals among the
standard input, output and error is a pty of the container's; the others
pass as they are, so
ct exec web sh -c 'cat > f' < fcopies a file in. A file it writes is the container's. ct enable|disablename- Start the container at boot, or not: its service without, or with, its down file. A temporary container is never started at boot.
ct createname image size [-nnet] [-aaddr/bits via gw [dns addr]] [-ddisk] [-Ppkg,...] [-p]- byol: a container from the image
/var/lib/scrotwmos/ct/images/image.
Its root is a copy, reflinked where the file system can, with each id
moved into a new range. Its YAML is its size's,
/etc/scrotwmos/ct/recipes/sizes/size.yaml,
or else
/usr/lib/scrotwmos/ct/recipes/sizes/size.yaml:
small1 CPU, 1G, 1024 pids and a 10G disk;medium2, 4G, 4096 and 40G;large4, 8G, 16384 and 100G.The disk is a hard limit on the root's blocks, and on its inodes, one per 4K of it: an XFS project quota. A write past it fails with
ENOSPC, as XFS answers a project's limit. It holds against the guest, not against host users: seect allow. The root takes the project id its range's first id / 65536, laid with inheritance on the directory the copy is made in, before the copy, so every file in the root has it; a copy past the limit fails.-ddisk, bytes or digits and K, M, G or T, replaces the size's. The limit is kept, root's, in /var/lib/scrotwmos/ct/name/disk, not in the YAML, and laid again at each start. When the root's file system is XFS mounted withoutprjquota, create says “disk quota: off until reboot” and goes on; the id is laid all the same. byol's install putsrootflags=prjquotaon the kernel's command line andupdateadds it, so quota is on from the next boot. Not XFS, it says “disk quota: none, not XFS”.-nislan0,vmnat0,both,noneorhost. A NIC onlan0takes its address from-a, written as its YAML'slan0key: an address and its prefix, its gateway, and its resolver if given, for example-a'192.168.1.50/24 via 192.168.1.1 dns 192.168.1.1'.lan0without-ais refused, and so is-awithout a NIC onlan0;-adhcp: the LAN's DHCP server leases it, the host its client. Not given:lan0when-ais (refused when the box has nolan0), elsevmnat0, elsenone, and it says so. Alan0address another container holds is refused. A NIC gets a MAC, and onvmnat0an address, from the pool the VMs take theirs from. The root's /etc/resolv.conf is never the image's: thelan0key's resolver when it names one; else onvmnat0, its gateway,10.83.87.1, alone (vmnatsends its queries on to the host's resolver); else a copy of the host's. A random password is made;-pasks for one, with no echo.The seed, the VM seed's files, goes in the root's /etc/swmseed. With the default init, the root's rc.local reads it at each start, before runsvdir, and lays: the byol user,
SWM_USERof /etc/sv/swm-wl/run, with that user's own key, ~/.ssh/id_ed25519.pub; the password's hash; the hostname; and the NIC's static address.-Pinstalls the packages, separated by commas, withxbps-installin the container as its root before it is first used, then turns on each service they ship. It is one run on the host's network, by a mark that run takes, with the host's resolver bound over the root's for it; the YAML and the root's resolver are not touched, and a later start never takes the host's network. When it fails, the container stays, made; remove it withct rm.The copy is made in /var/lib/scrotwmos/ct/.new.name and moved to its name only once its ids are its range's: a create that is cut leaves that directory and its range, and
ct rmname takes both. Refused: a name already taken, no image, no size, no byol user or key. ct clonesrc dst- A full copy of the stopped container src in a range
of its own: its YAML, with new MACs, a new
vmnat0address and no forwards; a new seed and password. Its disk limit is src's. Refused while src is up, when dst is taken, or when src has a NIC onlan0: its address is src's. ct rmname [-k]- The container's YAML, service, password (zeros written over it first),
cgroup, /run/ct/name, root,
and its range freed, its disk limit gone, its run uid spent
(
-ktoo); for a container with forwards,vmnatis sent its HUP.-k, before or after name, keeps the root and its range: a laterct rmname takes both. Refused while it runs. When its cgroup still holds a process, rm removes the service, keeps the YAML, the password, the root and the range, says so and exits 1: a new container must not get that process's ids. ct passname- The container's password, /var/lib/scrotwmos/ct/name.pass, root's alone.
ct portnameadd|rmproto:host:guestvm portfor a container; refused without avmnat0address.ct image list- Each image's name, size (always
-: an image is a directory), date and sum:yeswhen its .sha256 is there,-when not (an image built before sums).ct image checkreads the tree. ct image checkimage- The image's tree summed again against ~
image.sha256, its sum when it was built: each
entry's path, type, mode, owner, group, xattrs, a file's size and
content's sha256, a link's target, a device's number, a hard link's first
path, sorted by path, no link followed.
okexits 0;bad, or no sum, exits 1.ct createsums its copy of the image before any id moves and refuses one that is not the sum's, and refuses an image with no sum: build it again. ct image rmimage- The image, its .log and its .sha256. A container made from it does not stop it: a container is a copy.
ct image build void[--repourl]- A Void root for
ct create, namedvoid-yyyymmdd, built asvm image build voidbuilds a VM's, in the build range: base-minimal, openssh, opendoas and xbps, sshd and the console's getty on (ct console), no kernel and no DHCP client. ct allowuser [-msize] [-ppids] [-ddisk] [-fports] [-llan0]- Lets user have containers of their own, run as them:
their record,
/var/lib/scrotwmos/ct-users/user.yaml,
root's, with their uid, the limits and the grants;
-mand-pthe limits all their containers share (their runsvdir-user tree alone: a namespace they make from a login shell is not under them);-d, 1G at least, the cap of their disk: their place's own 1G and their roots' limits summed, a create or clone that would pass it refused;-fthe host ports their forwards may take, a comma apart;-l, one each time it is given, up to 8, alan0address one container of theirs holds at a time, addr/bitsviagateway, thendnsaddr if it names its resolver, ordhcp; their place, /var/lib/scrotwmos/ct-users/user/; the service runsvdir-user, which at each boot sets their cgroup, scrotwmos-ct-users/uid, and runs their containers' services as them; andctplace, the root service theirct create,cloneandrmask to make, copy and remove a root. It sayswith “memory limited”, “pids limited” and “disk capped” after the uid whenuser: allowed, uiduid,nport(s),nlan0(s)-m,-por-dis given. Their place takes a project id of its own, 65536 plus their uid, its limit 1G, for their YAMLs, seeds, services and logs; each root its own, as root's, laid byctplace. The limits hold against the guest, which as root of its own user namespace cannot change a project id. They do not hold against the owning user, nor any host user: a user who maps their range and their uid in a namespace moves a root's files off its id, and any host user can set a project id on a file of their own and fill a container's limit with it. A wall against host users needs a store where no host user owns a file. Without-d, an allow again keeps the cap. A user's create needs a limit: a size with a disk, or-d. Allowed already: the limits replaced; a kind of grant given,-for-l, replaced, each old one not given again said, user: portportno more grantedor user: lan0lan0no more granted; a kind not given kept. As user,ct createwith-nnone,host,lan0,vmnat0orboth, and-adhcpwithlan0,start,stop,restart,console,enable,disable,list,top,exec,pass,clone,rmandportwork on their own containers;-a's address,-P,-p,--tempandct imagestay root's. Each create and clone takes a new range in their name; a user's create says no address: vmnat picks it.A user's container on a bridge takes its NICs from vmnat, root's: their run hands vmnat, on /run/ct-nat.sock, the container's net namespace; vmnat checks that it is theirs, makes the veth, picks its MAC and
vmnat0address, keeps them in its own record of the container, and pins its port to them; the user's YAML asks for a NIC, never names one.lan0and forwards are root's grants atct allow, off until then.lan0: a static grant no other container of theirs holds, or, with-adhcpand thedhcpgrant, a DHCP keeper in the container's namespace, in a cgroup of its own; vmnat learns the lease on the host's side, from the LAN server's DHCPACK the bridge sends out the container's port, never from what the namespace hears, and pins the port to it while it holds. On a user'slan0port, IPv6's router advertisements and DHCPv6 server replies are dropped, and its source is pinned to its MAC's link-local and SLAAC address, or::for DAD. Forwards:ct porton the granted host ports alone, never a port a root's guest holds; vmnat checks. A user'sct topshows no NIC numbers for a container whose YAML only asks for NICs: their names are vmnat's.A user's
ct clone, the source down, takes a new range; the place helper's child, the root of a user namespace that maps both ranges and no host id, copies the root and shifts it into the new range. The source's forwards and MACs are not kept.ct rmasksctplaceto remove the root, its range retired;-kkeeps the root and the range. Root's walls against a user are vmnat's andctplace's checks, the pins, the grants and the cgroup's limits: a user runs their own pid 1, so the container's own walls guard the guest, not the host. ct denyuser [-f] [-k]- Undoes
ct allow: refused while a container of theirs is up,-fstops them. Then their service and cgroup go, every process with an id of their ranges is killed, the ranges are retired for good (named-in /etc/subuid and /etc/subgid), and their record and place are removed;-kkeeps their roots, root's to take or remove. vm run[--temp] name,vm termname,vm image servedir path ...,ct run[--temp] name,ct finishname,ct userbootuser,ct placed- Not commands to type.
vm runis a VM service's run: qemu, exec'd as thevmuser.vm termis its control/t, the power button runit's stop presses.vm image serveis a build's guestfwd: one HTTP request from the guest on the standard input, a GET of one of the paths in dir, answered on the standard output; anything else is 404.ct runandct finishare a container's service's run and finish:ct runstarts the container;ct finishremoves what its run left.ct userbootuser is runsvdir-user's run;ct placedisctplace's. help- List the commands, one line each.
man swmtoolshows this page, on the stick too.
FILES
- keys.wrap
- on the ESP: one entry for each username
- /swmdata/images
- the store of every world's images
- /swmdata/images/root.img
- on a byol, the root's image; beside it root.next.img, a rollback not yet booted, and root.prev.img, the root before the last rollback
- /swmdata/images/tt/
- on a byol, the root's points and its place's record
- /points/hour
- on a byol, a point mounted read-only (
tt mount) - /run/ttd.sock
- ttd(8)'s socket, root's, which
ttasks - /usr/local/release/kernels
- in rescue's root: the release's VM kernels, for the worlds it adds; update-root replaces it with the kernels it laid
- /scrotwmos
- in rescue, dom0's tree, read-only: ttvm
placeboots - /mnt/user
open's root, home, and point, andplace open's place- /run/plan
- the plan, on the install stick
- /run/install.log
- the install log, on the install stick
byol's VMs:
- /var/lib/scrotwmos/vm/name.yaml
- the VM: qemu's command line, 0644
- /usr/lib/scrotwmos/vm/recipes/sizes/size.yaml
vm create's sizes:small,medium,large- /etc/scrotwmos/vm/recipes/sizes/size.yaml
- your own sizes, read first
- /var/lib/scrotwmos/vm/name.qcow2
- the VM's disk, its uid's, 0600
- /var/lib/scrotwmos/vm/name.seed.img
- the VM's seed, its uid's, 0400
- /var/lib/scrotwmos/vm/name.pass
- the VM's password, root's, 0600
- /var/lib/scrotwmos/vm/name.killed
- there when the VM's last stop needed the kill (
vm stop) - /var/lib/scrotwmos/vm/.nat_top
- the last
vmnat0address create or clone gave, root's: the next is past it, so a removed VM's comes back last - /var/lib/scrotwmos/vm/name.vars.fd
- the VM's UEFI vars, for a UEFI image alone, its uid's
- /var/lib/scrotwmos/vm/images/image.qcow2
- a base image, 0444, never changed; beside it .sha256, .log, and, when the OS has one, .yaml
- /etc/sv/vm-name
- the VM's runit service: run, control/t, runit's supervise, and a down file unless enabled
- /var/service/vm-name
- its link, once started or enabled
- /run/vm/name.sv, /var/service/vm-name.temp
- a temporary VM's service and its link, gone when it stops
- /run/vm/name
- the
vmuser's, 0700: qmp and console, the VM's sockets - /etc/runit/shutdown.d/06-vm.sh
- the box's power off presses each VM's power button, and stops each container, first
- /var/lib/scrotwmos/ct/name.yaml
- the container, 0644
- /var/lib/scrotwmos/ct/name
- its wrapper: root's, its group the range's first gid, 0710, so no other host user reaches the root
- /var/lib/scrotwmos/ct/name/root
- its root, its range's
- /var/lib/scrotwmos/ct/name/disk
- its disk limit, bytes, root's, 0644; a user's in their roots/name
- /var/lib/scrotwmos/ct/name/hostnics
- root's: the host sets its NICs, its own dhcpcd taken off once, or never on
- /var/lib/scrotwmos/ct/name/resolv.conf
lan0: dhcp's resolver, root's, 0644: the lease's name servers, written by the host's DHCP client, bound read-only over the root's /etc/resolv.conf- /var/lib/scrotwmos/ct/name.pass
- its password, root's, 0600
- /var/lib/scrotwmos/ct/name.pkgnet
-P's mark, root's: its one run on the host's network, which that run takes- /var/lib/scrotwmos/ct/.new.name
- a create or clone not yet done, root's, 0700:
ct rmtakes it and its range - /var/lib/scrotwmos/ct/name/root/etc/swmseed
- its seed, its range root's, 0400
- /var/lib/scrotwmos/ct/images/image
- an image, never changed; images root's alone, 0700; beside it .log and .sha256, its sum when it was built, 0444
- /usr/lib/scrotwmos/ct/recipes/sizes/size.yaml
ct create's sizes:small,medium,large- /etc/scrotwmos/ct/recipes/sizes/size.yaml
- your own sizes, read first
- /etc/sv/ct-name, /var/service/ct-name
- its runit service: run, finish, log/run; and its link
- /run/ct/name.sv, /var/service/ct-name.temp
- a temporary container's service and its link
- /run/ct/name
- the container's run uid's, 0700: pid,
console, killed when its
last stop needed the kill, and lease,
lan0: dhcp's address while it holds one - /var/log/ct-name, /var/log/ct-name.temp
- its service's log, svlogd's, and a temporary run's
- /sys/fs/cgroup/scrotwmos-ct/name
- its cgroup: its limits, root's; ct, the
container's; keeper,
lan0: dhcp's DHCP keeper and engine, killed at the run's end - /var/lib/scrotwmos/ct-users/user.yaml
- an allowed user's record, root's, 0644:
ct allow's uid, limits and grants, the host ports of-fand thelan0addresses ordhcpof-l - /var/lib/scrotwmos/ct-users/user
- their place, root's, 0711: roots/, root's, 0711, each name in it a container's wrapper, root's, its group the range's first gid, 0710, and in the wrapper root, the container's root, its range's; ct/, the user's: their containers' YAMLs, seeds, passwords and services
- /etc/sv/runsvdir-user
- their containers' runsvdir, root's service, run as them; at each boot it lays their cgroup and /run/ct-users/user
- /run/ct-users/user
- the user's run directory: each container's pid and console
- /etc/sv/ctplace, /run/ct-place.sock
- the place helper's service and socket, root's: a user's create's copy and shift
- /sys/fs/cgroup/scrotwmos-ct-users/uid
- an allowed user's cgroup, by uid: their limits, root's; below it, delegated to them, each container's
- /var/lib/scrotwmos/ct-users-net/user/name.yaml
- vmnat's record of a user's container with NICs, root's;
ct-users-net is 0711 and
user/ 0750, its group the
user's own (a user with none: 0700): its net, MACs,
vmnat0address,lan0and forwards - /run/ct-nat.sock
- vmnat's socket for users' containers, root's, 0666: their NICs and forwards
- /run/ct-users-net/user/name.lease
- a user's
lan0: dhcp's lease, addr/bits, vmnat's, learned on the host's side; gone at a boot - /sys/fs/cgroup/scrotwmos-ct-keepers/user
.name - a user's
lan0: dhcp's DHCP keeper's cgroup, root's - /etc/subuid, /etc/subgid
- a
-ct:start:65536line and a-ct-name:start:65536line each container, a-vm-name:start:65536line each VM - /etc/qemu/bridge.conf
- without
allow lan0orallow vmnat0: no user's tap in either bridge by qemu-bridge-helper; the file's other lines kept - /etc/sv/dhcpcd/lan0
- the wired uplink's MAC: the NIC that goes in
lan0, and the mark thatlan0is laid - /etc/sv/dhcpcd/conf
- dhcpcd's flags: it makes
lan0and keeps dhcpcd off the NIC in it, the VMs' taps, the containers' veths, vmnat0 and the sessions' links, lan0 or none: a user's own tap, an OpenVPNtap0, gets no dhcpcd either - /etc/sv/lan0-link
- the service
lan0-link - /etc/sv/vmnat
- the service
vmnat: the NAT bridgevmnat0and its rules, laid and watched - /var/log/vmnat
- its log
- /etc/passwd
- the
vmuser: a system user, home /var/lib/scrotwmos/vm, shell /sbin/nologin, inkvm - /etc/subuid, /etc/subgid
- byol: the build range
scrotwmos-build, the idsvm image buildruns as
EXIT STATUS
install exits 0 when installed, 1 when it
failed after it wrote the disk, 2 on a bad command line, and 3 when it
refused before it wrote anything. update and
update-boot exit 3 when they refused before writing
anything, with nothing left open: a prompt gave nothing (Ctrl-C, Ctrl-D), a
password refused, a keys.wrap that does not parse, or, on dom0, an older
release. A keys.wrap from before the TOTP mark, or one cut short, says
“keys.wrap: no TOTP mark: older install, or cut; reinstall”.
session and world exit 3
when any of their questions gave nothing; they wrote nothing. The other
commands exit 0 on success, 2 on a bad command line, and another value on
failure.
EXAMPLES
On the install stick, open swmdata once, by any world's
credentials, for open and the others that need it
(unlock):
# swmtool unlock alice
Update to the release on the stick, from a mirror on your own network, or back to an older release:
# swmtool update # swmtool update --repo https://example.org/current # swmtool update --force /mnt/usb/dom0.signed
Install packages into alice's world, and chromium into its VM
session vm:
# swmtool add alice htop mpv # swmtool add --session vm alice chromium
Put back a file from the home as it was three points ago:
# swmtool points alice 1 Wed 2026-10-28 14:00 CET (0 h ago) 2 Wed 2026-10-28 13:00 CET (1 h ago) 3 Wed 2026-10-28 12:00 CET (2 h ago) # swmtool open --rw --point 3 alice # cp -p /mnt/alice/point/notes.txt /mnt/alice/home/ # swmtool close alice
Back up alice's home to a USB disk, then, on any box, read a file back from its copy of 09:00 UTC:
# swmtool place init alice /dev/sdb backups # swmtool place list /dev/sdb backups alice # swmtool place open 20261025T09Z /dev/sdb backups alice # cp -p /mnt/alice/place/notes.txt /root/ # swmtool close alice
A network place in rescue: ttvm's NIC on a tap, up and on a bridge, the bridge its gateway. swmtool makes no route or firewall rule: forward and masquerade from the bridge to the server yourself.
# ip link add br0 type bridge
# ip addr add 100.64.0.1/24 dev br0
# ip link set br0 up
# ip tuntap add tap0 mode tap
# ip link set tap0 master br0 up
# swmtool place init --tap tap0 \
--ip 100.64.0.2::100.64.0.1:255.255.255.0:::off \
alice nfs:192.0.2.5:/backup backups
A dead box. It needs the world's place and the world's password,
or the recovery phrase when the password is lost. While the box lives, F6
shows each session's images and when each was last backed up. An image shown
as ‘never’ or
‘NOT enabled’ has no backup and comes
back empty.
- Install a new box with a world of the same name and the same usernames. Add slot B and a share if the dead box had them. The password may be new.
- Boot its rescue world, not the world. Plug in the place's USB disk. Admit it in F7.
- Make the world the dead box's again with
place world. It names each image and the restore that brings it back. - Restore each image from an hour that
place listshows. Add--rootfor a root or VM disk. If the password is new, add--phraseto each command. Then type the phrase. - Boot the world. Its homes are the copies'. New copies go to the same place. In F9 and F5, approve each GPU and network card that the install did not approve.
# swmtool place world /dev/sdb backups alice # swmtool place list /dev/sdb backups alice # swmtool place restore --session alice 20261025T09Z /dev/sdb backups alice
To copy back only some files instead, open the new world's home
with --rw and the copy beside it, as above. A new
world of another name opens under its own name, and the copy under the old
one, at
/mnt/old/place.
byol: a first VM. Build a Void image, make a small VM over it, start it, read its password, log in on its console, and start it with the box from now on. The image is named for the day it was built:
# swmtool vm image build void # swmtool vm image list # swmtool vm create web void-20261115 small # swmtool vm start web # swmtool vm pass web # swmtool vm console web # swmtool vm enable web
On a box with lan0, vm
create writes this YAML, its first line the command as a comment; the
MAC comes from the name, so it never changes:
# cat /var/lib/scrotwmos/vm/web.yaml # swmtool vm create web void-20261115 small machine: q35,accel=kvm cpu: host display: none device: - virtio-rng-pci - virtio-net-pci,netdev=n0,mac=52:54:00:4b:5e:57 smp: 1 m: 1G drive: - file=/var/lib/scrotwmos/vm/web.qcow2,format=qcow2,if=virtio - file=/var/lib/scrotwmos/vm/web.seed.img,format=raw,if=virtio,readonly=on netdev: bridge,id=n0,br=lan0
A Fedora VM and an OpenBSD VM, the second with a 30G disk:
# swmtool vm image build fedora-45 # swmtool vm create db fedora-45 medium # swmtool vm image build openbsd-8.0 # swmtool vm create fw openbsd-8.0 small -s 30G
A VM moved over from another box, on lan0
with the MAC it had there, so the LAN's DHCP server gives it the same
address. A relative path is in
/var/lib/scrotwmos/vm. Its disk must be the VM's own
uid's. The first start gives the VM its ids: its
-vm-mail line of
/etc/subuid. That start fails: qemu cannot read the
disk. Give the disk to the ids. runit starts qemu again, and qemu opens the
disk:
# cat /var/lib/scrotwmos/vm/mail.yaml
machine: q35,accel=kvm
cpu: host
m: 2G
smp: 2
display: none
drive: file=mail.qcow2,if=virtio,format=qcow2
netdev: bridge,id=n0,br=lan0
device: virtio-net-pci,netdev=n0,mac=52:54:00:12:34:01
# swmtool vm start mail
# u=$(awk -F: '$1 == "-vm-mail" { print $2 }' /etc/subuid)
# chown $u:$u /var/lib/scrotwmos/vm/mail.qcow2
# chmod 600 /var/lib/scrotwmos/vm/mail.qcow2
The same VM on qemu's user net, with no
lan0 or off the LAN, its ssh on the box's port 2222
alone, reached from the box:
netdev: user,id=n0,hostfwd=tcp:127.0.0.1:2222-:22 device: virtio-net-pci,netdev=n0 $ ssh -p 2222 alice@127.0.0.1
Copy a stopped VM whole, then remove the copy but keep its disk:
# swmtool vm stop web # swmtool vm clone web web2 web2: cloned, web, 52:54:00:14:6d:31 # swmtool vm rm web2 -k web2: removed, disk kept
A temporary VM for a dirty task: its writes are gone when it stops.
# swmtool vm start --temp web web: up, temp, pid 3190
Watch the VMs: once, then live, a second apart:
# swmtool vm list name state pid uptime boot mac ip db up 2817 3h4m on 52:54:00:7b:dc:25 192.0.2.50 fw down - - off 52:54:00:07:f7:ab - web temp 3190 45s on 52:54:00:4b:5e:57 192.0.2.51 # swmtool vm top name state cpu% rss read/s write/s rx/s tx/s uptime db up 2.1 3.9G 120K 340K 1.5K 900B 3h4m fw down - - - - - - - web temp 0.3 1.0G 0B 12K 0B 0B 45s
Stop a VM and keep it from starting with the box:
# swmtool vm stop web # swmtool vm disable web
A container on vmnat0 with nginx: made,
started and reached from the host, whose address is 192.0.2.10; then from
the LAN, through a forward of the host's port 8080; then by ssh through the
host:
# swmtool ct image build void # swmtool ct image list name size date sum void-20261117 - 2026-11-17 yes # swmtool ct create web void-20261117 small -n vmnat0 -P nginx web: created, void-20261117, small, range 1073741824, net vmnat0, 10.83.87.2/24 web: packages, on the host's network web: up, pid 18060 [*] Updating repository ... nginx-1.30.6_1: installed successfully. service nginx: on web: stop web: down # swmtool ct start web web: up, pid 18384 $ curl http://10.83.87.2/ # swmtool ct port web add tcp:8080:80 web: forward tcp:8080:80 added $ curl http://192.0.2.10:8080/ $ ssh -J 192.0.2.10 alice@10.83.87.2
Edit a file in it, as its root, on this terminal:
# swmtool ct exec web vi /etc/nginx/nginx.conf # swmtool ct exec web sv restart /etc/runit/runsvdir/default/nginx
Log in on its console, as the user its seed made, with its password; Ctrl-] leaves:
# swmtool ct pass web # swmtool ct console web web login: alice Password:
Watch it, a second apart:
# swmtool ct top name state cpu% mem read/s write/s rx/s tx/s uptime web up 0.3 8.1M 0B 12K 42B 0B 9s
The same container, run once as a temporary one: its writes are gone when it stops.
# swmtool ct stop web web: stop web: down # swmtool ct start --temp web web: up, temp, pid 3311 # swmtool ct list -v name state pid uptime boot net lan0 range stop ip forward web temp 3311 12s off vmnat0 - 1073741824 - 10.83.87.2 tcp:8080:80
A user's own containers: root allows alice once, with limits all her containers share and one host port for her forwards; she makes, starts and uses hers; root sees them beside its own, then denies her.
# swmtool ct allow alice -m 4G -p 2000 -f 8081 alice: allowed, uid 1001, memory limited, pids limited, 1 port, 0 lan0s $ swmtool ct create box void-20261118 small -n vmnat0 box: created, void-20261118, small, range 1073807360, net vmnat0 $ swmtool ct start box box: up, pid 4410 $ swmtool ct exec box id -u 0 $ swmtool ct port box add tcp:8081:80 box: forward tcp:8081:80 added # swmtool ct list -a name owner state pid uptime boot web root up 3311 2m on box alice up 4410 5s ? # swmtool ct deny alice -f alice: denied, 1 range retired
SEE ALSO
scrotwmos.conf(5), swmtool-answer(5), scrotwmos(7), scrotwmos-byol(7), swm-tt(8), swm-vmm(8), swmstub(8), ttd(8)
AUTHORS
Marco Peereboom <marco@peereboom.us>
| October 27, 2026 | Void Linux |