scrotwmos

Installing scrotwmos

This guide is for the person who installs scrotwmos on a machine. At the end the machine boots to a username prompt, and each username opens its own world. It also covers the byol install, updates, and repair.

Every question, key, and option has its reference in a man page: swmtool(8) for the commands, swmtool-answer(5) for the plan, swmstub(8) for the boot loader’s messages, and scrotwmos(7) for the alerts. scrotwmos-dom0(7) explains worlds and sessions.

What you need

Make the stick

  1. Build the image (see building.md):

    make RELEASE_KEY=test media
    

    The result is build/install-media.img and its .sha256. That is TEST media; media for a real machine names a key directory instead (building.md). With no RELEASE_KEY it stops.

  2. Find the stick. Check its model and serial, and that nothing on it is mounted:

    lsblk -dno NAME,MODEL,SERIAL,TRAN /dev/sdX
    findmnt -rno SOURCE | grep /dev/sdX
    

    The second command must print nothing.

  3. Keep a copy of the image named by its commit. The next build overwrites build/install-media.img:

    c=$(git rev-parse --short HEAD)
    cp build/install-media.img build/install-media-$c.img
    
  4. Write it and read it back:

    sudo dd if=build/install-media-$c.img of=/dev/sdX bs=4M conv=fsync oflag=direct
    sudo cmp -n $(stat -c %s build/install-media-$c.img) build/install-media-$c.img /dev/sdX
    

    cmp prints nothing when the stick is good.

No script writes a block device. This step is always by hand.

Use a stick of the current release. The loader checks that the installer is signed, not that it is new, so an old stick installs an old release with its old flaws.

Boot the stick

Pick the stick in the firmware’s boot menu, in UEFI mode. The loader prints its banner and LOADING, checks the installer’s signature, and starts it. If it stops with an error, write the stick again. swmstub(8) lists each message.

The installer has four consoles. Switch with Ctrl-Alt-F1 to F4:

Console What is on it
1 the wizard
2 the install log, /run/install.log
3 the kernel log
4 a root shell

The power button powers the machine off at any time. Ctrl-C at any question before the disk’s confirmation drops you into a shell. Exit the shell to start again. Ctrl-D starts the wizard over.

Install the appliance

  1. At Keyboard (us/gb/de/...) [us]: type your layout, or press Enter for US. Every later answer, the passwords too, uses it. At the boot, type a password’s digits on the main row, not the keypad: on fr and be the keypad types other characters there. Over a serial console, the boot reads a password as typed on a US keyboard.

  2. At Install (update/dom0/byol) [update]: type dom0.

  3. At Network (wired/wifi/none) [wired]: pick the link (on a machine with no Wi-Fi card, the question is Network (wired/none)). For wifi, type the network’s number from the list, then its passphrase. At address [dhcp]: press Enter, or type an address such as 192.0.2.20/24. The installer then asks route: and dns:. The installer checks that the mirror answers. If it does not, fix the network and try again: the install does not go on without it.

  4. Answer the wizard. The default is in brackets, and Enter takes it. The wizard asks again after a wrong answer, and gives the reason. The questions, in order:

    Question What to answer
    Disk to wipe the disk name, nvme0n1 or /dev/nvme0n1; the install erases the whole disk
    Hostname the machine’s name; the lock and the tabs show it
    Advanced no takes the defaults for hotplug, swap, and the package repository
    World name, Slot A username, Slot B username your everyday world and its two usernames
    Isolation, Network, Process limit how the world’s default session runs
    Package sets, Package what the install puts in it
    Share between sessions, Session for <world> a shared /share, and extra sessions on workspaces of their own
    Next world (rescue/decoy/ab/done) add a rescue world; then done

    Make the rescue world. Without it, every repair starts from the stick. The two usernames of an A/B world open the same world from two boot images; see Update. swmtool-answer(5) explains each answer, the package sets, and the network modes.

    With a USB disk plugged in and Advanced set to yes, the wizard also asks Backup disk. The install erases the disk you name and makes it the backup place of each A/B world. Last, it may ask to allow a network card or approve a GPU or card ROM. Answer yes for the hardware in this machine.

  5. The installer shows the disk:

    ERASES: <name> (<model>, <N> GiB), all data lost
    CONFIRM: type <name> to install, else restart:
    

    Type the disk’s name. Anything else starts the wizard over, with nothing written.

  6. Type a password for each username, twice. Nothing echoes. Use 12 characters or more. A lost password cannot be recovered. A world is only as strong as its password.

    Then totp: codes at loader, for phone [no]:. yes shows two secrets, one at a time, the loader’s then the login’s, each as letters and a QR code. Add each to your phone’s authenticator and type its code back. The loader then shows its code before READY. and asks LOGIN CODE: first. no turns them off; swmtool totp on on the stick turns them on later.

  7. Wait. The installer fetches the firmware, partitions the disk, and installs every world from the mirror. Each step shows as [i/n].

  8. The installer says INSTALL OK. At Done (reboot/shell/shutdown) [reboot]: pull the stick and press Enter.

If the install fails after it started to write, it says INSTALL FAILED and leaves you in a shell. Nothing boots from the disk. Read /run/install.log, then run the install again with the command on the screen. REFUSED: nothing written means that a check failed before any write. The reason is above it.

The first boot

The loader prints READY. and asks USERNAME: and PASSWORD:. The right pair prints ACCESS GRANTED. and the world starts. Each wrong pair doubles the wait. After the third, power off and try again.

The world opens on workspace 1. The bar reads <user>:<session>:1.

Key What it does
MOD+Shift+Return open a terminal
MOD+Shift+Delete lock the screen
MOD+F1 to MOD+F12 open the tabs: help, top, log, alerts, network, and more
power button power off

MOD is the Super key. Start with MOD+F1. tabs.md is the guide to every tab. When something fails, a band across the top of every output shows an alert code. scrotwmos(7) explains the codes, and F4 takes the alert apart.

Unattended install

Put a plan on the stick, and the stick installs it with no wizard.

  1. Write a plan by hand. swmtool-answer(5) has the keys and an example. Use disk = only or disk = /dev/disk/by-id/<name>, so that the wrong machine refuses the plan.
  2. Mount the stick’s partition (label SWMINSTALL) and copy in:
    • swm/plan: the plan;
    • swm/passwords: a dom0’s passwords, one username password per line;
    • swm/passphrase: byol’s password.
  3. Boot the stick.

Without unattended = yes in the plan, the stick shows the plan and asks you to type the disk’s name. With it, the stick asks nothing, installs, and powers off. A refused plan writes nothing. The stick says why and starts the wizard.

Anyone who holds this stick can read the passwords on it. Keep it as you keep the passwords.

Install byol

byol (“bring your own Linux”) is a plain Void Linux with scrotwmos as its window manager. It has no worlds. You harden it yourself. scrotwmos-byol(7) says how the installed box works: its one password, the TPM, the log, the sessions, and its own VMs.

  1. At Keyboard (...) [us]: type your layout, as for the appliance.
  2. At Install (update/dom0/byol) [update]: type byol.
  3. Set up the network as for the appliance. A wired uplink becomes the installed box’s bridge lan0, for its own VMs; a Wi-Fi one does not.
  4. Answer the wizard: disk, hostname, timezone, package sets, the advanced questions, and the sessions. A session is a container or a VM on workspaces of its own.
  5. Confirm the disk.
  6. At Login user [swm] type your username, then the password twice.

Update

An A/B world has two boot slots. An update puts the new release in slot A and moves the old one to slot B. If slot A fails to boot, log in with the slot B username: it boots the last release that ran.

From the stick

  1. Boot a stick of the new release.
  2. At Keyboard (...) [us]: press Enter.
  3. At Install (update/dom0/byol) [update]: press Enter. The stick then puts its keys in the layout the box was installed with.
  4. Answer Package repository, then each slot’s username and password.

The stick finds the installed disk, writes the new release, the VM kernels, and the stub, and updates every package of the world. It ends with UPDATE OK or UPDATE FAILED. Run it once for each world. For the rescue world and the decoy, leave the slot B username empty. After an A/B world, the update says:

NOTE: rescue and decoy not updated
NOTE: update each: swmtool update, its username as slot A, slot B empty

From the rescue world

  1. Boot the rescue world’s username.

  2. Write the new release to a world’s boot slots:

    swmtool update-boot /mnt/dom0.signed
    

    Rescue has no network, so give a path, such as a release on a USB disk. With no argument, it takes the release beside swmtool.

  3. Update the world’s VM kernels and packages:

    swmtool update-root <user>
    

    With no network, --repo and --kernels must name local paths.

The rescue world’s own root is in use while it runs. Update it from the stick. swmtool refuses a release older than the installed one, unless --force. A machine installed from release keys refuses a nightly.

byol

Boot the stick and answer update. It updates the scrotwmos files, the boot stub, and each session’s root. It asks for the disk’s password. On a box from before swmtool vm, when the stick’s uplink is wired, it also adds the bridge lan0; lan0 takes effect at the next boot. It adds no vm user, and keeps one already there. It adds no package to the box, not even qemu: swmtool vm names each package that it lacks and the xbps-install line that adds them.

Repair

Boot the rescue world

Type the rescue world’s username at boot. It runs alone, as root, with the repair tools and every disk. It has no network: update from the stick. Each shell prints the list of commands.

Open the disk from the stick

Press Ctrl-C in the wizard, or use console 4. Then:

swmtool unlock <user>

It says swmtool: swmdata: open at /swmdata. Only a power off closes it again. swmtool passwd and swmtool update-boot do not need it. swmtool update refuses after an unlock: it opens the disk itself.

A dead ESP

If the loader does not start or the ESP does not mount, run swmtool esp restore from the stick. swmtool(8) describes it under esp restore.

A dead box

A world comes back on a new box from its backup place, with its password or its recovery phrase. The steps are in swmtool(8), under EXAMPLES. man swmtool works on the stick.

Common jobs

Each command asks for the credentials of the world it changes. Root on the machine can erase a world but cannot read one.

Job Command
change a password swmtool passwd
install packages in a world swmtool add <user> <pkg>...; --session NAME for a session
add, change, or remove a session swmtool session
add or remove a world swmtool world
read a world’s files swmtool open <user>, then /mnt/<user>/root and /mnt/<user>/home; swmtool close <user>
write down the recovery phrase swmtool place phrase <user>; keep it on paper, away from the box and the place
join a session to the share (rescue only) swmtool share join <user> <session>
fetch firmware for new hardware swmtool firmware scan, then swmtool firmware refresh

Changes take effect at the world’s next boot. swmtool help lists every command. swmtool(8) has each option and an example. The stick carries it and swmtool-answer(5) too.