|
| 1 | +# Packer: Alpine 3.23 Minimal UEFI for XCP-ng |
| 2 | + |
| 3 | +Builds a minimal Alpine Linux 3.23.4 VM image (XVA, zstd-compressed) for use |
| 4 | +in xcp-ng-tests. The image is UEFI-booted, has the XCP-ng guest tools |
| 5 | +installed, and allows root SSH access using the xcp-ng CI public keys. |
| 6 | + |
| 7 | +## VM Specs |
| 8 | + |
| 9 | +| Property | Value | |
| 10 | +|-------------|------------------------------| |
| 11 | +| OS | Alpine Linux 3.23.4 (x86_64) | |
| 12 | +| vCPUs | 1 | |
| 13 | +| RAM | 256 MiB | |
| 14 | +| Disk | 512 MiB | |
| 15 | +| Boot | UEFI (grub + GPT) | |
| 16 | +| Network | DHCP (eth0) | |
| 17 | +| Format | XVA (zstd) | |
| 18 | +| Guest tools | xe-guest-utilities (apk) | |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +### On the machine running Packer |
| 23 | + |
| 24 | +- [Packer](https://developer.hashicorp.com/packer) (tested with v1.x) |
| 25 | +- The `xenserver-iso` builder plugin from |
| 26 | + [xenserver/packer-plugin-xenserver](https://github.com/xenserver/packer-plugin-xenserver) |
| 27 | +- Python 3 with `libarchive-c==5.3` (for zstd post-processing): |
| 28 | + |
| 29 | + ```sh |
| 30 | + pip install 'libarchive-c==5.3' |
| 31 | + ``` |
| 32 | + |
| 33 | +### On the XCP-ng host |
| 34 | + |
| 35 | +- An ISO SR where Packer can upload the Alpine ISO (the plugin uploads it |
| 36 | + automatically if you use `iso_url`) |
| 37 | +- A network accessible from the build machine; the default variable value is |
| 38 | + `Pool-wide network associated with eth0` — override with `network_name` if |
| 39 | + needed |
| 40 | + |
| 41 | +## Building |
| 42 | + |
| 43 | +```sh |
| 44 | +cd packer/ |
| 45 | +packer init alpine-3.23-uefi.pkr.hcl |
| 46 | +packer build \ |
| 47 | + -var xen_host=<XCP-ng IP or hostname> \ |
| 48 | + -var xen_password=<XCP-ng root password> \ |
| 49 | + alpine-3.23-uefi.pkr.hcl |
| 50 | +``` |
| 51 | + |
| 52 | +Optional overrides: |
| 53 | + |
| 54 | +```sh |
| 55 | + -var xen_username=root # default: root |
| 56 | + -var network_name="<name>" # default: Pool-wide network associated with eth0 |
| 57 | + -var root_password=<password> # temporary build password; default: packer |
| 58 | +``` |
| 59 | + |
| 60 | +The output XVA is written to: |
| 61 | + |
| 62 | +``` |
| 63 | +output-alpine-3.23-uefi/alpine-3.23-uefi.xva |
| 64 | +``` |
| 65 | + |
| 66 | +After the build the post-processor rewrites it in-place with zstd compression |
| 67 | +and sets the bridge to `xenbr0`. |
| 68 | + |
| 69 | +## Directory structure |
| 70 | + |
| 71 | +``` |
| 72 | +packer/ |
| 73 | +├── alpine-3.23-uefi.pkr.hcl # Packer build definition (HCL) |
| 74 | +├── http_files/ |
| 75 | +│ └── answers.txt # Alpine setup-alpine answerfile |
| 76 | +└── scripts/ |
| 77 | + └── cleanup.sh # Post-install cleanup run inside the VM |
| 78 | +``` |
| 79 | + |
| 80 | +## Notes |
| 81 | + |
| 82 | +- The Alpine guest tools ISO `install.sh` script does not support Alpine; |
| 83 | + `xe-guest-utilities` is installed from the Alpine community repository |
| 84 | + instead. |
| 85 | +- `ROOTSSHKEY` in `answers.txt` injects the xcp-ng CI public keys during |
| 86 | + installation, so no separate provisioner step is needed for SSH keys. |
| 87 | +- `USE_EFI=1` is passed on the kernel cmdline via `boot_command`; this makes |
| 88 | + `setup-disk` use grub and a GPT layout automatically. |
| 89 | +- Swap is disabled (`SWAP_SIZE=0`) to keep the image within 512 MiB. |
| 90 | + |
| 91 | +## Troubleshooting |
| 92 | + |
| 93 | +**Boot hangs / VNC never gets past the boot prompt** |
| 94 | +: Increase `boot_wait` in the JSON (default `10s`) and ensure VNC is |
| 95 | + reachable from the Packer host. |
| 96 | + |
| 97 | +**SSH timeout** |
| 98 | +: The install takes up to ~3 minutes on a busy host. Increase |
| 99 | + `ssh_wait_timeout` if needed. |
| 100 | + |
| 101 | +**Disk full during install** |
| 102 | +: If `setup-disk` fails due to space, the disk size can be bumped to 1024 MB |
| 103 | + by passing `-var disk_size=1024` — but note that the builder does not expose |
| 104 | + this directly; you would need to edit the JSON. |
| 105 | + |
| 106 | +**xva_bridge.py fails** |
| 107 | +: Ensure `libarchive-c==5.3` is installed. Other versions may not work due to |
| 108 | + internal API usage. |
0 commit comments