|
| 1 | +# pxe-box |
| 2 | + |
| 3 | +Builds a tiny "iPXE on disk" Vagrant box — the cross-arch / cross-provider |
| 4 | +replacement for [`jtyr/pxe`][jtyr]. Each artifact is a ~64 MB virtual disk |
| 5 | +whose only contents are an EFI system partition with iPXE as the default |
| 6 | +loader (`\EFI\BOOT\BOOTX64.EFI` on amd64, `\EFI\BOOT\BOOTAA64.EFI` on arm64). |
| 7 | +At boot the firmware launches iPXE, which DHCPs and chains to whatever |
| 8 | +PXE/HTTP infrastructure is on the network — for the playground that's Smee. |
| 9 | + |
| 10 | +Targets produced: |
| 11 | + |
| 12 | +| provider | amd64 | arm64 | |
| 13 | +| ---------- | :---: | :---: | |
| 14 | +| virtualbox | ✅ | ✅ | |
| 15 | +| libvirt | ✅ | ✅ | |
| 16 | + |
| 17 | +Plus a top-level Vagrant Cloud-style `metadata.json` that resolves a single |
| 18 | +box name (default `tinkerbell/pxe`) to the right artifact based on the host's |
| 19 | +provider and architecture. |
| 20 | + |
| 21 | +## Build |
| 22 | + |
| 23 | +Host requirements (macOS): `brew install dosfstools mtools qemu coreutils gptfdisk`. |
| 24 | +Linux distros generally ship these. No VirtualBox installation is required |
| 25 | +on the build host — `qemu-img` produces the VDI directly, so a single |
| 26 | +`linux/amd64` runner can build every `(provider x architecture)` combination. |
| 27 | + |
| 28 | +```sh |
| 29 | +make # build everything into ./out |
| 30 | +make ARCHES=arm64 vbox # subset |
| 31 | +make BASE_URL=https://example.com/pxe metadata |
| 32 | +``` |
| 33 | + |
| 34 | +Output: |
| 35 | + |
| 36 | +``` |
| 37 | +out/ |
| 38 | +├── disk-amd64.img |
| 39 | +├── disk-arm64.img |
| 40 | +├── pxe-amd64-virtualbox.box |
| 41 | +├── pxe-arm64-virtualbox.box |
| 42 | +├── pxe-amd64-libvirt.box |
| 43 | +├── pxe-arm64-libvirt.box |
| 44 | +└── metadata.json |
| 45 | +``` |
| 46 | + |
| 47 | +## Local-only use (no server) |
| 48 | + |
| 49 | +You don't need to host the boxes anywhere. Build, then `vagrant box add` the |
| 50 | +single artifact you need by direct file path. The box name is whatever you |
| 51 | +pick at `add` time: |
| 52 | + |
| 53 | +```sh |
| 54 | +# 1. Build (only the artifact you need is fine). |
| 55 | +make ARCHES=arm64 vbox # -> out/pxe-arm64-virtualbox.box |
| 56 | + |
| 57 | +# 2. Register it locally under a name of your choice. |
| 58 | +vagrant box add --provider virtualbox --architecture arm64 \ |
| 59 | + --name tinkerbell/pxe out/pxe-arm64-virtualbox.box |
| 60 | + |
| 61 | +# 3. Reference it like any other box. No box_url, no metadata.json. |
| 62 | +# In a Vagrantfile: |
| 63 | +# config.vm.box = "tinkerbell/pxe" |
| 64 | +``` |
| 65 | + |
| 66 | +Repeat step 2 for additional `(provider, architecture)` combos as needed — |
| 67 | +Vagrant stores them under the same name and picks the right one based on the |
| 68 | +provider you use and the host's architecture. |
| 69 | + |
| 70 | +To remove or refresh a locally added box: |
| 71 | + |
| 72 | +```sh |
| 73 | +vagrant box list |
| 74 | +vagrant box remove tinkerbell/pxe --provider virtualbox --architecture arm64 |
| 75 | +``` |
| 76 | + |
| 77 | +## Publish (optional, multi-user setup) |
| 78 | + |
| 79 | +If you want one Vagrantfile to resolve to the right artifact for any |
| 80 | +contributor automatically, upload the four `.box` files and `metadata.json` |
| 81 | +to a static host (S3, GCS, GitHub Releases, ghcr.io OCI artifacts, anywhere |
| 82 | +with HTTP). The `url` fields in `metadata.json` must resolve to the box |
| 83 | +files. |
| 84 | + |
| 85 | +In a `Vagrantfile`: |
| 86 | + |
| 87 | +```ruby |
| 88 | +config.vm.box = "tinkerbell/pxe" |
| 89 | +config.vm.box_url = "https://your-host/path/metadata.json" |
| 90 | +``` |
| 91 | + |
| 92 | +Vagrant picks the right `(provider, architecture)` automatically. |
| 93 | + |
| 94 | +## Caveats |
| 95 | + |
| 96 | +- The OVF template in `templates/box.ovf.tmpl` targets VirtualBox 7.1+. |
| 97 | + If a future VBox release rejects it, regenerate by exporting a working |
| 98 | + VM (`VBoxManage export <vm> -o ref.ovf`) and copying the structure back. |
| 99 | +- `qemu-img convert -O vdi` produces a sparse VDI from the 64 MB raw; the |
| 100 | + resulting `.box` is a few MB compressed. |
| 101 | +- The arm64 box requires a host able to run arm64 VirtualBox VMs (Apple |
| 102 | + Silicon with VirtualBox ≥ 7.1). |
| 103 | + |
| 104 | +[jtyr]: https://app.vagrantup.com/jtyr/boxes/pxe |
0 commit comments