First Boot, Cloud-Init & Recovery
On first boot, headless-phone turns a generic, secret-free Debian rootfs into a unique host with its own identity, SSH keys, networking, and full-disk root partition — completely offline.
First-Boot Lifecycle
Section titled “First-Boot Lifecycle”-
Stage 1 Initramfs (
initramfs/init)Loads SoC, UFS storage, USB-C/TCPCI, thermal, and hardware watchdog (
s3c2410_wdt) modules, resolvesPARTNAME=userdatavia/sys/class/block/*/uevent, performs a non-destructive read-only probe (mount -t ext4 -o ro,noload) checking for/sbin/init, then mounts read-write and executesswitch_root. -
Read-Only
/vendorMount (mount-vendor.service)Runs before
sysinit.targetandcloud-init-local.service. Parses the device’ssuperpartition LP metadata with SHA-256 verification, exposesvendoras read-only/dev/mapper/headless-vendormounted at/vendor, and loads vendor firmware kernel modules (e.g., Wi-Fibcmdhd4389) sowlan0is ready before networking starts. -
Local
cloud-initProvisioning (cloud-init-lite)Configured via
/etc/cloud/cloud.cfg.d/90-headless-nocloud.cfg(datasource_list: [ NoCloud, None ]) so it never stalls waiting for cloud metadata endpoints. Reads/var/lib/cloud/seed/nocloud/if injected at flash time, applying hostname, user accounts, SSH keys,ssh_pwauth, Netplan Wi-Fi/static IP config, andruncmd. -
Idempotent First-Boot Identity & Resize (
firstboot-setup)Runs before
systemd-networkd,ssh.service, andavahi-daemon:- Online ext4 resize: Expands
/viaresize2fsto fill the entireuserdatapartition (stamps/var/lib/headless-phone/resize-doneonly on success so failures retry cleanly). - Unique fallback hostname: If
/etc/hostnameis empty orheadless-phone(i.e. not overridden bycloud-init), sets<codename>-<last-6-of-serial>(e.g.raven-a1b2c3), updates/etc/hosts, and stamps/var/lib/headless-phone/hostname-done. - Unique SSH host keys: Generates fresh
/etc/ssh/ssh_host_*_keyfiles viassh-keygen -A(base image ships with zero host keys and an empty/etc/machine-id).
- Online ext4 resize: Expands
-
Networking, Power & Slot-Success Confirmation
systemd-networkdbrings up wired Ethernet (fallback/etc/systemd/network/90-wired-dhcp.network, overridden by Netplan10-netplan-*when seeded) and Wi-Fi.[email protected]shuts off the OLED CRTC via DRM KMS as soon as/dev/dri/card*appears.charge-limit.servicecaps battery charge at 55%–70% andbrownout-guard.servicestarts monitoring battery/charger health.- Once
ssh.serviceand a carrier-up global IP uplink are confirmed,mark-boot-ok.servicemarks the A/B slot successful (on verified, allowlisted bootloaders).
Connecting to Your Phone
Section titled “Connecting to Your Phone”Over the Network (mDNS or IP)
Section titled “Over the Network (mDNS or IP)”# Seeded install (custom hostname)
# Unseeded install (auto-generated from codename + last 6 chars of serial)- Default credentials (when unseeded): user
pixel, passwordheadless(passwordlesssudoenabled via/etc/sudoers.d/90-headless-phone; root login is locked andPermitRootLogin nois enforced). - Wired Ethernet: Plug into any USB-C Gigabit Ethernet adapter or USB-C PD dock (
r8152,r8153_ecm,cdc_ncm,cdc_etherare preloaded via/etc/modules-load.d/headless-phone.conf).
Over USB-C Recovery Console (ttyGS0)
Section titled “Over USB-C Recovery Console (ttyGS0)”Whenever the phone is plugged directly into a PC (USB-C Device / UFP role), usb-role.service binds a Linux configfs CDC ACM serial gadget (0525:a4a7) and spawns [email protected].
- Linux:
/dev/ttyACM0— e.g.screen /dev/ttyACM0 115200orpicocom -b 115200 /dev/ttyACM0 - macOS:
/dev/cu.usbmodem* - Windows: Standard COM port using inbox
usbser.sys(no driver install needed; connect with PuTTY, Tera Term, or Windows Terminal +plink)
Use this offline console anytime to check IP addresses, fix Wi-Fi credentials, or inspect journalctl.
Complete YAML Provisioning Schema (--config node.yaml)
Section titled “Complete YAML Provisioning Schema (--config node.yaml)”Both tools/flash.py --config and tools/mkconfig.py --config accept a YAML mapping with the following fields:
hostname: pixel-node1user: ops # Default: pixel. Non-pixel locks the factory pixel account.# password: "initial-password" # Optional cleartext chpasswd overridessh_authorized_keys: - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... daniel@workstation"disable_password_auth: true # Requires >= 1 valid SSH key; sets ssh_pwauth: falseinstance_id: pixel-node1-v1 # Optional explicit NoCloud instance-id
# Optional Wi-Fi (wlan0, DHCPv4, optional: true)wifi_ssid: "MyHomeWiFi"wifi_psk: "MyWifiPassphrase" # Omit for open networks
# Optional static IPv4 for wired Ethernet (matches both en* and eth*)static_ip: "192.168.1.50/24"gateway: "192.168.1.1"dns: - "1.1.1.1" - "9.9.9.9"
# Optional extra first-boot commands (YAML-only; runs after adding user to docker group)runcmd: - "timedatectl set-timezone Australia/Perth" - "apt-get update && apt-get install -y tmux jq"Emergency Recovery Modes
Section titled “Emergency Recovery Modes”- Fastboot Recovery: Hold Volume Down while rebooting to enter fastboot. From there you can switch to the opposite A/B boot slot (
fastboot --set-active=<a|b>) or re-flash a boot image set. Note thatuserdatais shared across slots — switching back to a stock Android boot slot only restores Android’s boot chain; booting stock Android again requires wiping/restoringuserdatawith a factory image. - Stage 1 Initramfs USB Shell (
headless.shell=1): Ifuserdatafails to mount, lacks/sbin/init, or the boot image was built withSHELL_MODE=1, Stage 1 initramfs automatically brings up the0525:a4a7CDC ACM gadget (product="headless-initramfs-serial") and drops into an interactive BusyBox recovery shell (headless-initramfs#) on/dev/ttyGS0(115200 8N1). On Pixel 6 / 6 Pro (split Header v4boot+vendor_boot), flash the matchedSHELL_MODE=1recovery boot set to an A/B slot without--userdata(python tools/flash.py --boot-dir <dir> --slot <a|b> --reboot, adding--vbmeta path/to/stock-vbmeta.imgif AVB verification is still enabled on that slot — see Offline CLI Flashing). On devices with self-contained non-split recovery images (Header v2), you can RAM-boot non-destructively withpython tools/flash.py --boot-dir <dir> --ram-boot. - Automatic Rollback: If a newly flashed kernel fails to reach SSH + network uplink,
mark-boot-ok.servicenever marks the slot successful, and ABL automatically falls back after retry count exhaustion. See Firmware, Watchdog & A/B Safety.