notes

The program that makes the stick, file by file

Name: provisional, for the program the appendix describes. calef names files.

An appendix to notes/boot-stick.md. It holds the design detail behind the doc comments in crates/stick_maker, which link here.

The halves

The payload is embedded at build time

build.rs reads NIFE_STICK_PAYLOADS, a directory laid out the way the stick will be (EFI/BOOT/*.EFI). cargo xtask stick builds that directory and then points the variable at it. Every file under EFI/BOOT/ is embedded at its relative path. With the variable unset, the program builds with no boot files and refuses to write a stick, saying how to build one that has them. That keeps cargo build --workspace, cargo test and script/lint working with no environment. The loader's own build.rs uses the same arrangement.

Why a kernel and its archive cannot arrive mismatched

Each boot file is one UEFI application. It already contains its kernel and the userspace archive that kernel measures, and uefi_loader/build.rs refuses a pair whose archive the kernel does not vouch for. The only unit this program handles is that sealed file, so it cannot pair a kernel with the wrong archive. radon and xenon have both halted at MEASURED BOOT REFUSED on a mismatched pair that a person copied by hand. This program has no way to express that copy.

No stick shares a GUID with another

A prebuilt image written to every stick would give them all one disk GUID and one set of partition GUIDs. Firmware boot entries, PARTUUID lookups and installs would then be ambiguous when two copies meet one machine. Measured on 2026-10-06 (UTC), it does not happen here, for structural reasons:

The evidence is the erase path, run twice on two 64 MiB file-backed disks (hdiutil attach, dummy payloads, --include-disk-images --erase). Both came out MBR with LBA 1 all zeroes, so no EFI PART header. Each held one type 0x0b partition at sector 63. The FAT32 volume ids were 0x89f41902 and 0x3d471902. They differ, and that id is what Linux's /dev/disk/by-uuid and macOS name a FAT volume by.

Both MBR disk signatures were 0x00000000. So Linux gives every such stick's partition the same PARTUUID, 00000000-01, and a firmware boot entry that names the partition by MBR signature alone cannot tell two apart. diskutil has no option to set the signature. Writing one ourselves means opening the raw device, which needs root for a real stick, and the macOS path is built to need none. Linux's sfdisk draws a random signature for a new label: dos; that is libfdisk's behavior, read rather than run here.

Nothing in nife looks a disk up by GUID or MBR signature. uefi_loader's chooser finds its own disk by device-path prefix (uefi_loader/src/device_path.rs) and reads a table by type GUID.

macOS

diskutil is in every macOS install and is Apple's supported interface to Disk Arbitration from a script. The program shells out to it and reads its -plist output. The table diskutil prints by default is for people: its column widths move with the longest name, and its wording is not a contract.

plist.rs reads the XML itself rather than taking the plist crate. calef ruled it on 2026-10-20 (UTC), "Keep ours.", on milestone 784 (reuse what the tree wrote)'s item (f), under §46 (thin primitives or whole subsystems). The plist crate (1.10.1) would bring nine crates new to the tree, serde among them, to read a trusted local tool's output in a program that runs only on the host. The grammar diskutil emits is eight element types and five character entities, fully specified by Apple's DTD. Correctness is whether it reads what diskutil wrote, and the captured fixtures answer that.

The two USB hard disks and the disk image in the fixtures are real captures, with identifiers, names and sizes made neutral. The flash stick is synthesized, because no stick was attached when they were captured. diskutil eraseDisk has been run by this program only on file-backed disks (hdiutil attach), never on a physical stick; Apple documents the same command for both.

Linux

Every fact the offer rule needs is a file under /sys/block, readable without root:

Mounts come from /proc/self/mounts. A filesystem that is not mounted is named by udev's database in /run/udev/data, which is also readable without root. So listing needs no privileges and no tool; only erasing does. linux.rs takes the three roots as arguments, so its tests build a small fake sysfs rather than needing a Linux machine.

What has not been checked on Linux:

Windows

Windows names volumes by drive letter. GetDriveTypeW answers DRIVE_REMOVABLE from the same removable-media bit the other two hosts read. A USB hard disk answers DRIVE_FIXED, so the one rule in disk.rs refuses it with nothing Windows-specific. The five functions used are in kernel32, which every Windows process already links, so they are declared by hand rather than through a bindings crate (§46).

Erasing is not automated on Windows, by choice. A stick that is not FAT gets the diskpart steps printed, and the person confirms the disk to select by its size in list disk. Automating it needs the drive-letter-to-disk-number mapping (IOCTL_STORAGE_GET_DEVICE_NUMBER). Destructive code that has never run once on the host it targets is the one thing this program should not ship. Promote it when a Windows machine can run it against a VHD (diskpart's create vdisk), the host's file-backed disk.

FAT32 through format stops at 32 GB, which is Windows' own limit and not FAT32's. The printed steps therefore create a 1 GB partition, which the boot files fit in many times over.