Skip to content

Engine OS 5.x boot process

Carl Kittelberger edited this page Jul 13, 2026 · 1 revision

Engine OS 5.x Boot Process & SSH Persistence

Boot Sequence

  1. U-Boot loads zImage (kernel) and DTB from boot partition
  2. Kernel boots with console=ttyS0,115200 (serial console on UART)
  3. systemd PID 1 starts, scans /usr/lib/systemd/system/ for units
  4. etc.mount mounts /etc as OverlayFS:
    • lowerdir=/etc (read-only base rootfs)
    • upperdir=/data/system/etc/overlay (writable overlay)
    • workdir=/data/system/etc/.work
  5. var.mount mounts /var as OverlayFS (same pattern)
  6. overlayfs-setup.service runs systemd-tmpfiles --create --remove /etc/az01/overlayfs.conf (wipes certain files from overlay)
  7. systemd scans /etc/systemd/system/ for enabled services (AFTER overlay is mounted)
  8. Services start in dependency order

Critical Timing Issue

systemd scans /etc/systemd/system ONCE at boot, AFTER the /etc overlay is mounted. Any files placed in the overlay AFTER this point are invisible to systemd until daemon-reload is called.

This means:

  • Overlay-only SSH persistence cannot work for enabling new services
  • The sshd.service hardlink must be in the base rootfs (not the overlay)
  • No vendor unit in 5.0.3 calls daemon-reload

SSH Persistence Solution

Must modify the base rootfs in the AZ01 image:

  1. Add sshd.service hardlink at /etc/systemd/system/multi-user.target.wants/sshd.service
  2. Add authorized_keys at /root/.ssh/authorized_keys
  3. Recompress rootfs as xz
  4. Repack AZ01 image with correct SHA1 hashes

az01-script-runner Service

  • Location: /usr/bin/az01-script-runner (compiled ELF)
  • Port: UDP 36895 (0x901f in network byte order)
  • Binding: 127.0.0.1 (localhost only)
  • Function: Receives commands via recvfrom(), executes via system()
  • Buffer: 256 bytes
  • Error handling: Prints "Command received was longer than buffer - ignoring" if command exceeds buffer
  • Status: Factory/development service, not accessible from network

Key Services

Service Purpose
connman.service Network manager (D-Bus)
az01-script-runner.service Local UDP command executor
engine.service Main Engine application
overlayfs-setup.service Applies overlayfs.conf wipe rules
sshd.service OpenSSH server (NOT enabled by default)
ip6tables.service IPv6 firewall
az01-usbsata-fixer.service USB/SATA fixer (compiled binary)
az0x-data-mkfs.service Data partition formatting (shell script)
az0x-setup-hostname.service Hostname setup (shell script)

Overlay Wipe Rules (/etc/az01/overlayfs.conf)

R /data/system/etc/overlay/ssh
r /data/system/etc/overlay/group
r /data/system/etc/overlay/gshadow
r /data/system/etc/overlay/passwd
r /data/system/etc/overlay/shadow

The R rule recursively deletes the ssh directory from the overlay. The r rules delete specific files.

SSH Configuration (5.0.3)

  • /etc/ssh/sshd_config.d/10-az0x.conf:
    HostKey /etc/ssh/ssh_host_ed25519_key
    HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-ed25519
    PermitRootLogin prohibit-password
    PasswordAuthentication no
    KbdInteractiveAuthentication no
    
  • Host keys exist: /etc/ssh/ssh_host_ed25519_key, /etc/ssh/ssh_host_rsa_key
  • InMusic CA cert in /root/.ssh/authorized_keys (767 bytes)

Current Problem (as of 2026-07-13)

Device is running 5.0.3 with modified rootfs containing:

  • sshd.service hardlink at correct location
  • User's ed25519 key + InMusic CA in authorized_keys
  • All dependencies met (sshd binary, config, host keys)

But SSH still not working (port 22 closed, connection refused).

Possible causes:

  1. sshd service failing to start for unknown reason
  2. Some security feature preventing sshd from running
  3. The hardlink not being recognized by systemd for some reason
  4. Missing dependency or configuration issue

Next Steps

  1. Get console access (serial USB adapter needed)
  2. Check systemd journal for sshd startup errors
  3. Verify sshd is actually attempting to start
  4. Check if there's a firewall or security policy blocking port 22

Clone this wiki locally