VM base build
All three VMs start from the same base: Debian 13 on an encrypted disk, a serial console, SSH by key only, Docker, automatic security updates, and its network set inside the VM: a tagged VLAN for infra and standby, the Mac’s own untagged network plus one tagged leg for home. This chapter builds that base once per VM. Chapters 6, 7 and 14 then add what makes each VM different.
Do the whole chapter for infra now. Come back for home when chapter 7 sends you here (from-scratch path only: the restore path moves the existing VM instead), and for standby when chapter 14 does.
infra |
home |
standby |
|
|---|---|---|---|
| Memory | 4096 MB | 4096 MB | 4096 MB |
| CPU cores | 2 | 4 | 2 |
| Disk | 96 GB | 64 GB | 256 GB (see chapter 14 for sizing) |
| VLAN | 2 | 5, plus 4 | 10 |
| Address | 10.0.2.5 | 10.0.5.2 and 10.0.4.2 | 10.0.6.2 |
| Network file | vm/infra/etc/network/interfaces |
vm/home/etc/network/interfaces |
vm/standby/etc/network/interfaces |
UTM disks are sparse: a 96 GB disk takes only what the VM has written.
Restore path for infra. An infra VM already exists, built on 2026-11-25 with an encrypted disk and the right address. If you carried its bundle over in step 2.9, double-click it on the new Mac to add it to UTM, then do only steps 5.7 to 5.14 on it: they are written so that running them on an existing VM is safe. In its settings raise the memory to 4096 MB first, and grow the disk as shown at the end of this chapter.
Set these once in the Terminal window you work in, with the VM’s name:
export VM=infra # or home, standbyPart A. Create and install
Section titled “Part A. Create and install”5.1 Get the installer and check it
Section titled “5.1 Get the installer and check it”Why. The ISO is the root of trust of the VM. A checksum proves the download is the file Debian published.
Mac
mkdir -p ~/Downloads/debian && cd ~/Downloads/debiancurl -LO https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/SHA256SUMSISO=$(grep -o 'debian-13[0-9.]*-arm64-netinst.iso' SHA256SUMS | head -1)curl -LO "https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/$ISO"shasum -a 256 -c SHA256SUMS --ignore-missingVerify. The last command prints debian-13.x.x-arm64-netinst.iso: OK.
Rollback. Delete the folder.
5.2 Create the VM in UTM
Section titled “5.2 Create the VM in UTM”Why. The Apple Virtualization backend is the fast one on Apple silicon. Bridging puts the VM straight on the switch port, where it can tag its own VLAN. The serial device is the only console that shows the disk passphrase prompt.
Mac UTM: + > Virtualize > Linux
- Tick Use Apple Virtualization. Boot ISO Image: the ISO from step 5.1.
- Memory and CPU cores from the table above.
- Storage: the disk size from the table. Shared directory: skip.
- Name:
infra,homeorstandby, exactly. The scripts find VMs by these names. Tick Open VM Settings, then Save. - In the settings:
- Network: Network Mode: Bridged (Advanced), Bridged Interface: en0. Write down the MAC address.
- Devices > New > Serial: mode Pseudo-TTY Device.
- Remove the Sound device if one is listed.
- Save.
Verify. $U list shows the VM as stopped.
Rollback. In UTM, right-click the VM > Delete.
5.3 Install Debian with an encrypted disk
Section titled “5.3 Install Debian with an encrypted disk”Why. R5: the disk is encrypted from the first write. The installer runs on the Mac’s own network (Trusted, VLAN 5, untagged), which has DHCP and internet, so it needs no VLAN setup. Two throwaway secrets are used during the install because nothing can be pasted into the installer. Step 5.8 replaces both with the real ones from 1Password.
Mac Start the VM in UTM and choose Install (the text installer). Answer:
| Screen | Answer |
|---|---|
| Language, location, keyboard | English, Canada, your keyboard |
| Network | Automatic (DHCP). It gets a 10.0.5.x address |
| Hostname | infra, home or standby |
| Domain name | empty |
| Root password | leave empty, twice. The installer then gives your user sudo |
| Full name, username | admin |
| User password | temp-install-1 (replaced in step 5.8) |
| Partitioning | Guided - use entire disk and set up encrypted LVM, then All files in one partition |
| Erasing data | Cancel the erase with Cancel: a new virtual disk holds nothing to overwrite |
| Encryption passphrase | temp-install-1 (replaced in step 5.8) |
| Amount of volume group | max |
| Software selection | Untick everything except SSH server and standard system utilities |
When the installer finishes, let it reboot, then stop the VM ($U stop $VM), open its settings, and clear the ISO from the CD/DVD drive.
Verify. $U status $VM prints stopped, and the VM’s CD/DVD drive is empty.
Rollback. Delete the VM and start again at step 5.2.
5.4 First boot through the serial console
Section titled “5.4 First boot through the serial console”Why. On this backend the kernel’s console is the serial port. The UTM window stops at “Loading initial ramdisk” and looks frozen, while the VM is in fact waiting for the passphrase on the serial side.
Mac
$U start $VMsleep 5; screen "$(vm-tty $VM)"If vm-tty prints nothing, read Serial (TTY) in the VM’s details in UTM and use that path. Press Return. At Please unlock disk vda3_crypt: type temp-install-1. The device name can differ (vda4_crypt): it does not matter. Log in as admin with temp-install-1, then:
ip -br addrNote the 10.0.5.x address of enp0s1. If the interface has another name, use it wherever this guide writes enp0s1, including in the network file. Leave screen open in this tab.
Mac (a second Terminal tab)
export VM=infra VMIP=10.0.5.x # the address you just readVerify. ping -c 2 $VMIP answers.
Rollback. $U stop $VM.
Part B. Base configuration
Section titled “Part B. Base configuration”5.5 Your SSH key, then the common files
Section titled “5.5 Your SSH key, then the common files”Why. From here on you work over SSH with the key held in 1Password. The folder vm/common holds the settings shared by the three VMs.
Mac
ssh-copy-id -f -i ~/.ssh/mac-admin.pub admin@$VMIP # asks for temp-install-1 oncescp -r $INFRA/vm/common admin@$VMIP:/tmp/commonscp $INFRA/vm/$VM/etc/network/interfaces admin@$VMIP:/tmp/interfacesVerify. ssh admin@$VMIP hostname prints the VM’s name after a Touch ID prompt, with no password asked.
Rollback. ssh admin@$VMIP 'rm ~/.ssh/authorized_keys'.
5.6 Packages
Section titled “5.6 Packages”Why. vlan and ethtool make the tagged network possible, resolvconf applies the DNS servers named in the network file, and the others are the tools the verification steps use. They are installed now, while the VM still has plain internet on the Mac’s network: on the tagged VLAN nothing works until ethtool has turned checksum offload off.
VM (ssh admin@$VMIP)
sudo apt updatesudo apt install -y vlan ethtool resolvconf curl ca-certificates rsync ndisc6 netcat-openbsd \ tcpdump dnsutils cifs-utils unattended-upgrades zram-tools systemd-timesyncd jqVerify. dpkg -l vlan ethtool resolvconf | grep -c '^ii' prints 3.
Rollback. sudo apt purge the same list.
5.7 Send the console to the serial port for good
Section titled “5.7 Send the console to the serial port for good”Why. The last console= named on the kernel line receives the passphrase prompt and the boot log. Naming hvc0 last makes that explicit, and tty0 keeps a copy in the UTM window.
VM
sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=hvc0"/' /etc/default/grubsudo update-grubVerify. grep '^GRUB_CMDLINE_LINUX_DEFAULT' /etc/default/grub prints GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=hvc0".
Rollback. Put quiet back in that line and run sudo update-grub.
5.8 Replace the throwaway secrets with the real ones
Section titled “5.8 Replace the throwaway secrets with the real ones”Why. The disk passphrase and the user’s password now come from 1Password, sent over SSH so they never appear on screen or in a file. The new passphrase is added and tested before the old one is removed, so a typing error cannot lock the disk.
Mac
DEV=$(ssh admin@$VMIP "lsblk -lnpo NAME,FSTYPE | awk '\$2==\"crypto_LUKS\"{print \$1}'"); echo $DEV # for example /dev/vda3ssh -t admin@$VMIP "sudo cryptsetup luksAddKey $DEV"It asks three things. [sudo] password: temp-install-1. Enter any existing passphrase: temp-install-1. Enter new passphrase and its confirmation: in another tab run op read "op://Infrastructure/LUKS $VM/password" | pbcopy, then paste twice. Then test the new passphrase, remove the old one, and set the user’s password:
op read "op://Infrastructure/LUKS $VM/password" | pbcopyssh -t admin@$VMIP "sudo cryptsetup open --test-passphrase $DEV && echo NEW-PASSPHRASE-OK" # pastessh -t admin@$VMIP "sudo cryptsetup luksRemoveKey $DEV" # type temp-install-1op read "op://Infrastructure/VM $VM user/password" | pbcopyssh -t admin@$VMIP "passwd" # current: temp-install-1, new: paste twicepbcopy < /dev/nullVerify. ssh -t admin@$VMIP "sudo cryptsetup luksDump $DEV | grep -c '^ [0-9]: luks2'" prints 1 (one key slot), and the test line above printed NEW-PASSPHRASE-OK.
Rollback. While temp-install-1 is still a valid passphrase nothing is lost. After its removal, the only passphrase is the one in 1Password: check the item opens before you run luksRemoveKey.
5.9 Harden SSH and pin the parent interface down
Section titled “5.9 Harden SSH and pin the parent interface down”Why. Keys only, one user, no root login. The two small files keep the untagged parent interface from ever taking an address on the Mac’s network, and load the VLAN module at boot. The sudoers file lets your user run sudo without the VM password, which is what allows the Mac to drive a VM with one ssh vm 'sudo …' line in every later chapter. The gate is the SSH key: it lives in 1Password and asks for Touch ID on each use. The password still protects the console.
VM
sudo install -m 644 /tmp/common/etc/ssh/sshd_config.d/10-hardening.conf /etc/ssh/sshd_config.d/sudo install -m 644 /tmp/common/etc/sysctl.d/90-enp0s1-no-slaac.conf /etc/sysctl.d/sudo install -m 644 /tmp/common/etc/modules-load.d/8021q.conf /etc/modules-load.d/sudo install -m 755 /tmp/common/verify.sh /usr/local/bin/verify.shsudo install -m 440 /tmp/common/etc/sudoers.d/10-admin-nopasswd /etc/sudoers.d/ && sudo visudo -csudo sshd -t && sudo systemctl reload sshsudo modprobe 8021qKeep this SSH session open and test from a second tab before you close it.
Verify. From the Mac, ssh admin@$VMIP true still works, ssh admin@$VMIP 'sudo -n true && echo SUDO-OK' prints SUDO-OK, and ssh -o PubkeyAuthentication=no -o PreferredAuthentications=password admin@$VMIP true is refused with Permission denied (publickey).
Rollback. sudo rm /etc/ssh/sshd_config.d/10-hardening.conf /etc/sudoers.d/10-admin-nopasswd && sudo systemctl reload ssh.
5.10 Docker
Section titled “5.10 Docker”Why. Every service runs as a container. Docker’s own repository carries the current engine and the Compose plugin. The daemon file caps container logs so they cannot fill the disk.
VM
sudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.ascecho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo $VERSION_CODENAME) stable" | sudo tee /etc/apt/sources.list.d/docker.listsudo apt updatesudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-pluginsudo install -m 644 /tmp/common/etc/docker/daemon.json /etc/docker/daemon.jsonsudo systemctl restart dockersudo usermod -aG docker adminsudo install -d -o admin -g admin /srv/stackLog out and in again so the group applies.
Verify. docker run --rm hello-world | grep -c 'Hello from Docker' prints 1, and docker info --format '{{.LoggingDriver}}' prints local.
Rollback. sudo apt purge docker-ce docker-ce-cli containerd.io docker-compose-plugin.
5.11 Unattended security updates and a lean system
Section titled “5.11 Unattended security updates and a lean system”Why. The house’s DNS server should receive security fixes without waiting for you. Compressed swap in memory avoids disk swap inside a VM, and a journal cap keeps logs bounded.
VM
echo 'unattended-upgrades unattended-upgrades/enable_auto_updates boolean true' | sudo debconf-set-selectionssudo dpkg-reconfigure -f noninteractive unattended-upgradessudo sed -i 's/^#\?ALGO=.*/ALGO=zstd/; s/^#\?PERCENT=.*/PERCENT=50/' /etc/default/zramswapsudo systemctl restart zramswapsudo mkdir -p /etc/systemd/journald.conf.dprintf '[Journal]\nSystemMaxUse=200M\n' | sudo tee /etc/systemd/journald.conf.d/size.confsudo systemctl restart systemd-journaldsudo systemctl disable --now man-db.timer e2scrub_all.timersudo timedatectl set-timezone America/TorontoUnattended upgrades install fixes but never reboot the VM. Kernel updates take effect at the monthly restart of chapter 15.
Verify. systemctl is-enabled unattended-upgrades prints enabled, swapon --show | grep -c zram prints 1, and timedatectl show -p NTPSynchronized --value prints yes.
Rollback. sudo dpkg-reconfigure unattended-upgrades and answer No.
Part C. Move to the VM’s own network
Section titled “Part C. Move to the VM’s own network”5.12 Switch the network to the VM’s own address
Section titled “5.12 Switch the network to the VM’s own address”Why. Until now the VM sat on the Mac’s network with an address from DHCP. infra and standby belong in their own VLAN, tagged inside the VM. home stays in the Trusted network, untagged like the Mac (J27), with a fixed address and one tagged leg in IoT. The file turns checksum offload off on the parent interface: without that, ping works on the VLAN and every TCP and UDP connection fails. dhcpcd is disabled because it would keep an address on the Mac’s network and rewrite the DNS settings.
home only, before you go on: the file gives the VM 10.0.5.2. If chapter 7 told you to start at 10.0.5.20, edit /tmp/interfaces now as that chapter says.
VM, from the screen tab of step 5.4, not over SSH: the SSH session dies when the address changes.
sudo systemctl disable --now dhcpcd 2>/dev/null; sudo apt purge -y dhcpcd-base 2>/dev/nullsudo cp /etc/network/interfaces /etc/network/interfaces.installersudo rm -f /etc/network/interfaces.d/*sudo install -m 644 /tmp/interfaces /etc/network/interfacessudo rebootThe VM restarts and asks for the passphrase in the same screen tab. If the tab closed, reopen it with screen "$(vm-tty $VM)". Paste the passphrase (op read "op://Infrastructure/LUKS $VM/password" | pbcopy in another tab). Log in with the password from VM <name> user.
Verify. On the console, ip -br addr shows the address from the table on enp0s1.<vlan> and no IPv4 address on enp0s1. For home it is the reverse: 10.0.5.2 on enp0s1 itself, and 10.0.4.2 on enp0s1.4. From the Mac, ssh $VM hostname answers (the short names come from step 4.8).
Rollback. On the console: sudo cp /etc/network/interfaces.installer /etc/network/interfaces && sudo apt install -y dhcpcd-base && sudo reboot. The VM returns to the Mac’s network by DHCP. Note that apt needs the network: if the tagged VLAN never worked, run sudo ip link set enp0s1 up && sudo dhcpcd enp0s1 after restoring the file to get an address by hand first.
If ping to the gateway fails on the tagged VLAN: on the Mac run sudo tcpdump -eni en0 vlan while the VM pings. Tagged frames shown means the Mac’s bridge passes them, so check step 3.5 (the port must carry that VLAN tagged, and Trusted untagged). For standby, also check that the Standby network exists (step 3.3).
5.13 Restart test with the unlock script
Section titled “5.13 Restart test with the unlock script”Why. This is the routine after every restart of the Mac. Testing it now, on one VM, proves vm-unlock on your hardware before the house depends on it.
Mac
ssh $VM sudo poweroff; sleep 15$U start $VM --hidesleep 8; vm-unlock $VMsleep 40; ssh $VM uptimeVerify. vm-unlock prints <vm>: passphrase sent, and uptime shows less than two minutes.
Rollback. If vm-unlock fails, unlock by hand as in step 4.12 and note the failure for chapter 16. Everything else in the guide works with the manual way.
5.14 The base check
Section titled “5.14 The base check”Why. One read-only script answers “is this VM’s base healthy?” now and on any later day.
Mac
ssh $VM verify.sh 2 # the VLAN id of the VM's main network: 2 for infra, 5 for home, 6 for standbyVerify. Compare with this table:
| Line | Expected |
|---|---|
| offload | tx-checksumming: off and rx-checksumming: off |
| addresses | infra, standby: enp0s1 UP with no IPv4 address, enp0s1.<vlan> with the VM’s address. home: enp0s1 with 10.0.5.2, enp0s1.4 with 10.0.4.2 |
| dhcpcd | inactive, or nothing |
| resolv | infra and standby: 1.1.1.2 and 1.0.0.2. home: 10.0.2.5 then 10.0.5.1 |
| route | dev enp0s1.<vlan>. home: dev enp0s1 |
| mtu | 0% packet loss |
| TCP | OK |
| DNS | an address for debian.org |
| grub | console=tty0 console=hvc0 |
| luks | one line containing crypt |
| ssh | permitrootlogin no and passwordauthentication no |
| updates | enabled |
| clock | yes |
| docker | an empty list for now |
On home, DNS answers only once the infra VM serves it (chapter 6), or through the second server 10.0.5.1.
Rollback. None needed, read only.
5.15 Name it in UniFi and keep a copy
Section titled “5.15 Name it in UniFi and keep a copy”Why. A fixed entry in the controller stops DHCP from ever giving the VM’s address to something else, and shows the VM under its name. A copy of the bundle taken now is a clean base to return to.
UniFi Client Devices: find the client with the MAC address noted in step 5.2 (it appears on the VM’s VLAN). Settings: name it infra, home or standby, and set Fixed IP Address to its address.
Mac
ssh $VM sudo poweroff; sleep 20mkdir -p ~/vm-basecp -Rc ~/Library/Containers/com.utmapp.UTM/Data/Documents/$VM.utm ~/vm-base/$VM-base.utm$U start $VM --hide; sleep 8; vm-unlock $VMcp -c makes an instant copy that shares disk blocks, so it costs almost no space. Do not use one VM’s copy as the start of another VM: both would share the same disk master key.
Verify. The controller lists the VM under its name with the fixed address, and ls ~/vm-base shows the copy.
Rollback. Delete the copy. Remove the fixed address in the controller.
Growing a disk later
Section titled “Growing a disk later”Mac, with the VM stopped: in UTM, the VM’s Settings > Drives > the disk > Resize. Then start and unlock the VM, and inside it:
DEV=$(lsblk -lnpo NAME,FSTYPE | awk '$2=="crypto_LUKS"{print $1}') # for example /dev/vda3sudo apt install -y cloud-guest-utilssudo growpart ${DEV%[0-9]*} ${DEV##*[a-z]}sudo cryptsetup resize $(lsblk -lnpo NAME,TYPE | awk '$2=="crypt"{print $1}')sudo pvresize $(sudo pvs --noheadings -o pv_name | tr -d ' ')sudo lvextend -r -l +100%FREE $(findmnt -no SOURCE /)df -h /cryptsetup resize asks for the disk passphrase.
Result
Section titled “Result”A VM that boots to a passphrase prompt on its serial console, unlocks from 1Password, answers at its fixed address on its own network, accepts SSH by key only, updates itself, and runs Docker. It serves nothing yet.