diff --git a/base/base.conf b/base/base.conf
index 5e2684c..88d8261 100644
--- a/base/base.conf
+++ b/base/base.conf
@@ -2,11 +2,15 @@
Distribution=debian
Release=trixie
+[Build]
+PackageCacheDirectory=mkosi.cache
+Environment=KERNEL_IMAGE KERNEL_VERSION
+
[Output]
Format=uki
+ManifestFormat=json
ImageId=tdx-debian
OutputDirectory=build
-PackageCacheDirectory=mkosi.cache
Seed=630b5f72-a36a-4e83-b23d-6ef47c82fd9c
[Host]
@@ -15,12 +19,10 @@ Seed=630b5f72-a36a-4e83-b23d-6ef47c82fd9c
[Content]
SourceDateEpoch=0
KernelCommandLine=console=tty0 console=ttyS0,115200n8 mitigations=auto,nosmt spec_store_bypass_disable=on nospectre_v2
-Environment=KERNEL_IMAGE KERNEL_VERSION
SkeletonTrees=base/mkosi.skeleton
FinalizeScripts=base/debloat.sh
PostInstallationScripts=base/debloat-systemd.sh
BuildScripts=base/mkosi.build
-PrepareScripts=base/export-packages.sh
CleanPackageMetadata=true
Packages=kmod
@@ -28,6 +30,9 @@ Packages=kmod
systemd-boot-efi
busybox
util-linux
+ procps
+ ca-certificates
+ openssl
iproute2
udhcpc
e2fsprogs
@@ -37,4 +42,4 @@ BuildPackages=build-essential
cmake
pkg-config
clang
- cargo
\ No newline at end of file
+ cargo
diff --git a/base/debloat-systemd.sh b/base/debloat-systemd.sh
index adf4900..f0d0a84 100755
--- a/base/debloat-systemd.sh
+++ b/base/debloat-systemd.sh
@@ -22,6 +22,7 @@ systemd_bin_whitelist=(
"systemctl"
"journalctl"
"systemd"
+ "systemd-tty-ask-password-agent"
)
mkosi-chroot dpkg-query -L systemd | grep -E '^/usr/bin/' | while read -r bin_path; do
diff --git a/base/debloat.sh b/base/debloat.sh
index 69e33e9..f337fa5 100755
--- a/base/debloat.sh
+++ b/base/debloat.sh
@@ -27,6 +27,7 @@ debloat_paths=(
"/usr/share/mime"
"/usr/lib/modules"
"/usr/lib/udev/hwdb.d"
+ "/usr/lib/udev/hwdb.bin"
"/usr/lib/systemd/catalog"
"/usr/lib/systemd/user"
"/usr/lib/systemd/user-generators"
@@ -35,7 +36,6 @@ debloat_paths=(
"/usr/lib/tmpfiles.d"
"/etc/systemd/network"
"/etc/credstore"
- "/usr/lib/x86_64-linux-gnu/security"
)
for p in "${debloat_paths[@]}"; do rm -rf "$BUILDROOT$p"; done
\ No newline at end of file
diff --git a/base/export-packages.sh b/base/export-packages.sh
deleted file mode 100755
index 8413f6e..0000000
--- a/base/export-packages.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-if [ "$1" == "final" ]; then
- dpkg-query -W -f='${Package},${Architecture},${Version}\n' > $SRCDIR/build/packages.csv
-fi
\ No newline at end of file
diff --git a/base/mkosi.skeleton/etc/systemd/system/persistent-mount.service b/base/mkosi.skeleton/etc/systemd/system/persistent-mount.service
new file mode 100644
index 0000000..1c630ea
--- /dev/null
+++ b/base/mkosi.skeleton/etc/systemd/system/persistent-mount.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Wait for Persistent Directory Mount
+DefaultDependencies=no
+Conflicts=shutdown.target
+Before=minimal.target
+After=local-fs-pre.target
+
+[Service]
+Type=oneshot
+ExecStart=/bin/bash -c 'until grep -q " /persistent " /proc/mounts; do sleep 1; done'
+RemainAfterExit=yes
+
+[Install]
+WantedBy=minimal.target
diff --git a/base/mkosi.skeleton/init b/base/mkosi.skeleton/init
index 8fe1709..b6f1256 100755
--- a/base/mkosi.skeleton/init
+++ b/base/mkosi.skeleton/init
@@ -8,5 +8,10 @@ mount -t devtmpfs none /dev
mount -t tmpfs none /run
mount -t configfs none /sys/kernel/config
-# Execute systemd
-exec /lib/systemd/systemd systemd.unit=minimal.target
+# Workaround to make pivot_root work
+# https://aconz2.github.io/2024/07/29/container-from-initramfs.html
+exec unshare --mount sh -c '
+ mkdir /@
+ mount --rbind / /@
+ cd /@ && mount --move . /
+ exec chroot . /lib/systemd/systemd systemd.unit=minimal.target'
diff --git a/base/mkosi.skeleton/usr/bin/azure-complete-provisioning b/base/mkosi.skeleton/usr/bin/azure-complete-provisioning
new file mode 100755
index 0000000..9bf5f4e
--- /dev/null
+++ b/base/mkosi.skeleton/usr/bin/azure-complete-provisioning
@@ -0,0 +1,73 @@
+#!/bin/sh
+# Report VM is ready to Azure API in the absence of the Azure VM Agent
+# Adapted from https://learn.microsoft.com/en-us/azure/virtual-machines/linux/no-agent#bash-script
+
+set -e
+
+attempts=1
+retrieved_goal_state=false
+until [ "$attempts" -gt 5 ]
+do
+ echo "obtaining goal state - attempt $attempts"
+ goalstate=$(curl --fail -v -X 'GET' -H "x-ms-agent-name: azure-vm-register" \
+ -H "Content-Type: text/xml;charset=utf-8" \
+ -H "x-ms-version: 2012-11-30" \
+ "http://168.63.129.16/machine/?comp=goalstate")
+ if [ $? -eq 0 ]
+ then
+ echo "successfully retrieved goal state"
+ retrieved_goal_state=true
+ break
+ fi
+ sleep 5
+ attempts=$((attempts+1))
+done
+
+if [ "$retrieved_goal_state" != "true" ]
+then
+ echo "failed to obtain goal state - cannot register this VM"
+ exit 1
+fi
+
+container_id=$(echo "$goalstate" | grep ContainerId | sed 's/\s*<\/*ContainerId>//g' | sed 's/\r$//')
+instance_id=$(echo "$goalstate" | grep InstanceId | sed 's/\s*<\/*InstanceId>//g' | sed 's/\r$//')
+
+ready_doc=$(cat << EOF
+
+
+ 1
+
+ $container_id
+
+
+ $instance_id
+
+ Ready
+
+
+
+
+
+EOF
+)
+
+attempts=1
+until [ "$attempts" -gt 5 ]
+do
+ echo "registering with Azure - attempt $attempts"
+ curl --fail -v -X 'POST' -H "x-ms-agent-name: azure-vm-register" \
+ -H "Content-Type: text/xml;charset=utf-8" \
+ -H "x-ms-version: 2012-11-30" \
+ -d "$ready_doc" \
+ "http://168.63.129.16/machine?comp=health"
+ if [ $? -eq 0 ]
+ then
+ echo "successfully register with Azure"
+ exit 0
+ fi
+ sleep 5 # sleep to prevent throttling from wire server
+ attempts=$((attempts+1))
+done
+
+echo "failed to register with Azure after $attempts attempts"
+exit 1
\ No newline at end of file
diff --git a/bob.conf b/bob.conf
new file mode 100644
index 0000000..34b6c94
--- /dev/null
+++ b/bob.conf
@@ -0,0 +1,9 @@
+[Include]
+Include=base/base.conf
+Include=bob/bob.conf
+
+[Distribution]
+Mirror=https://snapshot.debian.org/archive/debian/20250526T142542Z/
+
+[Build]
+ToolsTreeMirror=https://snapshot.debian.org/archive/debian/20250526T142542Z/
\ No newline at end of file
diff --git a/bob/bob.conf b/bob/bob.conf
new file mode 100644
index 0000000..7d6ff3e
--- /dev/null
+++ b/bob/bob.conf
@@ -0,0 +1,41 @@
+[Build]
+Environment=LIGHTHOUSE_BINARY
+WithNetwork=true
+
+[Content]
+ExtraTrees=bob/mkosi.extra
+PostInstallationScripts=bob/mkosi.postinst
+BuildScripts=bob/mkosi.build
+
+Packages=podman
+ runc
+ dropbear
+ socat
+ iptables
+ iproute2
+ conntrack
+ netfilter-persistent
+ openntpd
+ curl
+ jq
+ ncat
+ logrotate
+ sudo
+ uidmap
+ passt
+ fuse-overlayfs
+ cryptsetup
+ openssh-sftp-server
+ udev
+ libsnappy1v5
+
+BuildPackages=build-essential
+ git
+ gcc
+ zlib1g-dev
+ libzstd-dev
+ libleveldb-dev
+ libsnappy-dev
+ libpq-dev
+ libssl-dev
+ golang
diff --git a/bob/mkosi.build b/bob/mkosi.build
new file mode 100755
index 0000000..bd0e646
--- /dev/null
+++ b/bob/mkosi.build
@@ -0,0 +1,42 @@
+#!/bin/bash
+set -euxo pipefail
+
+source scripts/build_rust_package.sh
+source scripts/make_git_package.sh
+
+# Compile searchersh
+mkdir -p "$DESTDIR/usr/bin"
+mkosi-chroot gcc -o "$DESTDIR/usr/bin/searchersh" "$SRCDIR/bob/searchersh.c"
+chmod 755 "$DESTDIR/usr/bin/searchersh"
+
+# Compile lighthouse
+build_rust_package \
+ "lighthouse" \
+ "v7.0.1" \
+ "https://github.com/sigp/lighthouse.git" \
+ "$LIGHTHOUSE_BINARY" \
+ "modern" \
+ "-l z -l zstd -l snappy"
+
+# Build tdx-init
+make_git_package \
+ "tdx-init" \
+ "v0.1.1" \
+ "https://github.com/flashbots/tdx-init" \
+ 'go build -trimpath -ldflags "-s -w -buildid=" -o ./build/tdx-init' \
+ "build/tdx-init:/usr/bin/tdx-init"
+
+# Build ssh-pubkey-server
+make_git_package \
+ "ssh-pubkey-server" \
+ "second-key" \
+ "https://github.com/flashbots/ssh-pubkey-server" \
+ 'go build -trimpath -ldflags "-s -w -buildid= -X github.com/flashbots/go-template/common.Version=v1.0.0" -o ./build/ssh-pubkey-server cmd/httpserver/main.go' \
+ "build/ssh-pubkey-server:/usr/bin/ssh-pubkey-server"
+
+make_git_package \
+ "cvm-reverse-proxy" \
+ "v0.1.7" \
+ "https://github.com/flashbots/cvm-reverse-proxy" \
+ "make build-proxy-server" \
+ "build/proxy-server:/usr/bin/cvm-reverse-proxy"
diff --git a/bob/mkosi.extra/etc/containers/containers.conf b/bob/mkosi.extra/etc/containers/containers.conf
new file mode 100644
index 0000000..f4bafe9
--- /dev/null
+++ b/bob/mkosi.extra/etc/containers/containers.conf
@@ -0,0 +1,14 @@
+[engine]
+cgroup_manager = "cgroupfs"
+events_logger = "file"
+runtime = "runc"
+lock_type = "file"
+seccomp_profile = "/etc/containers/seccomp.json"
+
+[storage]
+driver = "vfs"
+runroot = "/run/containers/storage"
+graphroot = "/var/lib/containers/storage"
+
+[network]
+firewall_driver = "iptables"
diff --git a/bob/mkosi.extra/etc/containers/seccomp.json b/bob/mkosi.extra/etc/containers/seccomp.json
new file mode 100644
index 0000000..c4d9110
--- /dev/null
+++ b/bob/mkosi.extra/etc/containers/seccomp.json
@@ -0,0 +1,833 @@
+{
+ "defaultAction": "SCMP_ACT_ERRNO",
+ "defaultErrnoRet": 1,
+ "archMap": [
+ {
+ "architecture": "SCMP_ARCH_X86_64",
+ "subArchitectures": [
+ "SCMP_ARCH_X86",
+ "SCMP_ARCH_X32"
+ ]
+ },
+ {
+ "architecture": "SCMP_ARCH_AARCH64",
+ "subArchitectures": [
+ "SCMP_ARCH_ARM"
+ ]
+ },
+ {
+ "architecture": "SCMP_ARCH_MIPS64",
+ "subArchitectures": [
+ "SCMP_ARCH_MIPS",
+ "SCMP_ARCH_MIPS64N32"
+ ]
+ },
+ {
+ "architecture": "SCMP_ARCH_MIPS64N32",
+ "subArchitectures": [
+ "SCMP_ARCH_MIPS",
+ "SCMP_ARCH_MIPS64"
+ ]
+ },
+ {
+ "architecture": "SCMP_ARCH_MIPSEL64",
+ "subArchitectures": [
+ "SCMP_ARCH_MIPSEL",
+ "SCMP_ARCH_MIPSEL64N32"
+ ]
+ },
+ {
+ "architecture": "SCMP_ARCH_MIPSEL64N32",
+ "subArchitectures": [
+ "SCMP_ARCH_MIPSEL",
+ "SCMP_ARCH_MIPSEL64"
+ ]
+ },
+ {
+ "architecture": "SCMP_ARCH_S390X",
+ "subArchitectures": [
+ "SCMP_ARCH_S390"
+ ]
+ },
+ {
+ "architecture": "SCMP_ARCH_RISCV64",
+ "subArchitectures": null
+ }
+ ],
+ "syscalls": [
+ {
+ "names": [
+ "accept",
+ "accept4",
+ "access",
+ "adjtimex",
+ "alarm",
+ "bind",
+ "brk",
+ "cachestat",
+ "capget",
+ "capset",
+ "chdir",
+ "chmod",
+ "chown",
+ "chown32",
+ "clock_adjtime",
+ "clock_adjtime64",
+ "clock_getres",
+ "clock_getres_time64",
+ "clock_gettime",
+ "clock_gettime64",
+ "clock_nanosleep",
+ "clock_nanosleep_time64",
+ "close",
+ "close_range",
+ "connect",
+ "copy_file_range",
+ "creat",
+ "dup",
+ "dup2",
+ "dup3",
+ "epoll_create",
+ "epoll_create1",
+ "epoll_ctl",
+ "epoll_ctl_old",
+ "epoll_pwait",
+ "epoll_pwait2",
+ "epoll_wait",
+ "epoll_wait_old",
+ "eventfd",
+ "eventfd2",
+ "execve",
+ "execveat",
+ "exit",
+ "exit_group",
+ "faccessat",
+ "faccessat2",
+ "fadvise64",
+ "fadvise64_64",
+ "fallocate",
+ "fanotify_mark",
+ "fchdir",
+ "fchmod",
+ "fchmodat",
+ "fchmodat2",
+ "fchown",
+ "fchown32",
+ "fchownat",
+ "fcntl",
+ "fcntl64",
+ "fdatasync",
+ "fgetxattr",
+ "flistxattr",
+ "flock",
+ "fork",
+ "fremovexattr",
+ "fsetxattr",
+ "fstat",
+ "fstat64",
+ "fstatat64",
+ "fstatfs",
+ "fstatfs64",
+ "fsync",
+ "ftruncate",
+ "ftruncate64",
+ "futex",
+ "futex_requeue",
+ "futex_time64",
+ "futex_wait",
+ "futex_waitv",
+ "futex_wake",
+ "futimesat",
+ "getcpu",
+ "getcwd",
+ "getdents",
+ "getdents64",
+ "getegid",
+ "getegid32",
+ "geteuid",
+ "geteuid32",
+ "getgid",
+ "getgid32",
+ "getgroups",
+ "getgroups32",
+ "getitimer",
+ "getpeername",
+ "getpgid",
+ "getpgrp",
+ "getpid",
+ "getppid",
+ "getpriority",
+ "getrandom",
+ "getresgid",
+ "getresgid32",
+ "getresuid",
+ "getresuid32",
+ "getrlimit",
+ "get_robust_list",
+ "getrusage",
+ "getsid",
+ "getsockname",
+ "getsockopt",
+ "get_thread_area",
+ "gettid",
+ "gettimeofday",
+ "getuid",
+ "getuid32",
+ "getxattr",
+ "inotify_add_watch",
+ "inotify_init",
+ "inotify_init1",
+ "inotify_rm_watch",
+ "io_cancel",
+ "ioctl",
+ "io_destroy",
+ "io_getevents",
+ "io_pgetevents",
+ "io_pgetevents_time64",
+ "ioprio_get",
+ "ioprio_set",
+ "io_setup",
+ "io_submit",
+ "ipc",
+ "kill",
+ "landlock_add_rule",
+ "landlock_create_ruleset",
+ "landlock_restrict_self",
+ "lchown",
+ "lchown32",
+ "lgetxattr",
+ "link",
+ "linkat",
+ "listen",
+ "listxattr",
+ "llistxattr",
+ "_llseek",
+ "lremovexattr",
+ "lseek",
+ "lsetxattr",
+ "lstat",
+ "lstat64",
+ "madvise",
+ "map_shadow_stack",
+ "membarrier",
+ "memfd_create",
+ "memfd_secret",
+ "mincore",
+ "mkdir",
+ "mkdirat",
+ "mknod",
+ "mknodat",
+ "mlock",
+ "mlock2",
+ "mlockall",
+ "mmap",
+ "mmap2",
+ "mprotect",
+ "mq_getsetattr",
+ "mq_notify",
+ "mq_open",
+ "mq_timedreceive",
+ "mq_timedreceive_time64",
+ "mq_timedsend",
+ "mq_timedsend_time64",
+ "mq_unlink",
+ "mremap",
+ "msgctl",
+ "msgget",
+ "msgrcv",
+ "msgsnd",
+ "msync",
+ "munlock",
+ "munlockall",
+ "munmap",
+ "name_to_handle_at",
+ "nanosleep",
+ "newfstatat",
+ "_newselect",
+ "open",
+ "openat",
+ "openat2",
+ "pause",
+ "pidfd_open",
+ "pidfd_send_signal",
+ "pipe",
+ "pipe2",
+ "pkey_alloc",
+ "pkey_free",
+ "pkey_mprotect",
+ "poll",
+ "ppoll",
+ "ppoll_time64",
+ "prctl",
+ "pread64",
+ "preadv",
+ "preadv2",
+ "prlimit64",
+ "process_mrelease",
+ "pselect6",
+ "pselect6_time64",
+ "pwrite64",
+ "pwritev",
+ "pwritev2",
+ "read",
+ "readahead",
+ "readlink",
+ "readlinkat",
+ "readv",
+ "recv",
+ "recvfrom",
+ "recvmmsg",
+ "recvmmsg_time64",
+ "recvmsg",
+ "remap_file_pages",
+ "removexattr",
+ "rename",
+ "renameat",
+ "renameat2",
+ "restart_syscall",
+ "rmdir",
+ "rseq",
+ "rt_sigaction",
+ "rt_sigpending",
+ "rt_sigprocmask",
+ "rt_sigqueueinfo",
+ "rt_sigreturn",
+ "rt_sigsuspend",
+ "rt_sigtimedwait",
+ "rt_sigtimedwait_time64",
+ "rt_tgsigqueueinfo",
+ "sched_getaffinity",
+ "sched_getattr",
+ "sched_getparam",
+ "sched_get_priority_max",
+ "sched_get_priority_min",
+ "sched_getscheduler",
+ "sched_rr_get_interval",
+ "sched_rr_get_interval_time64",
+ "sched_setaffinity",
+ "sched_setattr",
+ "sched_setparam",
+ "sched_setscheduler",
+ "sched_yield",
+ "seccomp",
+ "select",
+ "semctl",
+ "semget",
+ "semop",
+ "semtimedop",
+ "semtimedop_time64",
+ "send",
+ "sendfile",
+ "sendfile64",
+ "sendmmsg",
+ "sendmsg",
+ "sendto",
+ "setfsgid",
+ "setfsgid32",
+ "setfsuid",
+ "setfsuid32",
+ "setgid",
+ "setgid32",
+ "setgroups",
+ "setgroups32",
+ "setitimer",
+ "setpgid",
+ "setpriority",
+ "setregid",
+ "setregid32",
+ "setresgid",
+ "setresgid32",
+ "setresuid",
+ "setresuid32",
+ "setreuid",
+ "setreuid32",
+ "setrlimit",
+ "set_robust_list",
+ "setsid",
+ "setsockopt",
+ "set_thread_area",
+ "set_tid_address",
+ "setuid",
+ "setuid32",
+ "setxattr",
+ "shmat",
+ "shmctl",
+ "shmdt",
+ "shmget",
+ "shutdown",
+ "sigaltstack",
+ "signalfd",
+ "signalfd4",
+ "sigprocmask",
+ "sigreturn",
+ "socketcall",
+ "socketpair",
+ "splice",
+ "stat",
+ "stat64",
+ "statfs",
+ "statfs64",
+ "statx",
+ "symlink",
+ "symlinkat",
+ "sync",
+ "sync_file_range",
+ "syncfs",
+ "sysinfo",
+ "tee",
+ "tgkill",
+ "time",
+ "timer_create",
+ "timer_delete",
+ "timer_getoverrun",
+ "timer_gettime",
+ "timer_gettime64",
+ "timer_settime",
+ "timer_settime64",
+ "timerfd_create",
+ "timerfd_gettime",
+ "timerfd_gettime64",
+ "timerfd_settime",
+ "timerfd_settime64",
+ "times",
+ "tkill",
+ "truncate",
+ "truncate64",
+ "ugetrlimit",
+ "umask",
+ "uname",
+ "unlink",
+ "unlinkat",
+ "utime",
+ "utimensat",
+ "utimensat_time64",
+ "utimes",
+ "vfork",
+ "vmsplice",
+ "wait4",
+ "waitid",
+ "waitpid",
+ "write",
+ "writev"
+ ],
+ "action": "SCMP_ACT_ALLOW"
+ },
+ {
+ "names": [
+ "process_vm_readv",
+ "process_vm_writev",
+ "ptrace"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "minKernel": "4.8"
+ }
+ },
+ {
+ "names": [
+ "socket"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "args": [
+ {
+ "index": 0,
+ "value": 40,
+ "op": "SCMP_CMP_NE"
+ }
+ ]
+ },
+ {
+ "names": [
+ "personality"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "args": [
+ {
+ "index": 0,
+ "value": 0,
+ "op": "SCMP_CMP_EQ"
+ }
+ ]
+ },
+ {
+ "names": [
+ "personality"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "args": [
+ {
+ "index": 0,
+ "value": 8,
+ "op": "SCMP_CMP_EQ"
+ }
+ ]
+ },
+ {
+ "names": [
+ "personality"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "args": [
+ {
+ "index": 0,
+ "value": 131072,
+ "op": "SCMP_CMP_EQ"
+ }
+ ]
+ },
+ {
+ "names": [
+ "personality"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "args": [
+ {
+ "index": 0,
+ "value": 131080,
+ "op": "SCMP_CMP_EQ"
+ }
+ ]
+ },
+ {
+ "names": [
+ "personality"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "args": [
+ {
+ "index": 0,
+ "value": 4294967295,
+ "op": "SCMP_CMP_EQ"
+ }
+ ]
+ },
+ {
+ "names": [
+ "sync_file_range2",
+ "swapcontext"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "arches": [
+ "ppc64le"
+ ]
+ }
+ },
+ {
+ "names": [
+ "arm_fadvise64_64",
+ "arm_sync_file_range",
+ "sync_file_range2",
+ "breakpoint",
+ "cacheflush",
+ "set_tls"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "arches": [
+ "arm",
+ "arm64"
+ ]
+ }
+ },
+ {
+ "names": [
+ "arch_prctl"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "arches": [
+ "amd64",
+ "x32"
+ ]
+ }
+ },
+ {
+ "names": [
+ "modify_ldt"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "arches": [
+ "amd64",
+ "x32",
+ "x86"
+ ]
+ }
+ },
+ {
+ "names": [
+ "s390_pci_mmio_read",
+ "s390_pci_mmio_write",
+ "s390_runtime_instr"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "arches": [
+ "s390",
+ "s390x"
+ ]
+ }
+ },
+ {
+ "names": [
+ "riscv_flush_icache"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "arches": [
+ "riscv64"
+ ]
+ }
+ },
+ {
+ "names": [
+ "open_by_handle_at"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_DAC_READ_SEARCH"
+ ]
+ }
+ },
+ {
+ "names": [
+ "bpf",
+ "clone",
+ "clone3",
+ "fanotify_init",
+ "fsconfig",
+ "fsmount",
+ "fsopen",
+ "fspick",
+ "lookup_dcookie",
+ "mount",
+ "mount_setattr",
+ "move_mount",
+ "open_tree",
+ "perf_event_open",
+ "quotactl",
+ "quotactl_fd",
+ "setdomainname",
+ "sethostname",
+ "setns",
+ "syslog",
+ "umount",
+ "umount2",
+ "unshare"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_ADMIN"
+ ]
+ }
+ },
+ {
+ "names": [
+ "clone"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "args": [
+ {
+ "index": 0,
+ "value": 2114060288,
+ "op": "SCMP_CMP_MASKED_EQ"
+ }
+ ],
+ "excludes": {
+ "caps": [
+ "CAP_SYS_ADMIN"
+ ],
+ "arches": [
+ "s390",
+ "s390x"
+ ]
+ }
+ },
+ {
+ "names": [
+ "clone"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "args": [
+ {
+ "index": 1,
+ "value": 2114060288,
+ "op": "SCMP_CMP_MASKED_EQ"
+ }
+ ],
+ "comment": "s390 parameter ordering for clone is different",
+ "includes": {
+ "arches": [
+ "s390",
+ "s390x"
+ ]
+ },
+ "excludes": {
+ "caps": [
+ "CAP_SYS_ADMIN"
+ ]
+ }
+ },
+ {
+ "names": [
+ "clone3"
+ ],
+ "action": "SCMP_ACT_ERRNO",
+ "errnoRet": 38,
+ "excludes": {
+ "caps": [
+ "CAP_SYS_ADMIN"
+ ]
+ }
+ },
+ {
+ "names": [
+ "reboot"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_BOOT"
+ ]
+ }
+ },
+ {
+ "names": [
+ "chroot"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_CHROOT"
+ ]
+ }
+ },
+ {
+ "names": [
+ "delete_module",
+ "init_module",
+ "finit_module"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_MODULE"
+ ]
+ }
+ },
+ {
+ "names": [
+ "acct"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_PACCT"
+ ]
+ }
+ },
+ {
+ "names": [
+ "kcmp",
+ "pidfd_getfd",
+ "process_madvise",
+ "process_vm_readv",
+ "process_vm_writev",
+ "ptrace"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_PTRACE"
+ ]
+ }
+ },
+ {
+ "names": [
+ "iopl",
+ "ioperm"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_RAWIO"
+ ]
+ }
+ },
+ {
+ "names": [
+ "settimeofday",
+ "stime",
+ "clock_settime",
+ "clock_settime64"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_TIME"
+ ]
+ }
+ },
+ {
+ "names": [
+ "vhangup"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_TTY_CONFIG"
+ ]
+ }
+ },
+ {
+ "names": [
+ "get_mempolicy",
+ "mbind",
+ "set_mempolicy",
+ "set_mempolicy_home_node"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYS_NICE"
+ ]
+ }
+ },
+ {
+ "names": [
+ "syslog"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_SYSLOG"
+ ]
+ }
+ },
+ {
+ "names": [
+ "bpf"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_BPF"
+ ]
+ }
+ },
+ {
+ "names": [
+ "perf_event_open"
+ ],
+ "action": "SCMP_ACT_ALLOW",
+ "includes": {
+ "caps": [
+ "CAP_PERFMON"
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/bob/mkosi.extra/etc/default/dropbear b/bob/mkosi.extra/etc/default/dropbear
new file mode 100644
index 0000000..e350593
--- /dev/null
+++ b/bob/mkosi.extra/etc/default/dropbear
@@ -0,0 +1,14 @@
+# -s: Disallow password logins by default
+# -w: Disallow root logins
+# -g: Disable password logins for root
+# -m: Don't display the message of the day on login
+# -j: Disable local port forwarding
+# -k: Disable remote port forwarding
+DROPBEAR_EXTRA_ARGS="-s -w -g -m -j -k"
+DROPBEAR_RECEIVE_WINDOW=6291456
+
+# Bind only to ipv4
+DROPBEAR_PORT=0.0.0.0:22
+
+# SFTP configuration
+DROPBEAR_SUBSYSTEM="sftp /usr/lib/openssh/sftp-server"
diff --git a/bob/mkosi.extra/etc/logrotate.conf b/bob/mkosi.extra/etc/logrotate.conf
new file mode 100644
index 0000000..6fdc6bb
--- /dev/null
+++ b/bob/mkosi.extra/etc/logrotate.conf
@@ -0,0 +1,12 @@
+# Rotate logs in /delayed_logs and /searcher_logs daily,
+# keeping 5 old copies. Use copytruncate so tail
+# doesn't lose its file handles.
+
+/persistent/searcher_logs/*.log {
+ rotate 5
+ copytruncate
+ missingok
+ notifempty
+ compress
+ maxsize 2G
+}
\ No newline at end of file
diff --git a/bob/mkosi.extra/etc/sudoers.d/99-searcher b/bob/mkosi.extra/etc/sudoers.d/99-searcher
new file mode 100644
index 0000000..a50d484
--- /dev/null
+++ b/bob/mkosi.extra/etc/sudoers.d/99-searcher
@@ -0,0 +1 @@
+searcher ALL=(root) NOPASSWD: /usr/bin/toggle, /usr/bin/tdx-init set-passphrase
diff --git a/bob/mkosi.extra/etc/sysctl.d/sysctl.conf b/bob/mkosi.extra/etc/sysctl.d/sysctl.conf
new file mode 100644
index 0000000..bc8c4b3
--- /dev/null
+++ b/bob/mkosi.extra/etc/sysctl.d/sysctl.conf
@@ -0,0 +1 @@
+vm.max_map_count=2097152
diff --git a/bob/mkosi.extra/etc/systemd/system/cvm-reverse-proxy.service b/bob/mkosi.extra/etc/systemd/system/cvm-reverse-proxy.service
new file mode 100644
index 0000000..0209b0d
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/cvm-reverse-proxy.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=SSH Public Key Server
+After=ssh-pubkey-server.service
+Requires=ssh-pubkey-server.service
+
+[Service]
+Type=simple
+ExecStart=cvm-reverse-proxy --listen-addr=0.0.0.0:8745 \
+ --target-addr=http://localhost:5001 \
+ --server-attestation-type=auto
+Restart=always
+RestartSec=5
+
+[Install]
+WantedBy=minimal.target
diff --git a/bob/mkosi.extra/etc/systemd/system/dropbear.service.d/dropbear-prereq.conf b/bob/mkosi.extra/etc/systemd/system/dropbear.service.d/dropbear-prereq.conf
new file mode 100644
index 0000000..deb3611
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/dropbear.service.d/dropbear-prereq.conf
@@ -0,0 +1,10 @@
+[Unit]
+After=wait-for-key.service searcher-firewall.service
+Requires=wait-for-key.service searcher-firewall.service
+
+[Service]
+ExecStartPre=/usr/bin/chown -R searcher:searcher /home/searcher
+ExecStartPre=/bin/sh -c 'test -f /etc/dropbear/dropbear_ed25519_host_key || /usr/bin/dropbearkey -t ed25519 -f /etc/dropbear/dropbear_ed25519_host_key'
+
+[Install]
+WantedBy=minimal.target
diff --git a/bob/mkosi.extra/etc/systemd/system/lighthouse.service b/bob/mkosi.extra/etc/systemd/system/lighthouse.service
new file mode 100644
index 0000000..2a0fa31
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/lighthouse.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=Lighthouse Consensus Client
+After=network.target network-setup.service persistent-mount.service
+Requires=network-setup.service persistent-mount.service
+
+[Service]
+Type=exec
+User=lighthouse
+Group=eth
+ExecStartPre=+/usr/bin/lighthouse-init
+ExecStart=/usr/bin/lighthouse bn \
+ --network mainnet \
+ --execution-endpoint http://localhost:8551 \
+ --execution-jwt /tmp/jwt.hex \
+ --checkpoint-sync-url https://mainnet.checkpoint.sigp.io \
+ --disable-deposit-contract-sync \
+ --datadir "/persistent/lighthouse" \
+ --disable-optimistic-finalized-sync \
+ --disable-quic
+Restart=on-failure
+RestartSec=10
+StandardOutput=journal
+StandardError=journal
+
+[Install]
+WantedBy=minimal.target
\ No newline at end of file
diff --git a/bob/mkosi.extra/etc/systemd/system/searcher-container.service b/bob/mkosi.extra/etc/systemd/system/searcher-container.service
new file mode 100644
index 0000000..eccf0d0
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/searcher-container.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Searcher SSH Container
+After=dropbear.service searcher-firewall.service persistent-mount.service
+Requires=dropbear.service searcher-firewall.service persistent-mount.service
+
+[Service]
+Type=oneshot
+ExecStartPre=/usr/bin/chown -R searcher:searcher /etc/searcher/ssh_hostkey
+ExecStart=/usr/bin/init-container.sh
+RemainAfterExit=yes
+StandardOutput=journal
+StandardError=journal
+
+[Install]
+WantedBy=minimal.target
diff --git a/bob/mkosi.extra/etc/systemd/system/searcher-firewall.service b/bob/mkosi.extra/etc/systemd/system/searcher-firewall.service
new file mode 100644
index 0000000..3812c1e
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/searcher-firewall.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Searcher Network and Firewall Rules
+After=network.target network-setup.service
+Requires=network-setup.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/init-firewall.sh
+RemainAfterExit=yes
+StandardOutput=journal
+StandardError=journal
+
+[Install]
+WantedBy=minimal.target
diff --git a/bob/mkosi.extra/etc/systemd/system/searcher-log-reader.service b/bob/mkosi.extra/etc/systemd/system/searcher-log-reader.service
new file mode 100644
index 0000000..57eccfb
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/searcher-log-reader.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Searcher Log Reader
+After=persistent-mount.service
+Requires=persistent-mount.service
+
+[Service]
+Type=simple
+ExecStartPre=/bin/mkdir -p /run/delayed_logs
+ExecStartPre=-/bin/rm -f /run/delayed_logs/delay.sock
+ExecStart=/bin/sh -c "ncat -U --listen --keep-open --delay 120s /run/delayed_logs/delay.sock > /persistent/delayed_logs/output.log"
+Restart=always
+
+[Install]
+WantedBy=minimal.target
\ No newline at end of file
diff --git a/bob/mkosi.extra/etc/systemd/system/searcher-log-writer.service b/bob/mkosi.extra/etc/systemd/system/searcher-log-writer.service
new file mode 100644
index 0000000..531dd5c
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/searcher-log-writer.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Delayed Searcher Log Writer
+After=searcher-log-reader.service
+Requires=searcher-log-reader.service
+
+[Service]
+Type=simple
+ExecStartPre=/bin/sudo -u searcher touch /persistent/searcher_logs/bob.log
+ExecStart=/bin/sh -c "tail -F -n0 /persistent/searcher_logs/bob.log | ncat -U /run/delayed_logs/delay.sock"
+Restart=always
+
+[Install]
+WantedBy=minimal.target
\ No newline at end of file
diff --git a/bob/mkosi.extra/etc/systemd/system/ssh-pubkey-server.service b/bob/mkosi.extra/etc/systemd/system/ssh-pubkey-server.service
new file mode 100644
index 0000000..0c4b156
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/ssh-pubkey-server.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=SSH Public Key Server
+After=searcher-container.service
+Requires=searcher-container.service
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/ssh-pubkey-server --listen-addr=127.0.0.1:5001 --container-ssh-pubkey-file /etc/searcher/ssh_hostkey/host_key.pub --host-ssh-pubkey-file /etc/dropbear/dropbear_ed25519_host_key.pub
+Restart=always
+RestartSec=5
+
+[Install]
+WantedBy=minimal.target
diff --git a/bob/mkosi.extra/etc/systemd/system/wait-for-key.service b/bob/mkosi.extra/etc/systemd/system/wait-for-key.service
new file mode 100644
index 0000000..5a4c1ea
--- /dev/null
+++ b/bob/mkosi.extra/etc/systemd/system/wait-for-key.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=SSH Public Key Server
+After=network.target network-setup.service wait-for-key.service
+Requires=network-setup.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/tdx-init wait-for-key
+RemainAfterExit=yes
+Restart=on-failure
+RestartSec=5
+
+[Install]
+WantedBy=minimal.target
diff --git a/bob/mkosi.extra/usr/bin/init-container.sh b/bob/mkosi.extra/usr/bin/init-container.sh
new file mode 100755
index 0000000..f8fcfec
--- /dev/null
+++ b/bob/mkosi.extra/usr/bin/init-container.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+set -eu -o pipefail
+
+NAME=searcher-container
+
+# PORT FORWARDS
+SEARCHER_SSH_PORT=10022
+ENGINE_API_PORT=8551
+EL_P2P_PORT=30303
+SEARCHER_INPUT_CHANNEL=27017
+
+echo "Starting $NAME..."
+su -s /bin/sh searcher -c "cd ~ && podman run -d \
+ --name $NAME --replace \
+ -p ${SEARCHER_SSH_PORT}:22 \
+ -p ${ENGINE_API_PORT}:${ENGINE_API_PORT} \
+ -p ${EL_P2P_PORT}:${EL_P2P_PORT} \
+ -p ${EL_P2P_PORT}:${EL_P2P_PORT}/udp \
+ -p ${SEARCHER_INPUT_CHANNEL}:${SEARCHER_INPUT_CHANNEL}/udp \
+ -v /persistent/searcher:/persistent:rw \
+ -v /etc/searcher/ssh_hostkey:/etc/searcher/ssh_hostkey:rw \
+ -v /persistent/searcher_logs:/var/log/searcher:rw \
+ -v /tmp/jwt.hex:/secrets/jwt.hex:ro \
+ docker.io/library/ubuntu:24.04 \
+ /bin/sh -c ' \
+ DEBIAN_FRONTEND=noninteractive apt-get update && \
+ DEBIAN_FRONTEND=noninteractive apt-get install -y openssh-server && \
+ mkdir -p /run/sshd && \
+ mkdir -p /root/.ssh && \
+ echo \"ssh-ed25519 $(cat /etc/searcher_key)\" > /root/.ssh/authorized_keys && \
+ chmod 700 /root/.ssh && \
+ chmod 600 /root/.ssh/authorized_keys && \
+ cp /etc/ssh/ssh_host_ed25519_key.pub /etc/searcher/ssh_hostkey/host_key.pub && \
+ /usr/sbin/sshd -D -e'"
+
+# Attempt a quick check that the container is running
+for i in 1 2 3 4 5; do
+ status=$(su -s /bin/sh - searcher -c "podman inspect --format '{{.State.Status}}' $NAME 2>/dev/null || true")
+ if [ "$status" = "running" ]; then
+ break
+ fi
+ echo "Waiting for $NAME container to reach 'running' state..."
+ sleep 1
+done
+
+if [ "$status" != "running" ]; then
+ echo "ERROR: $NAME container is not running (status: $status)"
+ exit 1
+fi
+
+# Retrieve the PID
+pid=$(su -s /bin/sh - searcher -c "podman inspect --format '{{.State.Pid}}' $NAME")
+if [ -z "$pid" ] || [ "$pid" = "0" ]; then
+ echo "ERROR: Could not retrieve PID for container $NAME."
+ exit 1
+fi
+
+echo "Applying iptables rules in $NAME (PID: $pid) network namespace..."
+
+# Enter network namespace and apply DROP rules on port 9000 TCP/UDP
+nsenter --target "$pid" --net iptables -A OUTPUT -p tcp --dport 9000 -j DROP
+nsenter --target "$pid" --net iptables -A OUTPUT -p udp --dport 9000 -j DROP
+
+# Enter network namespace and apply DROP rule on port 123 UDP
+nsenter --target "$pid" --net iptables -A OUTPUT -p udp --dport 123 -j DROP
+
+# Drop outbound traffic from SEARCHER_INPUT_CHANNEL
+nsenter --target "$pid" --net iptables -A OUTPUT -p udp --sport $SEARCHER_INPUT_CHANNEL -j DROP
+nsenter --target "$pid" --net iptables -A OUTPUT -p tcp --sport $SEARCHER_INPUT_CHANNEL -j DROP
diff --git a/bob/mkosi.extra/usr/bin/init-firewall.sh b/bob/mkosi.extra/usr/bin/init-firewall.sh
new file mode 100755
index 0000000..f6c2bb9
--- /dev/null
+++ b/bob/mkosi.extra/usr/bin/init-firewall.sh
@@ -0,0 +1,222 @@
+#!/bin/sh
+set -eu -o pipefail
+
+echo "Initializing firewall with separate inbound/outbound chains..."
+
+TITAN_BUILDER_IP="52.207.17.217"
+
+###############################################################################
+# Ports
+###############################################################################
+SSH_CONTROL_PORT=22 # Inbound: SSH control plane (always on)
+SSH_DATA_PORT=10022 # Inbound: SSH data plane (maintenance mode only)
+SSH_REGISTER_PORT=8080 # Inbound: SSH registration
+
+CL_P2P_PORT=9000 # TCP/UDP inbound/outbound: Consensus client P2P (always on)
+EL_P2P_PORT=30303 # TCP/UDP outbound: Execution client P2P (maintenance mode only)
+
+DNS_PORT=53 # Outbound: DNS (maintenance mode only)
+HTTP_PORT=80 # Outbound: HTTP (maintenance mode only)
+HTTPS_PORT=443 # Outbound: HTTPS (maintenance mode only)
+
+SEARCHER_INPUT_CHANNEL=27017 # Inbound: Input Only Channel (always on)
+
+TITAN_STATE_DIFF_PORT_WSS=42203 # Outbound: Titan builder state diff new:42203 (production only)
+TITAN_BUNDLE_PORT_HTTPS=1338 # Outbound: Titan builder bundle submission new:1338 (always on)
+
+CVM_REVERSE_PROXY_PORT=8745 # Inbound: CVM reverse proxy (always on)
+NTP_PORT=123 # Outbound: NTP (always on)
+
+###############################################################################
+# Custom Chains
+###############################################################################
+CHAIN_ALWAYS_ON_IN="ALWAYS_ON_IN"
+CHAIN_ALWAYS_ON_OUT="ALWAYS_ON_OUT"
+
+CHAIN_MODE_SELECTOR_IN="MODE_SELECTOR_IN"
+CHAIN_MODE_SELECTOR_OUT="MODE_SELECTOR_OUT"
+
+CHAIN_MAINTENANCE_IN="MAINTENANCE_IN"
+CHAIN_MAINTENANCE_OUT="MAINTENANCE_OUT"
+
+CHAIN_PRODUCTION_IN="PRODUCTION_IN"
+CHAIN_PRODUCTION_OUT="PRODUCTION_OUT"
+
+
+###########################################################################
+# (1) Set default policies to DROP
+###########################################################################
+iptables -P INPUT DROP
+iptables -P FORWARD DROP
+iptables -P OUTPUT DROP
+
+###########################################################################
+# (2) Flush any existing rules/chains
+###########################################################################
+iptables -F
+iptables -X
+
+###########################################################################
+# (3) Create custom chains
+###########################################################################
+for CHAIN in \
+ $CHAIN_ALWAYS_ON_IN $CHAIN_ALWAYS_ON_OUT \
+ $CHAIN_MODE_SELECTOR_IN $CHAIN_MODE_SELECTOR_OUT \
+ $CHAIN_MAINTENANCE_IN $CHAIN_MAINTENANCE_OUT \
+ $CHAIN_PRODUCTION_IN $CHAIN_PRODUCTION_OUT
+do
+ iptables -N $CHAIN
+done
+
+###########################################################################
+# (4) Allow Established/Related connections (Inbound & Outbound)
+# OUTPUT (always): SSH (22), CL P2P (9000), CVM reverse-proxy (8745)
+# OUTPUT (maintenance): SSH (10022)
+###########################################################################
+iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
+iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
+
+###########################################################################
+# (5) Main Routing:
+# INPUT -> ALWAYS_ON_IN -> MODE_SELECTOR_IN
+# OUTPUT -> ALWAYS_ON_OUT -> MODE_SELECTOR_OUT
+###########################################################################
+iptables -A INPUT -j $CHAIN_ALWAYS_ON_IN
+iptables -A INPUT -j $CHAIN_MODE_SELECTOR_IN
+
+iptables -A OUTPUT -j $CHAIN_ALWAYS_ON_OUT
+iptables -A OUTPUT -j $CHAIN_MODE_SELECTOR_OUT
+
+###########################################################################
+# (6) ALWAYS_ON_IN: Inbound rules that never turn off
+###########################################################################
+# SSH control port (22)
+iptables -A $CHAIN_ALWAYS_ON_IN -p tcp --dport $SSH_CONTROL_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# Searcher input channel (UDP on 27017)
+iptables -A $CHAIN_ALWAYS_ON_IN -p udp --dport $SEARCHER_INPUT_CHANNEL \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# Consensus (CL) P2P inbound on port 9000 (TCP + UDP)
+iptables -A $CHAIN_ALWAYS_ON_IN -p tcp --dport $CL_P2P_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+iptables -A $CHAIN_ALWAYS_ON_IN -p udp --dport $CL_P2P_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# CVM reverse-proxy inbound on port 8745 (TCP)
+# Serves server attestation
+# Also forwards request to ssh pubkey server on localhost:5001,
+# which serves searcher-container openssh server pubkey
+iptables -A $CHAIN_ALWAYS_ON_IN -p tcp --dport $CVM_REVERSE_PROXY_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# Return from ALWAYS_ON_IN back to caller (INPUT chain -> MODE_SELECTOR_IN)
+iptables -A $CHAIN_ALWAYS_ON_IN -j RETURN
+
+###########################################################################
+# (7) ALWAYS_ON_OUT: Outbound rules that never turn off
+###########################################################################
+# CL P2P outbound on port 9000 (TCP + UDP)
+# Note: This is the lighthouse CL client run on the host, not the searcher's CL
+iptables -A $CHAIN_ALWAYS_ON_OUT -p tcp --dport $CL_P2P_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+iptables -A $CHAIN_ALWAYS_ON_OUT -p udp --dport $CL_P2P_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# NTP outbound on port 123 (UDP)
+iptables -A $CHAIN_ALWAYS_ON_OUT -p udp --dport $NTP_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# Titan builder bundle endpoints (always on)
+# Security note: This is a side channel.
+# While the operator will not be able to see the content of the packets,
+# they can observe the presence or absence of packets.
+iptables -A $CHAIN_ALWAYS_ON_OUT -p tcp -d $TITAN_BUILDER_IP --dport $TITAN_BUNDLE_PORT_HTTPS \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# Return from ALWAYS_ON_OUT back to caller (OUTPUT chain -> MODE_SELECTOR_OUT)
+iptables -A $CHAIN_ALWAYS_ON_OUT -j RETURN
+
+###########################################################################
+# (8) MAINTENANCE_IN: Inbound rules for Maintenance Mode
+###########################################################################
+# SSH data plane on port 10022
+iptables -A $CHAIN_MAINTENANCE_IN -p tcp --dport $SSH_DATA_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# SSH Registry port (not used in production mode)
+iptables -A $CHAIN_MAINTENANCE_IN -p tcp --dport $SSH_REGISTER_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# EL P2P inbound on port 30303 (TCP + UDP)
+iptables -A $CHAIN_MAINTENANCE_IN -p tcp --dport $EL_P2P_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+iptables -A $CHAIN_MAINTENANCE_IN -p udp --dport $EL_P2P_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# Return from MAINTENANCE_IN back to caller (INPUT chain -> END)
+iptables -A $CHAIN_MAINTENANCE_IN -j RETURN
+
+###########################################################################
+# (9) MAINTENANCE_OUT: Outbound rules for Maintenance Mode
+###########################################################################
+# DNS (UDP/TCP 53)
+# Note: Searchers will only have DNS in maintenance mode!
+iptables -A $CHAIN_MAINTENANCE_OUT -p udp --dport $DNS_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+iptables -A $CHAIN_MAINTENANCE_OUT -p tcp --dport $DNS_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# HTTP / HTTPS
+iptables -A $CHAIN_MAINTENANCE_OUT -p tcp --dport $HTTP_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+iptables -A $CHAIN_MAINTENANCE_OUT -p tcp --dport $HTTPS_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# EL P2P (30303) outbound only in Maintenance
+iptables -A $CHAIN_MAINTENANCE_OUT -p tcp --dport $EL_P2P_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+iptables -A $CHAIN_MAINTENANCE_OUT -p udp --dport $EL_P2P_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# SSH Registry port (not used in production mode)
+iptables -A $CHAIN_MAINTENANCE_OUT -p tcp --dport $SSH_REGISTER_PORT \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# Return from MAINTENANCE_OUT back to caller (OUTPUT chain -> END)
+iptables -A $CHAIN_MAINTENANCE_OUT -j RETURN
+
+###########################################################################
+# (10) PRODUCTION_IN: Inbound rules for Production Mode
+###########################################################################
+# Return from PRODUCTION_IN back to caller (INPUT chain -> END)
+iptables -A $CHAIN_PRODUCTION_IN -j RETURN
+
+###########################################################################
+# (11) PRODUCTION_OUT: Outbound rules for Production Mode
+# IP whitelisted for builder IPs
+###########################################################################
+# Titan state diff WSS
+iptables -A $CHAIN_PRODUCTION_OUT -p tcp -d $TITAN_BUILDER_IP --dport $TITAN_STATE_DIFF_PORT_WSS \
+ -m conntrack --ctstate NEW -j ACCEPT
+
+# Return from PRODUCTION_OUT back to caller (OUTPUT chain -> END)
+iptables -A $CHAIN_PRODUCTION_OUT -j RETURN
+
+###########################################################################
+# (12) Start in Maintenance Mode
+###########################################################################
+iptables -A $CHAIN_MODE_SELECTOR_IN -j $CHAIN_MAINTENANCE_IN
+iptables -A $CHAIN_MODE_SELECTOR_OUT -j $CHAIN_MAINTENANCE_OUT
+
+# Set initial state
+echo "maintenance" > /etc/searcher-network.state
+
+###########################################################################
+# (13) Allow loopback traffic
+###########################################################################
+iptables -A INPUT -i lo -j ACCEPT
+iptables -A OUTPUT -o lo -j ACCEPT
+
+echo "Firewall initialized in Maintenance Mode."
diff --git a/bob/mkosi.extra/usr/bin/toggle b/bob/mkosi.extra/usr/bin/toggle
new file mode 100755
index 0000000..257d850
--- /dev/null
+++ b/bob/mkosi.extra/usr/bin/toggle
@@ -0,0 +1,303 @@
+#!/bin/bash
+set -eu -o pipefail
+
+# -e: script exits on any command error.
+# -u: exits if any undefined variable is used.
+# -o pipefail: catches errors in any part of a pipeline.
+
+#
+# Mode Switching Script
+#
+# Switch Paths:
+# 1) "production" -> "stopped"
+# 2) "stopped" -> "maintenance" (two minute delay)
+# 3) "maintenance" -> "production"
+#
+# Terminating NEW connections: Uses MODE_SELECTOR IN/OUT chain jumps to MAINTENANCE_IN/OUT or PRODUCTION_IN/OUT rule sets
+# Terminating ESTABLISHED/RELATED connections: Uses conntrack to kill all current connections by port
+
+# We must be root to change iptable rules
+# Check if we're root, if not, fail
+if [ "$(id -u)" != "0" ]; then
+ echo "Error: This script must be run as root"
+ exit 1
+fi
+
+###############################################################################
+# Configuration
+###############################################################################
+
+# Delay implementationfiles
+LOCK_FILE="/etc/searcher-network.lock"
+STATE_FILE="/etc/searcher-network.state"
+TIMESTAMP_FILE="/etc/searcher-network-last-stop.timestamp"
+
+# Tools
+IPTABLES="/usr/sbin/iptables"
+CONNTRACK="/usr/sbin/conntrack"
+
+# Chains
+CHAIN_MODE_SELECTOR_IN="MODE_SELECTOR_IN"
+CHAIN_MODE_SELECTOR_OUT="MODE_SELECTOR_OUT"
+CHAIN_MAINTENANCE_IN="MAINTENANCE_IN"
+CHAIN_MAINTENANCE_OUT="MAINTENANCE_OUT"
+CHAIN_PRODUCTION_IN="PRODUCTION_IN"
+CHAIN_PRODUCTION_OUT="PRODUCTION_OUT"
+
+# Maintenance ports
+SSH_DATA_PORT=10022
+DNS_PORT=53
+HTTP_PORT=80
+HTTPS_PORT=443
+EL_P2P_PORT=30303
+
+# Production ports
+FB_STATE_DIFF_PORT=8547
+TITAN_STATE_DIFF_PORT_WSS=42203
+
+###############################################################################
+# Delay between stopping and starting maintenance
+###############################################################################
+with_lock() {
+ (
+ flock -x 200
+ "$@"
+ ) 200>"$LOCK_FILE"
+}
+
+get_state() {
+ if [ ! -f "$STATE_FILE" ]; then
+ echo "maintenance" # Default state
+ else
+ cat "$STATE_FILE"
+ fi
+}
+
+set_state() {
+ echo "$1" > "$STATE_FILE"
+}
+
+# SECURITY: this should only be called from disconnect_from_production()
+write_timestamp() {
+ date +%s > "$TIMESTAMP_FILE"
+}
+
+check_delay() {
+ if [ ! -f "$TIMESTAMP_FILE" ]; then
+ echo "Error: No previous stop_production timestamp found"
+ return 1
+ fi
+
+ last_stop=$(cat "$TIMESTAMP_FILE")
+ # SECURITY: time can be manipulated by the host
+ current_time=$(date +%s)
+ delay_seconds=120 # 2 minutes
+
+ if [ $((current_time - last_stop)) -lt $delay_seconds ]; then
+ remaining=$((delay_seconds - (current_time - last_stop)))
+ echo "Error: Must wait $remaining more seconds before starting maintenance"
+ return 1
+ fi
+ return 0
+}
+
+###############################################################################
+# Kill established connections via conntrack
+###############################################################################
+kill_established_connections() {
+ local old_mode="$1"
+ if [ "$old_mode" = "production" ]; then
+ echo "Killing leftover production flows (port $TITAN_STATE_DIFF_PORT_WSS)..."
+ $CONNTRACK -D -p tcp --dport $TITAN_STATE_DIFF_PORT_WSS 2>/dev/null
+
+ elif [ "$old_mode" = "maintenance" ]; then
+ echo "Killing leftover maintenance flows:"
+ echo " - SSH data port $SSH_DATA_PORT"
+ echo " - DNS $DNS_PORT, HTTP $HTTP_PORT, HTTPS $HTTPS_PORT, EL P2P $EL_P2P_PORT"
+ # SSH data plane
+ $CONNTRACK -D -p tcp --dport $SSH_DATA_PORT 2>/dev/null
+ # DNS
+ $CONNTRACK -D -p tcp --dport $DNS_PORT 2>/dev/null
+ $CONNTRACK -D -p udp --dport $DNS_PORT 2>/dev/null
+ # HTTP/HTTPS
+ $CONNTRACK -D -p tcp --dport $HTTP_PORT 2>/dev/null
+ $CONNTRACK -D -p tcp --dport $HTTPS_PORT 2>/dev/null
+ # EL P2P
+ $CONNTRACK -D -p tcp --dport $EL_P2P_PORT 2>/dev/null
+ $CONNTRACK -D -p udp --dport $EL_P2P_PORT 2>/dev/null
+ fi
+ # if old_mode="stopped", nothing to kill
+}
+###############################################################################
+# Toggle the iptables chain jumps
+###############################################################################
+configure_mode_rules() {
+ local new_mode="$1"
+ local old_mode="$2"
+
+ # 1) Flush the mode selector so we remove references to the old sub-chain
+ $IPTABLES -F $CHAIN_MODE_SELECTOR_IN
+ $IPTABLES -F $CHAIN_MODE_SELECTOR_OUT
+
+ # 2) Kill all established flows from old mode
+ kill_established_connections "$old_mode"
+
+ # 3) Depending on new_mode, jump to the matching sub-chains
+ case "$new_mode" in
+ maintenance)
+ $IPTABLES -A $CHAIN_MODE_SELECTOR_IN -j $CHAIN_MAINTENANCE_IN
+ $IPTABLES -A $CHAIN_MODE_SELECTOR_OUT -j $CHAIN_MAINTENANCE_OUT
+ ;;
+ production)
+ $IPTABLES -A $CHAIN_MODE_SELECTOR_IN -j $CHAIN_PRODUCTION_IN
+ $IPTABLES -A $CHAIN_MODE_SELECTOR_OUT -j $CHAIN_PRODUCTION_OUT
+ ;;
+ stopped)
+ # No jump => default DROP.
+ ;;
+ *)
+ echo "Unknown mode $new_mode in configure_mode_rules"
+ return 1
+ ;;
+ esac
+ return 0
+}
+
+###############################################################################
+# Container Namespace Rule Verification
+# Check that the searcher-container-netns iptables rules blocking port 9000 are active
+###############################################################################
+check_searcher_namespace_rules() {
+ local cont_name="searcher-container"
+ local user="searcher"
+ local daemon="/usr/bin/podman"
+
+ # 1) Check container status
+ local status
+ status=$(su -s /bin/sh - $user -c "$daemon inspect --format '{{.State.Status}}' $cont_name 2>/dev/null" || true)
+ if [ "$status" != "running" ]; then
+ echo "ERROR: '$cont_name' container is not running; cannot verify rules."
+ return 1
+ fi
+
+ # 2) Retrieve the container PID
+ local pid
+ pid=$(su -s /bin/sh - $user -c "$daemon inspect --format '{{.State.Pid}}' $cont_name 2>/dev/null" || true)
+ if [ -z "$pid" ] || [ "$pid" = "0" ]; then
+ echo "ERROR: Could not retrieve PID for '$cont_name'."
+ return 1
+ fi
+
+ # 3) Check if the DROP rule on port 9000, 27107, and 123 is present in OUTPUT chain
+ # -C (check) returns 0 if a matching rule is found, 1 otherwise
+ if nsenter --target "$pid" --net $IPTABLES -C OUTPUT -p tcp --dport 9000 -j DROP 2>/dev/null \
+ && nsenter --target "$pid" --net $IPTABLES -C OUTPUT -p udp --dport 9000 -j DROP 2>/dev/null \
+ && nsenter --target "$pid" --net $IPTABLES -C OUTPUT -p tcp --sport 27017 -j DROP 2>/dev/null \
+ && nsenter --target "$pid" --net $IPTABLES -C OUTPUT -p udp --sport 27017 -j DROP 2>/dev/null \
+ && nsenter --target "$pid" --net $IPTABLES -C OUTPUT -p udp --dport 123 -j DROP 2>/dev/null; then
+ echo "OK: searcher-container firewall rules (DROP tcp/udp port 9000, tcp/udp port 27017, udp port 123) are ACTIVE."
+ return 0
+ else
+ echo "WARNING: One or more searcher-container firewall rules (DROP ports 9000/27017/123) are NOT found."
+ return 1
+ fi
+}
+
+###############################################################################
+# Mode Switching Functions
+###############################################################################
+move_to_production() {
+ if [ "$(get_state)" != "maintenance" ]; then
+ echo "Error: Can only move to production from maintenance state"
+ return 1
+ fi
+
+ # Check the searcher-container-netns iptables rules are active first:
+ if ! check_searcher_namespace_rules; then
+ echo "Error: Required searcher-container-netns iptables rules not active!"
+ return 1
+ fi
+
+ echo "Moving to production mode..."
+ if configure_mode_rules "production" "maintenance"; then
+ set_state "production"
+ echo "Successfully switched to production mode"
+ return 0
+ else
+ echo "Failed to switch to production mode"
+ return 1
+ fi
+}
+
+disconnect_from_production() {
+ write_timestamp
+ if [ "$(get_state)" != "production" ]; then
+ echo "Error: Can only disconnect from production state"
+ return 1
+ fi
+ echo "Disconnecting from production mode..."
+ if configure_mode_rules "stopped" "production"; then
+ set_state "stopped"
+ echo "Successfully disconnected from production mode"
+ return 0
+ else
+ echo "Failed to disconnect from production mode"
+ return 1
+ fi
+}
+
+connect_to_maintenance() {
+ if [ "$(get_state)" != "stopped" ]; then
+ echo "Error: Can only connect to maintenance from stopped state"
+ return 1
+ fi
+ if ! check_delay; then
+ return 1
+ fi
+ echo "Connecting to maintenance mode..."
+ if configure_mode_rules "maintenance" "stopped"; then
+ set_state "maintenance"
+ rm -f "$TIMESTAMP_FILE" # Clear timestamp after successful use
+ echo "Successfully connected to maintenance mode"
+ return 0
+ else
+ echo "Failed to connect to maintenance mode"
+ return 1
+ fi
+}
+
+toggle() {
+ current_state=$(get_state)
+ case "$current_state" in
+ "production")
+ echo "Switching from production to stopped..."
+ disconnect_from_production
+ result=$?
+ ;;
+ "stopped")
+ echo "Switching from stopped to maintenance..."
+ connect_to_maintenance
+ result=$?
+ ;;
+ "maintenance")
+ echo "Switching from maintenance to production..."
+ move_to_production
+ result=$?
+ ;;
+ *)
+ echo "Error: Unknown state: $current_state"
+ return 1
+ ;;
+ esac
+ if [ $result -eq 0 ]; then
+ echo "Successfully switched state"
+ return 0
+ else
+ echo "Failed to switch state"
+ return 1
+ fi
+}
+
+# Main execution
+with_lock toggle
+exit $?
diff --git a/bob/mkosi.postinst b/bob/mkosi.postinst
new file mode 100755
index 0000000..83a3447
--- /dev/null
+++ b/bob/mkosi.postinst
@@ -0,0 +1,57 @@
+#!/bin/bash
+set -euxo pipefail
+
+# Create users and groups
+# NOTE: Due to a limitation in mkosi, all folders are owned by root by default
+# https://github.com/systemd/mkosi/issues/3065
+mkosi-chroot useradd -m -d /home/searcher -s /usr/bin/searchersh -u 1000 searcher
+mkosi-chroot groupadd -r eth
+mkosi-chroot useradd -r -s /bin/false -G eth lighthouse
+
+
+# Set up sudo permissions for searcher
+chmod 440 "$BUILDROOT/etc/sudoers.d/99-searcher"
+
+# Make sure searchersh is in the list of valid shells
+echo "/usr/bin/searchersh" >> "$BUILDROOT/etc/shells"
+
+# Install lighthouse
+install -m 755 services/bin/lighthouse-init "$BUILDROOT/usr/bin/"
+
+mkdir -p "$BUILDROOT/etc/searcher/ssh_hostkey"
+
+# Remove autogenerated ssh keys
+rm -r "$BUILDROOT/etc/dropbear"
+mkdir "$BUILDROOT/etc/dropbear"
+
+# Enable services
+mkdir "$BUILDROOT/etc/systemd/system/minimal.target.wants"
+for service in \
+ network-setup.service \
+ azure-complete-provisioning.service \
+ openntpd.service \
+ logrotate.service \
+ searcher-log-reader.service \
+ searcher-log-writer.service \
+ wait-for-key.service \
+ searcher-firewall.service \
+ dropbear.service \
+ lighthouse.service \
+ searcher-container.service \
+ ssh-pubkey-server.service \
+ cvm-reverse-proxy.service
+do
+ mkosi-chroot systemctl enable "$service"
+ ln -sf "/etc/systemd/system/$service" "$BUILDROOT/etc/systemd/system/minimal.target.wants/"
+done
+
+# Don't reserve port 22
+mkosi-chroot systemctl disable ssh.service ssh.socket
+mkosi-chroot systemctl mask ssh.service ssh.socket
+
+# Lock the root account
+mkosi-chroot passwd -l root
+
+# Remove execute permissions from su for non-root users
+chmod 700 "$BUILDROOT/bin/su"
+mkosi-chroot chown root:root /bin/su
diff --git a/bob/readme.md b/bob/readme.md
new file mode 100644
index 0000000..8b21796
--- /dev/null
+++ b/bob/readme.md
@@ -0,0 +1,56 @@
+BOB
+===
+
+This module implements three key features for bottom of block backrunning:
+
+1. **Network namespaces and firewall rules** that enforce a searcher cannot SSH into the container while state diffs are being streamed in, and the only way information can leave is through the block builder’s endpoints.
+2. A **log delay** **script that enforces a two-minute (~10 block) delay until the searcher can view their bot’s logs.
+3. **Mode switching** which allows a searcher to toggle between production and maintenance modes, where the SSH connection is cut and restored respectively.
+
+Together, they provide the “no-frontrunning” guarantee to order flow providers while balancing searcher bot visibility and maintenance.
+
+Docs: https://flashbots.notion.site/Bob-V2-Image-Guide-1506b4a0d87680b2979de36288b48d9a?pvs=4
+
+
+
+Additional functionality
+------------------------
+
+This universal, Mkosi-based version implements additional capabilities which allow searchers to persist data across restarts and version upgrades without sacrificing data privacy and integrity.
+When the image boots up, it will open an HTTP server at port 8080 and wait for a ed25519 public key to be submitted. For example, run the qemu image then POST the key to the forwarded port like so:
+
+```
+ubuntu@ns5018742:~/Angela/bobgela/keys$ curl -X POST -d "AAAAC3NzaC1lZDI1NTE5AAAAIMPdKdQZip5rYQAhuKTbhI09HM9aFSU/erbUWXb4i4nR" http://localhost:8080
+```
+
+This step is only necessary if the persistent disk has not been initialized.
+
+Then, using the dropbear port, you can initialize or decrypt an existing disk by running the "initialize" command (rather than toggle, status, etc). This will prompt you for a password via stdin. This step is necessary on each boot. When you initialize as disk, it will store the previously supplied public key in plaintext inside of the LUKS header so it can be retrieved automatically on subsequent boots.
+
+Service Order
+-------------
+
+1. Initialize network (**name:** `network-setup.service`)
+2. Get searcher key from LUKS partition or wait for key on port 8080 (**name:** `wait-for-key.service`) (**after:** `network-setup.service`)
+3. Setup firewall (**name:** `searcher-firewall.service`) (**after:** `network-setup.service`)
+4. Start dropbear server for `initialize`, `toggle`, etc. (**name:** `dropbear.service`) (**after:** `wait-for-key.service`, `searcher-firewall.service`)
+5. Open a log socket and forward text from it to the delayed log file after 120s (**name:** searcher-log-reader.service) (**after:** `/persistent` is mounted)
+6. Write new text in `bob.log` to the log socket (**name:** searcher-log-writer.service) (**after:** searcher-log-reader.service)
+7. Lighthouse (**name:** `lighthouse.service`) (**after:** `/persistent` is mounted)
+8. Start the podman container (**name:** `searcher-container.service`) (**after:** `dropbear.service`, `lighthouse.service`, `searcher-firewall.service`, `/persistent` is mounted)
+9. SSH pubkey server (**name:** `ssh-pubkey-server.service`) (**after:** `searcher-container.service`)
+10. CVM reverse proxy for SSH pubkey server (**name:** `cvm-reverse-proxy.service`) (**after:** `ssh-pubkey-server.service`)
+
+Testing
+-------
+
+```shell
+ssh-keygen -t ed25519
+curl -X POST -d "$(cut -d" " -f2 /root/.ssh/id_ed25519.pub)" http://localhost:8080
+sleep 1
+# start here if recovering existing persistent disk (assumes searcher key is in /root/.ssh)
+ssh -4 -i /root/.ssh/id_ed25519 searcher@127.0.0.1 initialize
+journalctl -fu searcher-container
+ssh -4 -i /root/.ssh/id_ed25519 -p 10022 root@127.0.0.1
+ssh -4 -i /root/.ssh/id_ed25519 searcher@127.0.0.1 toggle
+```
\ No newline at end of file
diff --git a/bob/searchersh.c b/bob/searchersh.c
new file mode 100644
index 0000000..bce66b2
--- /dev/null
+++ b/bob/searchersh.c
@@ -0,0 +1,183 @@
+#include // For fprintf, perror
+#include // For exit, malloc/free, strdup, atoi
+#include // For strcmp, strtok
+#include // For execl
+#include // For isdigit
+#include // For stat
+
+#define MAX_LINES 10000000
+
+// Check if initialization is complete (persistent is mounted)
+int is_initialized() {
+ struct stat st_mount, st_parent;
+
+ if (stat("/persistent", &st_mount) != 0) {
+ return 0;
+ }
+
+ if (stat("/persistent/..", &st_parent) != 0) {
+ return 0;
+ }
+
+ // Different device IDs mean it's a mount point
+ return (st_mount.st_dev != st_parent.st_dev);
+}
+
+// argc is the number of command-line arguments
+// argv is an array of C-strings (character pointers)
+int main(int argc, char *argv[]) {
+
+ // We expect exactly 3 arguments:
+ // Example: ssh -i ~/.ssh/yocto-searcher -p 8084 searcher@localhost hello 5
+ // argv[0] = 'searchersh'
+ // argv[1] = '-c'
+ // argv[2] = 'hello 5'
+
+ if (argc != 3) {
+ fprintf(stderr, "Invalid number of arguments\n");
+ return 1; // return error code 1
+ }
+
+ // Verify argv[0] is "searchersh"
+ if (strcmp(argv[0], "searchersh") != 0) {
+ fprintf(stderr, "Error: This program must be invoked as 'searchersh'\n");
+ return 1;
+ }
+
+ // Verify argv[1] is "-c"
+ if (strcmp(argv[1], "-c") != 0) {
+ fprintf(stderr, "Error: Second argument must be '-c'\n");
+ return 1;
+ }
+
+ // Make a copy of argv[2], because strtok will modify the string
+ // strdup() allocates memory and copies the entire string.
+ // We must free() this memory later.
+ char *arg_copy = strdup(argv[2]);
+ if (!arg_copy) {
+ perror("strdup failed");
+ return 1; // return error code 1
+ }
+
+ // Use strtok() to split the string in arg_copy by spaces (" ")
+ // strtok modifies the string by inserting '\0' to separate tokens.
+ // 'command' will point to the first token, if it exists.
+ char *command = strtok(arg_copy, " ");
+ if (command == NULL) {
+ // If there's no token at all (e.g., empty or whitespace-only string),
+ // we print an error and quit.
+ fprintf(stderr, "No command provided. Valid commands are: toggle, status, logs, initialize\n");
+ free(arg_copy); // free the memory
+ return 1; // return error code 1
+ }
+
+ // If the first token (command) is not NULL, we try to get the next token
+ // 'arg' is needed when the command is "logs "
+ // e.g., if argv[2] = "logs 3", then:
+ // command = "logs"
+ // arg = "3"
+ char *arg = strtok(NULL, " ");
+
+ // If command == "initialize", run the tdx-init program with set-passphrase command
+ if (strcmp(command, "initialize") == 0) {
+ execl("/usr/bin/sudo", "sudo", "/usr/bin/tdx-init", "set-passphrase", NULL);
+
+ perror("execl failed (initialize)");
+ free(arg_copy);
+ return 1;
+ }
+
+ // Check if system is initialized before allowing other commands
+ if (!is_initialized()) {
+ fprintf(stderr, "System not initialized. Please run 'initialize' command first.\n");
+ free(arg_copy);
+ return 1;
+ }
+
+ // Compare the first token to see which command we want.
+ // 1) "toggle"
+ // 2) "status"
+ // 3) "logs"
+ // Anything else -> invalid.
+
+ // If command == "toggle", call /usr/bin/toggle via sudo
+ if (strcmp(command, "toggle") == 0) {
+ // execl() replaces the current process with the new program
+ // Arguments to execl:
+ // 1) path to executable: "/usr/bin/sudo"
+ // 2) argv[0] for new program: "sudo"
+ // 3) "-S" accept password from stdin
+ // 4) "/usr/bin/toggle" (the program we actually want to run via sudo)
+ // 5) NULL terminator for argument list
+ // execl("/usr/bin/sudo", "sudo", "-S", "/usr/bin/toggle", NULL);
+ execl("/usr/bin/sudo", "sudo", "/usr/bin/toggle", NULL);
+
+ // If execl fails, we reach here. perror prints error details.
+ perror("execl failed (toggle)");
+
+ // We must free the copied string before exiting
+ free(arg_copy);
+ return 1;
+ }
+
+ // If command == "status", print the contents of /etc/searcher-network.state
+ else if (strcmp(command, "status") == 0) {
+ // runs: cat /etc/searcher-network.state
+ execl("/bin/cat", "cat", "/etc/searcher-network.state", NULL);
+
+ perror("execl failed (status)");
+ free(arg_copy);
+ return 1;
+ }
+
+ // If command == "tail-the-logs", print the contents of /persistent/delayed_logs/output.log
+ else if (strcmp(command, "tail-the-logs") == 0) {
+ execl("/usr/bin/tail", "tail", "-f", "/persistent/delayed_logs/output.log", NULL);
+ perror("execl failed (tail-the-logs)");
+ free(arg_copy);
+ return 1;
+ }
+
+ // If command == "logs", we expect a second token representing number of lines
+ else if (strcmp(command, "logs") == 0) {
+ // If no second token, user didn't specify how many lines
+ if (arg == NULL) {
+ fprintf(stderr, "Usage: logs \n");
+ free(arg_copy);
+ return 1; // return error code 1
+ }
+
+ // 1) Check that 'arg' is strictly numeric
+ for (int i = 0; arg[i] != '\0'; i++) {
+ if (!isdigit((unsigned char)arg[i])) {
+ fprintf(stderr, "Invalid line count (non-digit characters detected): %s\n", arg);
+ free(arg_copy);
+ return 1;
+ }
+ }
+
+ // 2) Convert to int
+ int lines = atoi(arg);
+
+ // 3) Check the range
+ if (lines < 1 || lines > MAX_LINES) {
+ fprintf(stderr, "Number of lines must be between 1 and %d\n", MAX_LINES);
+ free(arg_copy);
+ return 1;
+ }
+
+ // Call tail with the specified number of lines, e.g.:
+ // tail -n /persistent/delayed_logs/output.log
+ // If arg = "3", that's tail -n 3 /persistent/delayed_logs/output.log
+ execl("/usr/bin/tail", "tail", "-n", arg, "/persistent/delayed_logs/output.log", (char *)NULL);
+
+ perror("execl failed (logs)");
+ free(arg_copy);
+ return 1; // return error code 1
+ }
+
+ // If we reach here, the command didn't match any of the valid commands
+ fprintf(stderr, "Invalid command. Valid commands are: toggle, status, logs, initialize\n");
+ free(arg_copy); // Clean up allocated memory
+ return 1; // Return error code 1
+}
diff --git a/buildernet.conf b/buildernet.conf
index 9df6566..5aba459 100644
--- a/buildernet.conf
+++ b/buildernet.conf
@@ -1,4 +1,3 @@
-[Config]
+[Include]
Include=base/base.conf
Include=buildernet/buildernet.conf
-Include=devtools/devtools.conf
\ No newline at end of file
diff --git a/buildernet/buildernet.conf b/buildernet/buildernet.conf
index 3fb9498..ac7bfca 100644
--- a/buildernet/buildernet.conf
+++ b/buildernet/buildernet.conf
@@ -1,20 +1,20 @@
+[Build]
+Environment=LIGHTHOUSE_BINARY RETH_BINARY RBUILDER_BINARY
+WithNetwork=true
+
[Content]
SkeletonTrees=buildernet/mkosi.skeleton
PostInstallationScripts=buildernet/mkosi.postinst
PostInstallationScripts=buildernet/render-config.sh
BuildScripts=buildernet/mkosi.build
-WithNetwork=true
-Environment=LIGHTHOUSE_BINARY RETH_BINARY RBUILDER_BINARY
+
Packages=prometheus
prometheus-node-exporter
prometheus-process-exporter
- fluent-bit
rclone
openntpd
+ libsnappy1v5
netcat-openbsd
- procps
- ca-certificates
- openssl
bubblewrap
BuildPackages=libleveldb-dev
libsnappy-dev
@@ -22,4 +22,4 @@ BuildPackages=libleveldb-dev
libzstd-dev
libpq-dev
libssl-dev
- protobuf-compiler
\ No newline at end of file
+ protobuf-compiler
diff --git a/buildernet/mkosi.build b/buildernet/mkosi.build
index 3e37760..fbddd27 100755
--- a/buildernet/mkosi.build
+++ b/buildernet/mkosi.build
@@ -5,11 +5,11 @@ source scripts/build_rust_package.sh
build_rust_package \
"lighthouse" \
- "v5.3.0" \
+ "v7.0.1" \
"https://github.com/sigp/lighthouse.git" \
"$LIGHTHOUSE_BINARY" \
"modern" \
- "-l z -l zstd"
+ "-l z -l zstd -l snappy"
build_rust_package \
"reth" \
diff --git a/buildernet/mkosi.postinst b/buildernet/mkosi.postinst
index a49fc78..3804cd9 100755
--- a/buildernet/mkosi.postinst
+++ b/buildernet/mkosi.postinst
@@ -18,7 +18,7 @@ mkdir -p "$SERVICE_DIR"
# Copy systemd service files for buildernet
for service in \
- lighthouse # reth reth-sync \
+ persistence-setup # reth reth-sync \
# rbuilder-bidding rbuilder
do
install -m 644 "services/systemd/$service.service" "$SERVICE_DIR/"
diff --git a/services/systemd/lighthouse.service b/buildernet/mkosi.skeleton/etc/systemd/system/lighthouse.service
similarity index 81%
rename from services/systemd/lighthouse.service
rename to buildernet/mkosi.skeleton/etc/systemd/system/lighthouse.service
index 97b3d76..dd64add 100644
--- a/services/systemd/lighthouse.service
+++ b/buildernet/mkosi.skeleton/etc/systemd/system/lighthouse.service
@@ -1,14 +1,13 @@
[Unit]
Description=Lighthouse Consensus Client
-After=network-setup.service persistence-setup.service
-Wants=network-setup.service persistence-setup.service
-ConditionPathExists=/persistent
+After=network.target network-setup.service persistent-mount.service
+Requires=network-setup.service persistent-mount.service
[Service]
Type=exec
User=lighthouse
Group=eth
-ExecStartPre=/usr/bin/lighthouse-init
+ExecStartPre=+/usr/bin/lighthouse-init
ExecStart=/usr/bin/lighthouse bn \
--eth1 \
--checkpoint-sync-url https://mainnet.checkpoint.sigp.io \
diff --git a/devtools/devtools.conf b/devtools/devtools.conf
deleted file mode 100644
index 1c6931d..0000000
--- a/devtools/devtools.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-[Content]
-SkeletonTrees=devtools/systemd:/etc/systemd/system
-Packages=socat
- iputils-ping
- curl
- apt
\ No newline at end of file
diff --git a/flake.lock b/flake.lock
index 0782e05..7dcb42b 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
- "lastModified": 1736012469,
- "narHash": "sha256-/qlNWm/IEVVH7GfgAIyP6EsVZI6zjAx1cV5zNyrs+rI=",
+ "lastModified": 1746904237,
+ "narHash": "sha256-3e+AVBczosP5dCLQmMoMEogM57gmZ2qrVSrmq9aResQ=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "8f3e1f807051e32d8c95cd12b9b421623850a34d",
+ "rev": "d89fc19e405cb2d55ce7cc114356846a0ee5e956",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index 5967055..c1bd83b 100644
--- a/flake.nix
+++ b/flake.nix
@@ -6,7 +6,6 @@
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
kernel = import ./kernel.nix { inherit pkgs; };
- mkosi = pkgs.mkosi;
reprepro = pkgs.stdenv.mkDerivation rec {
name = "reprepro-${version}";
version = "4.16.0";
@@ -25,6 +24,13 @@
wrapProgram "$out/bin/reprepro" --prefix PATH : "${pkgs.gnupg}/bin"
'';
};
+ mkosi = pkgs.mkosi.override {
+ extraDeps = with pkgs; [
+ apt dpkg gnupg debootstrap
+ squashfsTools dosfstools e2fsprogs mtools mustache-go
+ cryptsetup util-linux zstd
+ ] ++ [ reprepro ];
+ };
in {
packages.${system} = {
kernel = kernel;
@@ -32,11 +38,7 @@
};
devShells.${system}.default = pkgs.mkShell {
- nativeBuildInputs = with pkgs; [
- apt dpkg gnupg debootstrap
- squashfsTools dosfstools e2fsprogs mtools mustache-go
- cryptsetup util-linux zstd qemu
- ] ++ [ reprepro mkosi ];
+ nativeBuildInputs = [ pkgs.qemu mkosi ];
KERNEL_IMAGE = "${kernel}/bzImage";
KERNEL_VERSION = kernel.version;
diff --git a/kernel-yocto.config b/kernel-yocto.config
index 67deb8c..455b7e4 100644
--- a/kernel-yocto.config
+++ b/kernel-yocto.config
@@ -993,7 +993,7 @@ CONFIG_INET_UDP_DIAG=y
CONFIG_TCP_CONG_CUBIC=y
CONFIG_DEFAULT_TCP_CONG="cubic"
# CONFIG_TCP_MD5SIG is not set
-CONFIG_IPV6=y
+CONFIG_IPV6=n
# CONFIG_IPV6_ROUTER_PREF is not set
# CONFIG_IPV6_OPTIMISTIC_DAD is not set
# CONFIG_INET6_AH is not set
@@ -1024,23 +1024,24 @@ CONFIG_BRIDGE_NETFILTER=y
# CONFIG_NETFILTER_EGRESS is not set
CONFIG_NETFILTER_FAMILY_BRIDGE=y
CONFIG_NETFILTER_BPF_LINK=y
+CONFIG_NETFILTER_NETLINK=y
# CONFIG_NETFILTER_NETLINK_ACCT is not set
# CONFIG_NETFILTER_NETLINK_QUEUE is not set
-# CONFIG_NETFILTER_NETLINK_LOG is not set
+CONFIG_NETFILTER_NETLINK_LOG=y
# CONFIG_NETFILTER_NETLINK_OSF is not set
CONFIG_NF_CONNTRACK=y
# CONFIG_NF_LOG_SYSLOG is not set
-# CONFIG_NF_CONNTRACK_MARK is not set
+CONFIG_NF_CONNTRACK_MARK=y
# CONFIG_NF_CONNTRACK_ZONES is not set
# CONFIG_NF_CONNTRACK_PROCFS is not set
-# CONFIG_NF_CONNTRACK_EVENTS is not set
+CONFIG_NF_CONNTRACK_EVENTS=y
# CONFIG_NF_CONNTRACK_TIMEOUT is not set
# CONFIG_NF_CONNTRACK_TIMESTAMP is not set
# CONFIG_NF_CONNTRACK_LABELS is not set
CONFIG_NF_CONNTRACK_OVS=y
# CONFIG_NF_CT_PROTO_DCCP is not set
-# CONFIG_NF_CT_PROTO_SCTP is not set
-# CONFIG_NF_CT_PROTO_UDPLITE is not set
+CONFIG_NF_CT_PROTO_SCTP=y
+CONFIG_NF_CT_PROTO_UDPLITE=y
# CONFIG_NF_CONNTRACK_AMANDA is not set
# CONFIG_NF_CONNTRACK_FTP is not set
# CONFIG_NF_CONNTRACK_H323 is not set
@@ -1051,13 +1052,31 @@ CONFIG_NF_CONNTRACK_OVS=y
# CONFIG_NF_CONNTRACK_SANE is not set
# CONFIG_NF_CONNTRACK_SIP is not set
# CONFIG_NF_CONNTRACK_TFTP is not set
-# CONFIG_NF_CT_NETLINK is not set
+CONFIG_NF_CT_NETLINK=y
CONFIG_NF_NAT=y
CONFIG_NF_NAT_MASQUERADE=y
CONFIG_NF_NAT_OVS=y
-# CONFIG_NF_TABLES is not set
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_NF_TABLES=y
+CONFIG_NF_TABLES_INET=y
+CONFIG_NF_TABLES_IPV4=y
+CONFIG_NF_TABLES_BRIDGE=y
+CONFIG_NF_TABLES_ARP=y
+CONFIG_NF_TABLES_NETDEV=y
CONFIG_NETFILTER_XTABLES=y
-# CONFIG_NETFILTER_XTABLES_COMPAT is not set
+CONFIG_NETFILTER_XTABLES_COMPAT=y
+
+CONFIG_NFT_CT=y
+CONFIG_NFT_COUNTER=y
+CONFIG_NFT_LOG=y
+CONFIG_NFT_LIMIT=y
+CONFIG_NFT_MASQ=y
+CONFIG_NFT_REJECT=y
+CONFIG_NFT_REJECT_INET=y
+CONFIG_NFT_COMPAT=y
+CONFIG_NFT_NAT=y
+CONFIG_NFT_REDIR=y
+CONFIG_NFT_OBJREF=y
#
# Xtables combined modules
@@ -1073,7 +1092,7 @@ CONFIG_NETFILTER_XT_MARK=y
# CONFIG_NETFILTER_XT_TARGET_HMARK is not set
# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set
# CONFIG_NETFILTER_XT_TARGET_LED is not set
-# CONFIG_NETFILTER_XT_TARGET_LOG is not set
+CONFIG_NETFILTER_XT_TARGET_LOG=y
# CONFIG_NETFILTER_XT_TARGET_MARK is not set
CONFIG_NETFILTER_XT_NAT=y
# CONFIG_NETFILTER_XT_TARGET_NETMAP is not set
@@ -1114,7 +1133,7 @@ CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set
# CONFIG_NETFILTER_XT_MATCH_MAC is not set
# CONFIG_NETFILTER_XT_MATCH_MARK is not set
-# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set
# CONFIG_NETFILTER_XT_MATCH_OSF is not set
# CONFIG_NETFILTER_XT_MATCH_OWNER is not set
@@ -1126,7 +1145,7 @@ CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
# CONFIG_NETFILTER_XT_MATCH_RECENT is not set
# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
# CONFIG_NETFILTER_XT_MATCH_SOCKET is not set
-# CONFIG_NETFILTER_XT_MATCH_STATE is not set
+CONFIG_NETFILTER_XT_MATCH_STATE=y
# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
# CONFIG_NETFILTER_XT_MATCH_STRING is not set
# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
@@ -1152,14 +1171,14 @@ CONFIG_IP_NF_IPTABLES=y
# CONFIG_IP_NF_MATCH_ECN is not set
# CONFIG_IP_NF_MATCH_TTL is not set
CONFIG_IP_NF_FILTER=y
-# CONFIG_IP_NF_TARGET_REJECT is not set
+CONFIG_IP_NF_TARGET_REJECT=y
# CONFIG_IP_NF_TARGET_SYNPROXY is not set
CONFIG_IP_NF_NAT=y
CONFIG_IP_NF_TARGET_MASQUERADE=y
-# CONFIG_IP_NF_TARGET_NETMAP is not set
-# CONFIG_IP_NF_TARGET_REDIRECT is not set
-# CONFIG_IP_NF_MANGLE is not set
-# CONFIG_IP_NF_RAW is not set
+CONFIG_IP_NF_TARGET_NETMAP=y
+CONFIG_IP_NF_TARGET_REDIRECT=y
+CONFIG_IP_NF_MANGLE=y
+CONFIG_IP_NF_RAW=y
# CONFIG_IP_NF_ARPTABLES is not set
# end of IP: Netfilter Configuration
@@ -1199,7 +1218,7 @@ CONFIG_LLC=y
CONFIG_6LOWPAN=m
# CONFIG_6LOWPAN_NHC is not set
# CONFIG_IEEE802154 is not set
-# CONFIG_NET_SCHED is not set
+CONFIG_NET_SCHED=y
# CONFIG_DCB is not set
CONFIG_DNS_RESOLVER=y
# CONFIG_BATMAN_ADV is not set
diff --git a/mkosi-docs.md b/mkosi-docs.md
new file mode 100644
index 0000000..5a86122
--- /dev/null
+++ b/mkosi-docs.md
@@ -0,0 +1,3241 @@
+% mkosi(1)
+%
+%
+
+# NAME
+
+mkosi — Build Bespoke OS Images
+
+# SYNOPSIS
+
+`mkosi [options…] init`
+
+`mkosi [options…] summary`
+
+`mkosi [options…] cat-config`
+
+`mkosi [options…] build [-- command line…]`
+
+`mkosi [options…] shell [-- command line…]`
+
+`mkosi [options…] boot [-- nspawn settings…]`
+
+`mkosi [options…] vm [-- vmm parameters…]`
+
+`mkosi [options…] ssh [-- command line…]`
+
+`mkosi [options…] journalctl [-- command line…]`
+
+`mkosi [options…] coredumpctl [-- command line…]`
+
+`mkosi [options…] sysupdate [-- sysupdate settings…]`
+
+`mkosi [options…] sandbox [-- command line…]`
+
+`mkosi [options…] dependencies [-- options…]`
+
+`mkosi [options…] clean`
+
+`mkosi [options…] serve`
+
+`mkosi [options…] burn `
+
+`mkosi [options…] bump`
+
+`mkosi [options…] genkey`
+
+`mkosi [options…] documentation [manual]`
+
+`mkosi [options…] completion [shell]`
+
+`mkosi [options…] help`
+
+# DESCRIPTION
+
+**mkosi** is a tool for easily building customized OS images. It's a fancy wrapper around **dnf**, **apt**,
+**pacman** and **zypper** that may generate disk images with a number of bells and whistles.
+
+## Command Line Verbs
+
+The following command line verbs are known:
+
+`init`
+: Initialize **mkosi**. This is a one time operation that sets up various
+ config files required for an optimal experience. Currently this only
+ initialized a `tmpfiles.d` dropin for the mkosi package cache
+ directory to make sure old, unused files are cleaned up
+ automatically.
+
+`summary`
+: Show a human-readable summary of all options used for building the images.
+ This will parse the command line and configuration files, but only print
+ what it is configured for and not actually build or run anything.
+
+`cat-config`
+: Output the names and contents of all loaded configuration files. **mkosi**
+ loads a bunch of files from different locations and this command makes
+ it easier to figure out what is configured where.
+
+`build`
+: Build the image-based on the settings passed on the command line and in the
+ configuration files. This command is the default if no verb is specified.
+ Arguments may be passed to the build scripts, if some are defined. To pass options to the build
+ scripts, separate them from regular mkosi options with `--`.
+
+`shell`
+: This builds the image if it is not built yet, and then invokes
+ **systemd-nspawn** to run an interactive shell in the image. This doesn't
+ require booting the system, it's like a better chroot. An optional command
+ line may be specified after the `shell` verb, to be invoked in place of the
+ shell in the container. To pass extra options to nspawn, separate them
+ from regular options with `--`.
+
+`boot`
+: Similar to `shell`, but instead of spawning a shell, it boots systemd in the
+ image using **systemd-nspawn**. Extra arguments may be specified after
+ the `boot` verb, which are passed as the *kernel command line* to the
+ init system in the image. To pass extra options to nspawn, separate them
+ from regular options with `--`.
+
+`vm`
+: Similar to `boot`, but uses the configured virtual machine monitor (by
+ default `qemu`) to boot up the image, i.e. instead of container
+ virtualization, virtual machine virtualization is used. How extra
+ command line arguments are interpreted depends on the configured
+ virtual machine monitor. See `VirtualMachineMonitor=` for more
+ information. To pass extra options to the configured virtual machine
+ monitor, separate them from regular options with `--`.
+
+`ssh`
+: When the image is built with the `Ssh=yes` option, this command
+ connects to a booted virtual machine via SSH. Make sure to run `mkosi ssh`
+ with the same config as `mkosi build` so that it has
+ the necessary information available to connect to the running virtual
+ machine via SSH. Specifically, the SSH private key from the `SshKey=`
+ setting is used to connect to the virtual machine. Use `mkosi genkey`
+ to automatically generate a key and certificate that will be picked up
+ by **mkosi**. Any arguments passed after the `ssh` verb are passed as
+ arguments to the **ssh** invocation. To pass extra options, separate
+ them from regular options with `--`.To connect to a container, use
+ `machinectl login` or `machinectl shell`.
+
+ The `Machine=` option can be used to give the machine a custom
+ hostname when booting it which can later be used to **ssh** into the image
+ (e.g. `mkosi --machine=mymachine vm` followed by
+ `mkosi --machine=mymachine ssh`).
+
+`journalctl`
+: Uses **journalctl** to inspect the journal inside the image.
+ All arguments specified after the `journalctl` verb and separated by
+ `--` from the regular options are appended to the **journalctl**
+ invocation.
+
+`coredumpctl`
+: Uses **coredumpctl** to look for coredumps inside the image.
+ All arguments specified after the `coredumpctl` verb and separated by
+ `--` from the regular options are appended to the **coredumpctl**
+ invocation.
+
+`sysupdate`
+: Invokes **systemd-sysupdate** with the `--transfer-source=` option set
+ to the output directory and the `--definitions=` option set to the
+ directory configured with `SysupdateDirectory=`. All arguments
+ specified after the `sysupdate` verb and separated from the regular
+ options with `--` are passed directly to **systemd-sysupdate**.
+
+`sandbox`
+: Run arbitrary commands inside of the same sandbox used to execute
+ other verbs such as `boot`, `shell`, `vm` and more. This means
+ `/usr` will be replaced by `/usr` from the tools tree if one is used
+ while everything else will remain in place. If no command is provided,
+ `$SHELL` will be executed or **bash** if `$SHELL` is not set. To pass
+ extra options to the given command, separate them from regular options
+ with `--`.
+
+`clean`
+: Remove build artifacts generated on a previous build. If combined
+ with `-f`, also removes incremental build cache images and the tools tree.
+ If `-f` is specified twice, also removes any package cache.
+
+`serve`
+: This builds the image if it is not built yet, and then serves the
+ output directory (i.e. usually `mkosi.output/`, see below) via a
+ small embedded HTTP server, listening on port 8081. Combine with
+ `-f` in order to rebuild the image unconditionally before serving
+ it. This command is useful for testing network-based acquisition of
+ OS images, for example via `machinectl pull-raw …` and `machinectl
+ pull-tar …`.
+
+`burn `
+: This builds the image if it is not built yet, and then writes it to the
+ specified block device. The partition contents are written as-is, but the GPT
+ partition table is corrected to match sector and disk size of the specified
+ medium.
+
+`bump`
+: Bumps the image version from `mkosi.version` and writes the resulting
+ version string to `mkosi.version`. This is useful for implementing a
+ simple versioning scheme: each time this verb is called the version is
+ bumped in preparation for the subsequent build. Note that
+ `--auto-bump`/`-B` may be used to automatically bump the version
+ as part of a build. The new version is only written to
+ `mkosi.version` if the build succeeds in that case.
+
+ If `mkosi.bump` exists, it is invoked to generate the new version to
+ be used instead of using mkosi's own logic.
+
+`genkey`
+: Generate a pair of SecureBoot keys for usage with the
+ `SecureBootKey=`/`--secure-boot-key=` and
+ `SecureBootCertificate=`/`--secure-boot-certificate=` options.
+
+`documentation`
+: Show **mkosi**'s documentation. If no argument is given, the **mkosi** man page is shown, but the arguments
+ `mkosi`, `mkosi-initrd`, `initrd`, `mkosi-sandbox`, `sandbox`, `mkosi.news` and `news` are supported and
+ respectively show the man pages for **mkosi**, **mkosi-initrd**, **mkosi-sandbox** and **mkosi**'s NEWS file.
+
+ By default this verb will try several ways to output the documentation, but a specific option can be
+ chosen with the `--doc-format` option. Distro packagers are encouraged to add a file `mkosi.1` into the
+ `mkosi/resources` directory of the Python package, if it is missing, as well as to install it in the
+ appropriate search path for man pages. The man page can be generated from the markdown file
+ `mkosi/resources/man/mkosi.1.md` e.g via `pandoc -t man -s -o mkosi.1 mkosi.1.md`.
+
+`completion`
+: Generate shell completion for the shell given as argument and print it to stdout. The arguments `bash`,
+ `fish`, and `zsh` are understood.
+
+`dependencies`
+: Output the list of packages required by **mkosi** to build and boot
+ images.
+
+ This list can be piped directly to a package manager to install the
+ packages. For example, if the host system uses the **dnf** package
+ manager, the packages could be installed as follows:
+
+ ```sh
+ mkosi dependencies | xargs -d '\n' dnf install
+ ```
+
+ By default, only the dependencies required to build images with
+ mkosi are shown. Extra tools tree profiles can be enabled to also
+ output the packages belonging to those profiles. For example,
+ running `mkosi dependencies -- --profile runtime` will also output
+ the packages in the runtime profile on top of the regular packages.
+ See the documentation for `ToolsTreeProfiles=` for a list of
+ available profiles.
+
+`help`
+: This verb is equivalent to the `--help` switch documented below: it
+ shows a brief usage explanation.
+
+## Commandline-only Options
+
+Those settings cannot be configured in the configuration files.
+
+`--force`, `-f`
+: Replace the output file if it already exists, when building an
+ image. By default when building an image and an output artifact
+ already exists **mkosi** will refuse operation. Specify this option
+ once to delete all build artifacts from a previous run before
+ re-building the image. If incremental builds are enabled,
+ specifying this option twice will ensure the intermediary
+ cache files are removed, too, before the re-build is initiated. If a
+ package cache is used (also see the **Files** section below),
+ specifying this option thrice will ensure the package cache is
+ removed too, before the re-build is initiated. For the `clean`
+ operation this option has a slightly different effect: by default
+ the verb will only remove build artifacts from a previous run, when
+ specified once the incremental cache files and the tools tree are deleted
+ too, and when specified twice the package cache is also removed.
+
+`--directory=`, `-C`
+: Takes a path to a directory. **mkosi** switches to this directory before
+ doing anything. Note that the various configuration files are searched
+ for in this directory, hence using this option is an effective way to
+ build a project located in a specific directory. Defaults to the current
+ working directory. If the empty string is specified, all configuration in
+ the current working directory will be ignored.
+
+`--debug`
+: Enable additional debugging output.
+
+`--debug-shell`
+: When executing a command in the image fails, **mkosi** will start an interactive
+ shell in the image allowing further debugging.
+
+`--debug-workspace`
+: When specified, the workspace directory will not be deleted and its
+ location will be logged when **mkosi** exits.
+
+`--debug-sandbox`
+: Run **mkosi-sandbox** with **strace**.
+
+`--version`
+: Show package version.
+
+`--help`, `-h`
+: Show brief usage information.
+
+`--genkey-common-name=`
+: Common name to be used when generating keys via **mkosi**'s `genkey` command. Defaults to `mkosi of %u`, where
+ `%u` expands to the username of the user invoking **mkosi**.
+
+`--genkey-valid-days=`
+: Number of days that the keys should remain valid when generating keys via **mkosi**'s `genkey` command.
+ Defaults to two years (730 days).
+
+`--auto-bump=`, `-B`
+: If specified, the version is bumped and if the build succeeds, the
+ version is written to `mkosi.version` in a fashion equivalent to the
+ `bump` verb. This is useful for simple, linear version management:
+ each build in a series will have a version number one higher then
+ the previous one.
+
+ If `mkosi.bump` exists, it is invoked to generate the new version to
+ be used instead of using mkosi's own logic.
+
+`--doc-format`
+: The format to show the documentation in. Supports the values `markdown`,
+ `man`, `pandoc`, `system` and `auto`. In the case of `markdown` the
+ documentation is shown in the original Markdown format. `man` shows the
+ documentation in man page format, if it is available. **pandoc** will generate
+ the man page format on the fly, if **pandoc** is available. `system` will show
+ the system-wide man page for **mkosi**, which may or may not correspond to the
+ version you are using, depending on how you installed **mkosi**. `auto`, which is
+ the default, will try all methods in the order `man`, `pandoc`, `markdown`,
+ `system`.
+
+`--json`
+: Show the summary output as JSON-SEQ.
+
+`--wipe-build-dir`, `-w`
+: Wipe the build directory if one is configured before building the image.
+
+`--rerun-build-scripts`, `-R`
+: Rerun build scripts. Requires the `Incremental=` option to be
+ enabled and the image to have been built once already. If `History=`
+ is enabled, the history from the previous build will be reused and
+ no new history will be written.
+
+## Supported output formats
+
+The following output formats are supported:
+
+* Raw *GPT* disk image, created using **systemd-repart** (*disk*)
+* Plain directory, containing the OS tree (*directory*)
+* Tar archive (*tar*)
+* CPIO archive (*cpio*)
+
+The output format may also be set to *none* to have **mkosi** produce no
+image at all. This can be useful if you only want to use the image to
+produce another output in the build scripts (e.g. build an RPM).
+
+When a *GPT* disk image is created, repart partition definition files
+may be placed in `mkosi.repart/` to configure the generated disk image.
+
+It is highly recommended to run **mkosi** on a file system that supports reflinks
+such as XFS and btrfs and to keep all related directories on the same file
+system. This allows **mkosi** to create images very quickly by using reflinks to
+perform copying via copy-on-write operations.
+
+## Configuration Settings
+
+The following settings can be set through configuration files (the
+syntax with `SomeSetting=value`) and on the command line (the syntax
+with `--some-setting=value`). For some command line parameters, a
+single-letter shortcut is also allowed. In the configuration files,
+the setting must be in the appropriate section, so the settings are
+grouped by section below.
+
+Configuration is parsed in the following order:
+
+* The command line arguments are parsed.
+* `mkosi.local.conf` and `mkosi.local/` are parsed if they exists (in that order).
+ This file and directory should be in `.gitignore` (or equivalent)
+ and are intended for local configuration.
+* Any default paths (depending on the option) are configured if the
+ corresponding path exists.
+* `mkosi.conf` is parsed if it exists in the directory configured with
+ `--directory=` or the current working directory if `--directory=` is
+ not used. If the specified directory does not contain a `mkosi.conf` or
+ `mkosi.tools.conf` and a `mkosi/mkosi.conf` or `mkosi/mkosi.tools.conf`
+ exists, the configuration will be parsed from the `mkosi/`
+ subdirectory of the specified directory instead.
+* `mkosi.conf.d/` is parsed in the same directory as `mkosi.conf` if it
+ exists. Each directory and each file with the `.conf` extension in
+ `mkosi.conf.d/` is parsed. Any directory in `mkosi.conf.d` is parsed
+ as if it were a regular top level directory.
+* If any profiles are configured, their configuration is parsed from the
+ `mkosi.profiles/` directory.
+* Subimages are parsed from the `mkosi.images/` directory if it exists.
+
+Note that settings configured via the command line always override
+settings configured via configuration files. If the same setting is
+configured more than once via configuration files, later assignments
+override earlier assignments except for settings that take a collection
+of values. Also, settings read from `mkosi.local.conf` or `mkosi.local/` will
+override settings from configuration files that are parsed later, but not
+settings specified on the CLI.
+
+For settings that take a single value, the empty assignment (`SomeSetting=` or
+`--some-setting=`) can be used to override a previous setting and reset to the
+default.
+
+Settings that take a collection of values are merged by appending the
+new values to the previously configured values. Assigning the empty
+string to such a setting removes all previously assigned values, and
+overrides any configured default values as well. The values specified
+on the CLI are appended after all the values from configuration files.
+
+To conditionally include configuration files, the `[Match]` section can
+be used. A `[Match]` section consists of individual conditions.
+Conditions can use a pipe symbol (`|`) after the equals sign (`…=|…`),
+which causes the condition to become a triggering condition. The config
+file will be included if the logical AND of all non-triggering
+conditions and the logical OR of all triggering conditions is satisfied.
+To negate the result of a condition, prefix the argument with an
+exclamation mark. If an argument is prefixed with the pipe symbol and an
+exclamation mark, the pipe symbol must be passed first, and the
+exclamation second.
+
+Note that `[Match]` conditions compare against the current values of
+specific settings, and do not take into account changes made to the
+setting in configuration files that have not been parsed yet (settings
+specified on the CLI are taken into account). Also note that matching
+against a setting and then changing its value afterwards in a different
+config file may lead to unexpected results.
+
+The `[Match]` section of a `mkosi.conf` file in a directory applies to
+the entire directory. If the conditions are not satisfied, the entire
+directory is skipped. The `[Match]` sections of files in `mkosi.conf.d/`
+and `mkosi.local.conf` only apply to the file itself.
+
+If there are multiple `[Match]` sections in the same configuration file,
+each of them has to be satisfied in order for the configuration file to
+be included. Specifically, triggering conditions only apply to the
+current `[Match]` section and are reset between multiple `[Match]`
+sections. As an example, the following will only match if the output
+format is one of `disk` or `directory` and the architecture is one of
+`x86-64` or `arm64`:
+
+```ini
+[Match]
+Format=|disk
+Format=|directory
+
+[Match]
+Architecture=|x86-64
+Architecture=|arm64
+```
+
+The `[TriggerMatch]` section can be used to indicate triggering match
+sections. These are identical to triggering conditions except they apply
+to the entire match section instead of just a single condition. As an
+example, the following will match if the distribution is `debian` and
+the release is `bookworm` or if the distribution is `ubuntu` and the
+release is `noble`.
+
+```ini
+[TriggerMatch]
+Distribution=debian
+Release=bookworm
+
+[TriggerMatch]
+Distribution=ubuntu
+Release=noble
+```
+
+The semantics of conditions in `[TriggerMatch]` sections is the same as
+in `[Match]`, i.e. all normal conditions are joined by a logical AND and
+all triggering conditions are joined by a logical OR. When mixing
+`[Match]` and `[TriggerMatch]` sections, a match is achieved when all
+`[Match]` sections match and at least one `[TriggerMatch]` section
+matches. The absence of match sections is valued as true. Logically this means:
+
+```
+(⋀ᵢ Matchᵢ) ∧ (⋁ᵢ TriggerMatchᵢ)
+```
+
+Command line options that take no argument are shown without `=` in
+their long version. In the config files, they should be specified with a
+boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
+`false` to disable.
+
+### [Distribution] Section
+
+`Distribution=`, `--distribution=`, `-d`
+: The distribution to install in the image. Takes one of the following
+ arguments: `fedora`, `debian`, `kali`, `ubuntu`, `arch`, `opensuse`,
+ `mageia`, `centos`, `rhel`, `rhel-ubi`, `openmandriva`, `rocky`, `alma`,
+ `azure` or `custom`. If not specified, defaults to the distribution of
+ the host or `custom` if the distribution of the host is not a supported
+ distribution.
+
+`Release=`, `--release=`, `-r`
+: The release of the distribution to install in the image. The precise
+ syntax of the argument this takes depends on the distribution used,
+ and is either a numeric string (in case of Fedora Linux, CentOS, …,
+ e.g. `29`), or a distribution version name (in case of Debian, Kali,
+ Ubuntu, …, e.g. `artful`). Defaults to a recent version of the chosen
+ distribution, or the version of the distribution running on the host
+ if it matches the configured distribution.
+
+`Architecture=`, `--architecture=`
+: The architecture to build the image for. The architectures that are
+ actually supported depends on the distribution used and whether a
+ bootable image is requested or not. When building for a foreign
+ architecture, you'll also need to install and register a user mode
+ emulator for that architecture.
+
+ One of the following architectures can be specified per image built:
+ `alpha`, `arc`, `arm`, `arm64`, `ia64`, `loongarch64`, `mips64-le`,
+ `mips-le`, `parisc`, `ppc`, `ppc64`, `ppc64-le`, `riscv32`, `riscv64`,
+ `s390`, `s390x`, `tilegx`, `x86`, `x86-64`.
+
+`Mirror=`, `--mirror=`, `-m`
+: The mirror to use for downloading the distribution packages. Expects
+ a mirror URL as argument. If not provided, the default mirror for the
+ distribution is used.
+
+ The default mirrors for each distribution are as follows (unless
+ specified, the same mirror is used for all architectures):
+
+ | | x86-64 | aarch64 |
+ |----------------|-----------------------------------|--------------------------------|
+ | `debian` | http://deb.debian.org/debian | |
+ | `arch` | https://geo.mirror.pkgbuild.com | http://mirror.archlinuxarm.org |
+ | `opensuse` | http://download.opensuse.org | |
+ | `kali` | http://http.kali.org/kali | |
+ | `ubuntu` | http://archive.ubuntu.com | http://ports.ubuntu.com |
+ | `centos` | https://mirrors.centos.org | |
+ | `rocky` | https://mirrors.rockylinux.org | |
+ | `alma` | https://mirrors.almalinux.org | |
+ | `fedora` | https://mirrors.fedoraproject.org | |
+ | `rhel-ubi` | https://cdn-ubi.redhat.com | |
+ | `mageia` | https://www.mageia.org | |
+ | `openmandriva` | http://mirrors.openmandriva.org | |
+ | `azure` | https://packages.microsoft.com/ | |
+
+`LocalMirror=`, `--local-mirror=`
+: The mirror will be used as a local, plain and direct mirror instead
+ of using it as a prefix for the full set of repositories normally supported
+ by distributions. Useful for fully offline builds with a single repository.
+ Supported on **deb**-, **rpm**-, and **pacman**-based distributions. Overrides `--mirror=` but only
+ for the local **mkosi** build, it will not be configured inside the final image,
+ `--mirror=` (or the default repository) will be configured inside the final
+ image instead.
+
+`RepositoryKeyCheck=`, `--repository-key-check=`
+: Controls signature/key checks when using repositories, enabled by default.
+ Useful to disable checks when combined with `--local-mirror=` and using only
+ a repository from a local filesystem.
+
+`RepositoryKeyFetch=`, `--repository-key-fetch=`
+: Controls whether **mkosi** will fetch distribution GPG keys remotely. Enabled by
+ default on Ubuntu when not using a tools tree or when using Ubuntu tools trees to build
+ Arch Linux or RPM-based distributions. Disabled by default on all other distributions.
+ When disabled, the distribution GPG keys for the target distribution have to be installed
+ locally on the host system alongside the package manager for that distribution.
+
+ This setting is only implemented for distributions using **dnf**, **pacman** or **zypper**
+ as their package manager. For other distributions the distribution GPG keys are always looked
+ up locally regardless of the value of this setting. To make the distribution GPG keys
+ for distributions available without enabling this setting, the corresponding package
+ has to be installed on the host. This is usually one of `archlinux-keyring`,
+ `debian-keyring`, `kali-archive-keyring`, `ubuntu-keyring` or `distribution-gpg-keys`
+ (for RPM-based distributions).
+
+`Repositories=`, `--repositories=`
+: Enable package repositories that are disabled by default. This can be used to enable the EPEL repos for
+ CentOS or different components of the Debian/Kali/Ubuntu repositories.
+
+### [Output] Section
+
+`Format=`, `--format=`, `-t`
+: The image format type to generate. One of `directory` (for generating
+ an OS image directly in a local directory), `tar` (similar, but a
+ tarball of the OS image is generated), `cpio` (similar, but a cpio
+ archive is generated), `disk` (a block device OS image with a GPT
+ partition table), `uki` (a unified kernel image with the OS image in
+ the `.initrd` PE section), `esp` (`uki` but wrapped in a disk image
+ with only an ESP partition), `oci` (a directory compatible with the
+ OCI image specification), `sysext`, `confext`, `portable`,
+ `addon` or `none` (the OS image is solely intended as a build
+ image to produce another artifact).
+
+ If the `disk` output format is used, the disk image is generated using
+ **systemd-repart**. The repart partition definition files to use can be
+ configured using the `RepartDirectories=` setting or via
+ `mkosi.repart/`. When verity partitions are configured using
+ **systemd-repart**'s `Verity=` setting, **mkosi** will automatically parse the
+ verity hash partition's roothash from **systemd-repart**'s JSON output and
+ include it in the kernel command line of every unified kernel image
+ built by **mkosi**.
+
+ If the `none` output format is used, the outputs from a previous
+ build are not removed, but clean scripts (see `CleanScripts=`) are
+ still executed. This allows rerunning a build script
+ (see `BuildScripts=`) without removing the results of a previous
+ build.
+
+`ManifestFormat=`, `--manifest-format=`
+: The manifest format type or types to generate. A comma-delimited
+ list consisting of `json` (the standard JSON output format that
+ describes the packages installed), `changelog` (a human-readable
+ text format designed for diffing). By default no manifest is
+ generated.
+
+`Output=`, `--output=`, `-o`
+: Name to use for the generated output image file or directory. Defaults
+ to `image` or, if `ImageId=` is specified, it is used as the default
+ output name, optionally suffixed with the version set with
+ `ImageVersion=` or if a specific image is built from `mkosi.images`, the
+ name of the image is preferred over `ImageId`. Note that this option does
+ not allow configuring the output directory, use `OutputDirectory=` for that.
+
+ Note that this only specifies the output prefix, depending on the
+ specific output format, compression and image version used, the full
+ output name might be `image_7.8.raw.xz`.
+
+`OutputExtension=`, `--output-extension=`
+: Use the specified extension for the output file. Defaults to the appropriate
+ extension based on the output format. Only includes the file extension, not
+ any compression extension which will be appended to this extension if compression
+ is enabled.
+
+`CompressOutput=`, `--compress-output=`
+: Configure compression for the resulting image or archive. The argument can be
+ either a boolean or a compression algorithm (**xz**, **zstd**). **zstd**
+ compression is used by default, except CentOS and derivatives up to version
+ 8, which default to **xz**, and OCI images, which default to **gzip**.
+ Note that when applied to block device image types,
+ compression means the image cannot be started directly but needs to be
+ decompressed first. This also means that the `shell`, `boot`, `vm` verbs
+ are not available when this option is used. Implied for `tar`, `cpio`, `uki`,
+ `esp`, `oci` and `addon`.
+
+`CompressLevel=`, `--compress-level=`
+: Configure the compression level to use. Takes an integer. The possible
+ values depend on the compression being used.
+
+`OutputDirectory=`, `--output-directory=`, `-O`
+: Path to a directory where to place all generated artifacts. If this is
+ not specified and the directory `mkosi.output/` exists in the local
+ directory, it is automatically used for this purpose.
+
+`OutputMode=`, `--output-mode=`
+: File system access mode used when creating the output image file. Takes an
+ access mode in octal notation. If not set, uses the current system defaults.
+
+`ImageVersion=`, `--image-version=`
+: Configure the image version. This accepts any string, but it is
+ recommended to specify a series of dot separated components. The
+ version may also be configured by reading a `mkosi.version` file (in
+ which case it may be conveniently managed via the `bump` verb or the
+ `--auto-bump` option) or by reading stdout if it is executable (see
+ the **Scripts** section below). When specified the image version is
+ included in the default output file name, i.e. instead of `image.raw`
+ the default will be `image_0.1.raw` for version `0.1` of the image,
+ and similar. The version is also passed via the `$IMAGE_VERSION` to
+ any build scripts invoked (which may be useful to patch it into
+ `/usr/lib/os-release` or similar, in particular the `IMAGE_VERSION=`
+ field of it).
+
+`ImageId=`, `--image-id=`
+: Configure the image identifier. This accepts a freeform string that
+ shall be used to identify the image with. If set the default output
+ file will be named after it (possibly suffixed with the version). The
+ identifier is also passed via the `$IMAGE_ID` to any build scripts
+ invoked. The image ID is automatically added to `/usr/lib/os-release`.
+
+`SplitArtifacts=`, `--split-artifacts=`
+: The artifact types to split out of the final image. A comma-delimited
+ list consisting of `uki`, `kernel`, `initrd`, `os-release`, `prcs`, `partitions`,
+ `roothash` and `tar`. When building a bootable image `kernel` and `initrd`
+ correspond to their artifact found in the image (or in the UKI),
+ while `uki` copies out the entire UKI. If `pcrs` is specified, a JSON
+ file containing the pre-calculated TPM2 digests is written out, according
+ to the [UKI specification](https://uapi-group.org/specifications/specs/unified_kernel_image/#json-format-for-pcrsig),
+ which is useful for offline signing.
+
+ When building a disk image and `partitions` is specified,
+ pass `--split=yes` to **systemd-repart** to have it write out split partition
+ files for each configured partition. Read the
+ [man](https://www.freedesktop.org/software/systemd/man/systemd-repart.html#--split=BOOL)
+ page for more information. This is useful in A/B update scenarios where
+ an existing disk image shall be augmented with a new version of a
+ root or `/usr` partition along with its Verity partition and unified
+ kernel.
+
+ When `tar` is specified, the rootfs is additionally archived as a
+ tar archive (compressed according to `CompressOutput=`).
+
+ When `roothash` is specified and a dm-verity disk image is built, the dm-verity
+ roothash is written out as a separate file, which is useful for offline signing.
+
+ By default `uki`, `kernel` and `initrd` are split out.
+
+`RepartDirectories=`, `--repart-directory=`
+: Paths to directories containing **systemd-repart** partition definition
+ files that are used when **mkosi** invokes **systemd-repart** when building a
+ disk image. If `mkosi.repart/` exists in the local directory, it will
+ be used for this purpose as well. Note that **mkosi** invokes repart with
+ `--root=` set to the root of the image root, so any `CopyFiles=`
+ source paths in partition definition files will be relative to the
+ image root directory.
+
+`SectorSize=`, `--sector-size=`
+: Override the default sector size that **systemd-repart** uses when building a disk
+ image.
+
+`Overlay=`, `--overlay=`
+: When used together with `BaseTrees=`, the output will consist only out of
+ changes to the specified base trees. Each base tree is attached as a lower
+ layer in an overlayfs structure, and the output becomes the upper layer,
+ initially empty. Thus files that are not modified compared to the base trees
+ will not be present in the final output.
+
+ This option may be used to create [systemd *system extensions* or
+ *portable services*](https://uapi-group.org/specifications/specs/extension_image).
+
+`Seed=`, `--seed=`
+: Takes a UUID as argument or the special value `random`.
+ Overrides the seed that **systemd-repart**
+ uses when building a disk image. This is useful to achieve reproducible
+ builds, where deterministic UUIDs and other partition metadata should be
+ derived on each build. If not specified explicitly and the file `mkosi.seed`
+ exists in the local directory, the UUID to use is read from it. Otherwise,
+ a random UUID is used.
+
+`CleanScripts=`, `--clean-script=`
+: Takes a comma-separated list of paths to executables that are used as
+ the clean scripts for this image. See the **Scripts** section for
+ more information.
+
+### [Content] Section
+
+`Packages=`, `--package=`, `-p`
+: Install the specified distribution packages (i.e. RPM, deb, …) in the
+ image. Takes a comma-separated list of package specifications. This
+ option may be used multiple times in which case the specified package
+ lists are combined. Use `BuildPackages=` to specify packages that
+ shall only be installed in an overlay that is mounted when the prepare
+ scripts are executed with the `build` argument and when the build scripts
+ are executed.
+
+ The types and syntax of *package specifications* that are allowed
+ depend on the package installer (e.g. **dnf** for RPM-based distros or
+ **apt** for deb-based distros), but may include package names, package
+ names with version and/or architecture, package name globs, package
+ groups, and virtual provides, including file paths.
+
+ See `PackageDirectories=` for information on how to make local
+ packages available for installation with `Packages=`.
+
+ **Example**: when using a distro that uses **dnf**, the following configuration
+ would install the **meson** package (in the latest version), the 32-bit version
+ of the `libfdisk-devel` package, all available packages that start with the
+ `git-` prefix, a **systemd** RPM from the local file system, one of the
+ packages that provides `/usr/bin/ld`, the packages in the *Development Tools*
+ group, and the package that contains the `mypy` python module.
+
+ ```ini
+ Packages=meson
+ libfdisk-devel.i686
+ git-*
+ /usr/bin/ld
+ @development-tools
+ python3dist(mypy)
+ ```
+
+`BuildPackages=`, `--build-package=`
+: Similar to `Packages=`, but configures packages to install only in an
+ overlay that is made available on top of the image to the prepare
+ scripts when executed with the `build` argument and the build scripts.
+ This option should be used to list packages containing header files,
+ compilers, build systems, linkers and other build tools the
+ `mkosi.build` scripts require to operate. Note that packages listed
+ here will be absent in the final image.
+
+`VolatilePackages=`, `--volatile-package=`
+: Similar to `Packages=`, but packages configured with this setting are
+ not cached when `Incremental=` is enabled and are installed after
+ executing any build scripts.
+
+ Specifically, this setting can be used to install packages that change
+ often or which are built by a build script.
+
+`PackageDirectories=`, `--package-directory=`
+: Specify directories containing extra packages to be made available during
+ the build. **mkosi** will create a local repository containing all
+ packages in these directories and make it available when installing packages or
+ running scripts. If the `mkosi.packages/` directory is found in the local
+ directory it is also used for this purpose.
+
+`VolatilePackageDirectories=`, `--volatile-package-directory=`
+: Like `PackageDirectories=`, but any changes to the packages in these
+ directories will not invalidate the cached images if `Incremental=`
+ is enabled.
+
+ Additionally, build scripts can add more packages to the local
+ repository by placing the built packages in `$PACKAGEDIR`. The
+ packages placed in `$PACKAGEDIR` are shared between all image builds
+ and thus available for installation in all images using
+ `VolatilePackages=`.
+
+`WithRecommends=`, `--with-recommends=`
+: Configures whether to install recommended or weak dependencies,
+ depending on how they are named by the used package manager, or not.
+ By default, recommended packages are not installed. This is only used
+ for package managers that support the concept, which are currently
+ **apt**, **dnf** and **zypper**.
+
+`WithDocs=`, `--with-docs=`
+: Include documentation in the image. Enabled by default. When disabled,
+ if the underlying distribution package manager supports it
+ documentation is not included in the image. The `$WITH_DOCS`
+ environment variable passed to the `mkosi.build` scripts is set to `0`
+ or `1` depending on whether this option is enabled or disabled.
+
+`BaseTrees=`, `--base-tree=`
+: Takes a comma-separated list of paths to use as base trees. When used,
+ these base trees are each copied into the OS tree and form the base
+ distribution instead of installing the distribution from scratch. Only
+ extra packages are installed on top of the ones already installed in
+ the base trees. Note that for this to work properly, the base image
+ still needs to contain the package manager metadata by setting
+ `CleanPackageMetadata=no` (see `CleanPackageMetadata=`).
+
+ Instead of a directory, a tar file or a disk image may be provided. In
+ this case it is unpacked into the OS tree. This mode of operation
+ allows setting permissions and file ownership explicitly, in
+ particular for projects stored in a version control system such as
+ **git** which retain full file ownership and access mode metadata for
+ committed files.
+
+`SkeletonTrees=`, `--skeleton-tree=`
+: Takes a comma-separated list of colon-separated path pairs. The first
+ path of each pair refers to a directory to copy into the OS tree
+ before invoking the package manager. The second path of each pair
+ refers to the target directory inside the image. If the second path is
+ not provided, the directory is copied on top of the root directory of
+ the image. The second path is always interpreted as an absolute path.
+ Use this to insert files and directories into the OS tree before the
+ package manager installs any packages. If the `mkosi.skeleton/`
+ directory is found in the local directory it is also used for this
+ purpose with the root directory as target (also see the **Files**
+ section below).
+
+ Note that skeleton trees are cached and any changes to skeleton trees
+ after a cached image has been built (when using `Incremental=`) are
+ only applied when the cached image is rebuilt (by using `-ff` or
+ running `mkosi -f clean`).
+
+ As with the base tree logic above, instead of a directory, a tar
+ file may be provided too. `mkosi.skeleton.tar` will be automatically
+ used if found in the local directory.
+
+ To add extra package manager configuration files such as extra
+ repositories, use `SandboxTrees=` as **mkosi** invokes the package
+ managers from outside the image and not inside so any package
+ manager configuration files provided via `SkeletonTrees=` won't
+ take effect when **mkosi** invokes a package manager to install
+ packages.
+
+`ExtraTrees=`, `--extra-tree=`
+: Takes a comma-separated list of colon-separated path pairs. The first
+ path of each pair refers to a directory to copy from the host into the
+ image. The second path of each pair refers to the target directory
+ inside the image. If the second path is not provided, the directory is
+ copied on top of the root directory of the image. The second path is
+ always interpreted as an absolute path. Use this to override any
+ default configuration files shipped with the distribution. If the
+ `mkosi.extra/` directory is found in the local directory it is also
+ used for this purpose with the root directory as target (also see the
+ **Files** section below).
+
+ As with the base tree logic above, instead of a directory, a tar
+ file may be provided too. `mkosi.extra.tar` will be automatically
+ used if found in the local directory.
+
+`RemovePackages=`, `--remove-package=`
+: Takes a comma-separated list of package specifications for removal, in
+ the same format as `Packages=`. The removal will be performed as one
+ of the last steps. This step is skipped if `CleanPackageMetadata=no`
+ is used.
+
+`RemoveFiles=`, `--remove-files=`
+: Takes a comma-separated list of globs. Files in the image matching
+ the globs will be purged at the end.
+
+`CleanPackageMetadata=`, `--clean-package-metadata=`
+: Enable/disable removal of package manager databases and repository
+ metadata at the end of installation. Can be specified as `true`,
+ `false`, or `auto` (the default). With `auto`, package manager
+ databases and repository metadata will be removed if the respective
+ package manager executable is *not* present at the end of the
+ installation.
+
+`SourceDateEpoch=`, `--source-date-epoch=`
+: Takes a timestamp in seconds since the UNIX epoch as argument.
+ File modification times of all files will be clamped to this value.
+ The variable is also propagated to **systemd-repart** and
+ scripts executed by **mkosi**. If not set explicitly, `SOURCE_DATE_EPOCH` from
+ `--environment=` and from the host environment are tried in that order.
+ This is useful to make builds reproducible. See
+ [SOURCE_DATE_EPOCH](https://reproducible-builds.org/specs/source-date-epoch/)
+ for more information.
+
+`SyncScripts=`, `--sync-script=`
+: Takes a comma-separated list of paths to executables that are used as
+ the sync scripts for this image. See the **Scripts** section for
+ more information.
+
+`PrepareScripts=`, `--prepare-script=`
+: Takes a comma-separated list of paths to executables that are used as
+ the prepare scripts for this image. See the **Scripts** section for
+ more information.
+
+`BuildScripts=`, `--build-script=`
+: Takes a comma-separated list of paths to executables that are used as
+ the build scripts for this image. See the **Scripts** section for more
+ information.
+
+`PostInstallationScripts=`, `--postinst-script=`
+: Takes a comma-separated list of paths to executables that are used as
+ the post-installation scripts for this image. See the **Scripts** section
+ for more information.
+
+`FinalizeScripts=`, `--finalize-script=`
+: Takes a comma-separated list of paths to executables that are used as
+ the finalize scripts for this image. See the **Scripts** section for more
+ information.
+
+`PostOutputScripts=`, `--postoutput-script=`
+: Takes a comma-separated list of paths to executables that are used as
+ the post output scripts for this image. See the **Scripts** section for more
+ information.
+
+`Bootable=`, `--bootable=`
+: Takes a boolean or `auto`. Enables or disables generation of a
+ bootable image. If enabled, **mkosi** will install an EFI bootloader, and
+ add an ESP partition when the disk image output is used. If the
+ selected EFI bootloader (see `Bootloader=`) is not installed or no
+ kernel images can be found, the build will fail. `auto` behaves as if
+ the option was enabled, but the build won't fail if either no kernel
+ images or the selected EFI bootloader can't be found. If disabled, no
+ bootloader will be installed even if found inside the image, no
+ unified kernel images will be generated and no ESP partition will be
+ added to the image if the disk output format is used.
+
+`Bootloader=`, `--bootloader=`
+: Takes one of `none`, `systemd-boot`, `uki`, `grub`,
+ `systemd-boot-signed`, `uki-signed` or `grub-signed`. Defaults to
+ `systemd-boot`. If set to `none`, no EFI bootloader will be installed
+ into the image. If set to `systemd-boot`, **systemd-boot** will be
+ installed and for each installed kernel, a UKI will be generated and
+ stored in `EFI/Linux` in the ESP. If set to `uki`, a single UKI will
+ be generated for the latest installed kernel (the one with the highest
+ version) which is installed to `EFI/BOOT/BOOTX64.EFI` in the ESP. If
+ set to `grub`, for each installed kernel, a UKI will be generated and
+ stored in `EFI/Linux` in the ESP. For each generated UKI, a menu entry
+ is appended to the grub configuration in `grub/grub.cfg` in the ESP
+ which chainloads into the UKI. A shim grub.cfg is also written to
+ `EFI//grub.cfg` in the ESP which loads `grub/grub.cfg`
+ in the ESP for compatibility with signed versions of grub which load
+ the grub configuration from this location.
+
+ The `signed` variants will only install pre-signed EFI binaries
+ shipped by the distribution.
+
+ Kernels need to be placed into the root filesystem (for example using
+ `ExtraTrees=`) under `/usr/lib/modules/$version`, named `vmlinux` or
+ `vmlinuz`. The `$version` is as produced by Kbuild's `kernelversion` make
+ target.
+
+ Note: When using `systemd-boot` or `systemd-boot-signed`, `mkosi` expects
+ the `systemd-boot` EFI binaries to be present in the image. Depending on
+ your distribution, these may be packaged separately. For example, Debian-
+ based images will need `systemd-boot-efi`.
+
+`BiosBootloader=`, `--bios-bootloader=`
+: Takes one of `none` or `grub`. Defaults to `none`. If set to `none`,
+ no BIOS bootloader will be installed. If set to `grub`, grub is
+ installed as the BIOS boot loader if a bootable image is requested
+ with the `Bootable=` option. If no repart partition definition files
+ are configured, **mkosi** will add a grub BIOS boot partition and an EFI
+ system partition to the default partition definition files.
+
+ Note that this option is not mutually exclusive with `Bootloader=`. It
+ is possible to have an image that is both bootable on UEFI and BIOS by
+ configuring both `Bootloader=` and `BiosBootloader=`.
+
+ The grub BIOS boot partition should have UUID
+ `21686148-6449-6e6f-744e-656564454649` and should be at least 1MB.
+
+ Even if no EFI bootloader is installed, we still need an ESP for BIOS
+ boot as that's where we store the kernel, initrd and grub modules.
+
+`ShimBootloader=`, `--shim-bootloader=`
+: Takes one of `none`, `unsigned`, or `signed`. Defaults to `none`. If
+ set to `none`, shim and MokManager will not be installed to the ESP.
+ If set to `unsigned`, **mkosi** will search for unsigned shim and
+ MokManager EFI binaries and install them. If `SecureBoot=` is enabled,
+ **mkosi** will sign the unsigned EFI binaries before installing them. If
+ set to `signed`, **mkosi** will search for signed EFI binaries and install
+ those. Even if `SecureBoot=` is enabled, **mkosi** won't sign these
+ binaries again.
+
+ Note that this option only takes effect when an image that is bootable
+ on UEFI firmware is requested using other options
+ (`Bootable=`, `Bootloader=`).
+
+ Note that when this option is enabled, **mkosi** will only install already
+ signed bootloader binaries, kernel image files and unified kernel
+ images as self-signed binaries would not be accepted by the signed
+ version of shim.
+
+`UnifiedKernelImages=`, `--unified-kernel-images=`
+: Specifies whether to use unified kernel images or not when
+ `Bootloader=` is set to `systemd-boot` or `grub`. Takes a boolean
+ value or `auto`. Defaults to `auto`. If enabled, unified kernel images
+ are always used and the build will fail if any components required to
+ build unified kernel images are missing. If set to `auto`, unified
+ kernel images will be used if all necessary components are available.
+ Otherwise Type 1 entries as defined by the Boot Loader Specification
+ will be used instead. If disabled, Type 1 entries will always be used.
+
+`UnifiedKernelImageFormat=`, `--unified-kernel-image-format=`
+: Takes a filename without any path components to specify the format that
+ unified kernel images should be installed as. This may include both the
+ regular specifiers (see **Specifiers**) and special delayed specifiers, that
+ are expanded during the installation of the files, which are described below.
+ The default format for this parameter is `&e-&k` with `-&h` being appended
+ if `roothash=` or `usrhash=` is found on the kernel command line and `+&c`
+ if `/etc/kernel/tries` is found in the image.
+
+ The following specifiers may be used:
+
+ | Specifier | Value |
+ |-----------|----------------------------------------------------|
+ | `&&` | `&` character |
+ | `&e` | Entry Token |
+ | `&k` | Kernel version |
+ | `&h` | `roothash=` or `usrhash=` value of kernel argument |
+
+`UnifiedKernelImageProfiles=`, `--uki-profile=`
+: Build additional UKI profiles. Takes a comma-separated list of paths
+ to UKI profile config files. This option may be used multiple times in
+ which case each config gets built into a corresponding UKI profile.
+ Config files in the `mkosi.uki-profiles/` directory are
+ automatically picked up. All configured UKI profiles are added as
+ additional UKI profiles to each UKI built by **mkosi**.
+
+ See the documentation for the `UKIProfile` section for information
+ on which settings can be configured in UKI profile config files.
+
+`Initrds=`, `--initrd=`
+: Use user-provided initrd(s). Takes a comma-separated list of paths to initrd
+ files. This option may be used multiple times in which case the initrd lists
+ are combined. If no initrds are specified and a bootable image is requested,
+ **mkosi** will look for initrds in a subdirectory `io.mkosi.initrd` of the
+ artifact directory (see `$ARTIFACTDIR` in the section **ENVIRONMENT
+ VARIABLES**), if none are found there **mkosi** will automatically build a
+ default initrd.
+
+`InitrdProfiles=`, `--initrd-profile=`
+: Set the profiles to enable for the default initrd. Takes a
+ comma-delimited list of profiles. By default, all profiles are
+ disabled.
+
+ The `lvm` profile enables support for LVM.
+ The `pkcs11` profile enables support for PKCS#11.
+ The `plymouth` profile provides a graphical interface at boot (animation and
+ password prompt).
+ The `raid` profile enables support for RAID arrays.
+
+`InitrdPackages=`, `--initrd-package=`
+: Extra packages to install into the default initrd. Takes a comma
+ separated list of package specifications. This option may be used
+ multiple times in which case the specified package lists are combined.
+
+`InitrdVolatilePackages=`, `--initrd-volatile-package=`
+: Similar to `VolatilePackages=`, except it applies to the default
+ initrd.
+
+`Devicetree=`, `--devicetree=`
+: When set, specifies a Devicetree blob to be used by the booting system,
+ instead of the one provided by firmware. **mkosi** will search for the
+ specified file relative to common paths where Linux distributions install
+ Devicetree files. It should typically have the format `/.dtb`.
+
+`Splash=`, `--splash=`
+: When set, the boot splash for any unified kernel image built by **mkosi** will
+ be picked up from the given path inside the image.
+
+`MicrocodeHost=`, `--microcode-host=`
+: When set to true only include microcode for the host's CPU in the image.
+
+`KernelCommandLine=`, `--kernel-command-line=`
+: Use the specified kernel command line when building images.
+
+ If the root or usr partition are created with verity enabled,
+ `roothash=` or `usrhash=` respectively are automatically added to the
+ kernel command line and `root=` or `mount.usr=` should not be added.
+ Otherwise, if the value of this setting contains the literals
+ `root=PARTUUID` or `mount.usr=PARTUUID`, these are replaced with the
+ partition UUID of the root or usr partition respectively. For
+ example, `root=PARTUUID` would be replaced with
+ `root=PARTUUID=58c7d0b2-d224-4834-a16f-e036322e88f7` where
+ `58c7d0b2-d224-4834-a16f-e036322e88f7` is the partition UUID of the
+ root partition.
+
+`KernelModules=`, `--kernel-modules=`
+: Takes a list of glob patterns that specify which kernel modules to include in the image.
+ Each argument may be prefixed with a dash (`-`), to *exclude* matching modules.
+ The arguments are evaluated in order,
+ the last positive or negative matching pattern determines the result.
+ The modules that were last matched by a positive pattern are included in the image,
+ as well as their module and firmware dependencies.
+
+ The module paths are taken relative to the `/usr/lib/modules///kernel/` directory,
+ and the `.ko` suffix and compression suffix are ignored during matching.
+ The patterns may include just the basename (e.g. `loop`),
+ which must match the basename of the module,
+ the relative path (e.g. `block/loop`),
+ which must match the final components of the module path up to the basename,
+ or an absolute path (e.g. `/drivers/block/loop`),
+ which must match the full path to the module.
+ When suffixed with `/`, the pattern will match all modules underneath that directory.
+ The patterns may include shell-style globs (`*`, `?`, `[…-…]`).
+
+ If the special value `default` is used, the default kernel modules
+ defined in the **mkosi-initrd** configuration are included as well.
+
+ If the special value `host` is used, the currently loaded modules on
+ the host system are included as well.
+
+`KernelModulesInitrd=`, `--kernel-modules-initrd=`
+: Boolean value, enabled (true) by default. If enabled, when building a bootable image, **mkosi** will generate
+ an extra initrd for each unified kernel image it assembles. This initrd contains only modules for
+ the specific kernel version, and will be appended to the prebuilt initrd. This allows generating kernel
+ independent initrds which are augmented with the necessary modules when the UKI is assembled.
+
+`KernelInitrdModules=`, `--kernel-modules-initrd-include=`
+: Like `KernelModules=`, but specifies the kernel modules to include in the initrd.
+
+`FirmwareFiles=`, `--firmware-files=`
+: Takes a list of glob patterns that specify which firmware files to include in the image.
+ The patterns are interpreted in the same way as in the `KernelModules=` settings,
+ except that the paths are relative to `/usr/lib/firmware/`.
+ The compression suffix is ignored and must not be included in the pattern.
+
+ Firmware files that listed by modules that are included in the image are
+ automatically included.
+
+ Example: `FirmwareFiles=cxgb4/bcm8483.bin` or `FirmwareFiles=bcm8483.*` would both cause
+ `/usr/lib/firmware/cxgb4/bcm8483.bin.xz` to be included,
+ even if not listed by a module.
+
+`Locale=`, `--locale=`, `LocaleMessages=`, `--locale-messages=`, `Keymap=`, `--keymap=`, `Timezone=`, `--timezone=`, `Hostname=`, `--hostname=`, `RootShell=`, `--root-shell=`
+: The settings `Locale=`, `--locale=`, `LocaleMessages=`, `--locale-messages=`,
+ `Keymap=`, `--keymap=`, `Timezone=`, `--timezone=`, `Hostname=`,
+ `--hostname=`, `RootShell=`, `--root-shell=` correspond to the identically
+ named systemd-firstboot options. See **systemd-firstboot**(1)
+ for more information. Additionally, where applicable, the corresponding
+ systemd credentials for these settings are written to `/usr/lib/credstore`,
+ so that they apply even if only `/usr` is shipped in the image.
+
+`RootPassword=`, `--root-password=`,
+: Set the system root password. If this option is not used, but a `mkosi.rootpw` file is found in the local
+ directory, the password is automatically read from it or if the file is executable it is run as a script
+ and stdout is read instead (see the **Scripts** section below). If the password starts with `hashed:`, it is
+ treated as an already hashed root password. The root password is also stored in `/usr/lib/credstore` under
+ the appropriate systemd credential so that it applies even if only `/usr` is shipped in the image. To create
+ an unlocked account without any password use `hashed:` without a hash.
+
+`Autologin=`, `--autologin=`, `-a`
+: Enable autologin for the `root` user on `/dev/pts/0` (nspawn),
+ `/dev/tty1` and `/dev/hvc0`.
+
+`MakeInitrd=`, `--make-initrd=`
+: Add `/etc/initrd-release` and `/init` to the image so that it can be
+ used as an initramfs.
+
+`Ssh=`, `--ssh=`
+: Specifies whether to install an **sshd** socket unit and matching service
+ in the final image. Takes one of `always`, `never`, `auto` or `runtime`.
+ Defaults to `auto`.
+
+ If set to `auto` and `sshd` is present in the image and the generator binary
+ `systemd-ssh-generator` is not present, or if set to `always`,
+ mkosi will install **sshd** units in the final image that expose SSH over VSock.
+ If set to `never`, mkosi will not install these units. If the `runtime` value is used,
+ mkosi will also not install any units but abort starting `mkosi vm` if no
+ SSH credentials are configured. When building with this
+ option and running the image using `mkosi vm`, the `mkosi ssh`
+ command can be used to connect to the container/VM via SSH. Note that
+ you still have to make sure openssh is installed in the image to make
+ `mkosi ssh` behave correctly. Run `mkosi genkey` to automatically
+ generate an X.509 certificate and private key to be used by **mkosi** to
+ enable SSH access to any virtual machines via `mkosi ssh`. To access
+ images booted using `mkosi boot`, use **machinectl**.
+
+`SELinuxRelabel=`, `--selinux-relabel=`
+: Specifies whether to relabel files to match the image's SELinux
+ policy. Takes a boolean value or `auto`. Defaults to `auto`. If
+ disabled, files will not relabeled. If enabled, an SELinux policy has
+ to be installed in the image and **setfiles** has to be available to
+ relabel files. If any errors occur during **setfiles**, the build will
+ fail. If set to `auto`, files will be relabeled if mkosi is not
+ building a directory image, an SELinux policy is installed in the
+ image and if **setfiles** is available. Any errors occurred during
+ **setfiles** will be ignored.
+
+ Note that when running unprivileged, **setfiles** will fail to set any
+ labels that are not in the host's SELinux policy. To ensure **setfiles**
+ succeeds without errors, make sure to run **mkosi** as root or build from
+ a host system with the same SELinux policy as the image you're
+ building.
+
+`MachineId=`, `--machine-id=`
+
+: Takes a UUID or the special value `random`. Sets the machine ID of the
+ image to the specified UUID. If set to `random`, a random UUID will be
+ written to `/etc/machine-id`. If not specified explicitly and the file
+ `mkosi.machine-id` exists in the local directory, the UUID to use is
+ read from it. Otherwise, `uninitialized` will be written to `/etc/machine-id`.
+
+### [Validation] Section
+
+`SecureBoot=`, `--secure-boot=`
+: Sign **systemd-boot** (if it is not signed yet) and any generated
+ unified kernel images for UEFI SecureBoot.
+
+`SecureBootAutoEnroll=`, `--secure-boot-auto-enroll=`
+: Set up automatic enrollment of the secure boot keys in virtual machines as
+ documented in **systemd-boot**(7) if `SecureBoot=` is used.
+ Note that **systemd-boot** will only do automatic secure boot key
+ enrollment in virtual machines starting from systemd v253. To do auto
+ enrollment on systemd v252 or on bare metal machines, write a
+ **systemd-boot** configuration file to `/efi/loader/loader.conf` using an
+ extra tree with `secure-boot-enroll force` or
+ `secure-boot-enroll manual` in it. Auto enrollment is not supported on
+ systemd versions older than v252. Defaults to `yes`.
+
+`SecureBootKey=`, `--secure-boot-key=`
+: Path to the PEM file containing the secret key for signing the
+ UEFI kernel image if `SecureBoot=` is used and PCR signatures when
+ `SignExpectedPcr=` is also used. When `SecureBootKeySource=` is specified,
+ the input type depends on the source.
+
+`SecureBootCertificate=`, `--secure-boot-certificate=`
+: Path to the X.509 file containing the certificate for the signed
+ UEFI kernel image, if `SecureBoot=` is used.
+
+`SecureBootSignTool=`, `--secure-boot-sign-tool=`
+: Tool to use to sign secure boot PE binaries. Takes one of `systemd-sbsign`, `sbsign` or `auto`.
+ Defaults to `auto`. If set to `auto`, either **systemd-sbsign** or **sbsign** are used if
+ available, with **systemd-sbsign** being preferred.
+
+`Verity=`, `--verity=`
+: Whether to enforce or disable verity for extension images. Takes one of
+ `signed`, `hash`, `defer`, `auto` or a boolean value. If set to `signed`,
+ a verity key and certificate must be present and the build will fail if
+ we don't detect any verity partitions in the disk image produced by
+ **systemd-repart**. If disabled, verity partitions will be excluded
+ from the extension images produced by **systemd-repart**. If set to
+ `hash`, **mkosi** configures **systemd-repart** to create a verity hash
+ partition, but no signature partition. If set to `defer`, space for the verity
+ sig partition will be allocated but it will not be populated yet. If set to
+ `auto` and a verity key and certificate are present, **mkosi** will pass them
+ to **systemd-repart** and expects the generated disk image to contain verity
+ partitions, but the build won't fail if no verity partitions are found in the
+ disk image produced by **systemd-repart**.
+
+ Note that explicitly disabling verity signature and/or hash is not yet
+ implemented for the `disk` output and only works for extension images at the
+ moment.
+
+`VerityKey=`, `--verity-key=`
+: Path to the PEM file containing the secret key for signing the verity signature, if a verity signature
+ partition is added with **systemd-repart**. When `VerityKeySource=` is specified, the input type depends on
+ the source.
+
+`VerityCertificate=`, `--verity-certificate=`
+: Path to the X.509 file containing the certificate for signing the verity signature, if a verity signature
+ partition is added with **systemd-repart**.
+
+`SignExpectedPcr=`, `--sign-expected-pcr=`
+: Measure the components of the unified kernel image (UKI) using
+ **systemd-measure** and embed the PCR signature into the unified kernel
+ image. This option takes a boolean value or the special value `auto`,
+ which is the default, which is equal to a true value if the
+ **systemd-measure** binary is in `PATH`. Depends on `SecureBoot=`
+ being enabled and key from `SecureBootKey=`.
+
+`SignExpectedPcrKey=`, `--sign-expected-pcr-key=`
+: Path to the PEM file containing the secret key for signing the expected PCR signatures.
+ When `SignExpectedPcrKeySource=` is specified, the input type depends on
+ the source.
+
+`SignExpectedPcrCertificate=`, `--sign-expected-pcr-certificate=`
+: Path to the X.509 file containing the certificate for signing the expected PCR signatures.
+
+`SecureBootKeySource=`, `--secure-boot-key-source=`, `VerityKeySource=`, `--verity-key-source=`, `SignExpectedPcrKeySource=`, `--sign-expected-key-source=`
+: The source of the corresponding private key, to support OpenSSL engines and providers,
+ e.g. `--secure-boot-key-source=engine:pkcs11` or `--secure-boot-key-source=provider:pkcs11`.
+
+`SecureBootCertificateSource=`, `--secure-boot-certificate-source=`, `VerityCertificateSource=`, `--verity-certificate-source=`, `SignExpectedPcrCertificateSource=`, `--sign-expected-certificate-source=`
+: The source of the corresponding certificate, to support OpenSSL providers,
+ e.g. `--secure-boot-certificate-source=provider:pkcs11`. Note that engines are not supported.
+
+`Passphrase=`, `--passphrase=`
+: Specify the path to a file containing the passphrase to use for LUKS
+ encryption. It should contain the passphrase literally, and not end in
+ a newline character (i.e. in the same format as **cryptsetup** and
+ `/etc/crypttab` expect the passphrase files). The file must have an
+ access mode of 0600 or less.
+
+`Checksum=`, `--checksum=`
+: Generate a `