# Proxmox host comparison: working vs new

Quick reference from comparing **working** (10.130.60.224) and **new** (100.106.128.36) Proxmox hosts.

## Same on both

| Item | Status |
|------|--------|
| `/opt/cm4-provisioning/env` | Same (GOLDEN_IMAGE, RPIBOOT_DIR, EMMC_SIZE_BYTES=8589934592, SHRINK_BACKUP, etc.) |
| `/etc/cm4-provisioning/enabled` | Present (provisioning enabled) |
| udev rules `89-cm4-boot-mode-permissions.rules` | Same (MODE="0666" for 2b8e, 0a5c:2711) |
| udev rules `90-cm4-boot-mode.rules` | Same (trigger cm4-flash-trigger.sh on add) |
| `/usr/local/bin/cm4-flash-trigger.sh` | Same (starts cm4-flash.service) |
| `cm4-flash.service` | Same (ExecStartPre=sleep 5, TimeoutStartSec=7200) |
| `cm4-build-cloudinit.path`, `cm4-shrink.path` + services | Same |
| `build-cloudinit-image.sh`, `run-shrink-on-host.sh`, `fix-gadget-bootcode-on-host.sh` | Same (md5 match) |

## Differences

### 1. `/opt/usbboot/mass-storage-gadget64/bootcode4.bin` — **fixed**

- **Working:** Present (105984 bytes). rpiboot needs this or it prints "No 'bootcode' files found".
- **New:** Was missing; fixed by copying from working host. Verify: `ls -la /opt/usbboot/mass-storage-gadget64/bootcode4.bin` on new.

### 2. `/opt/cm4-provisioning/flash-emmc-on-connect.sh`

- **Working:** Older version (14421 bytes, md5 `dbac0bc2...`).
- **New:** Newer version (15449 bytes, md5 `6081bda7...`) with longer device wait (60s/90s), relaxed size check (50–120%), and extra diagnostics on "No suitable block device".

**Recommendation:** Copy the repo script to the **working** host so both use the same version:

```bash
scp emmc-provisioning/host/flash-emmc-on-connect.sh root@10.130.60.224:/opt/cm4-provisioning/
```

### 3. `/var/lib/cm4-provisioning/golden.img`

- **Working:** Present (symlink to a backup image). Required for **Deploy** (writing image to device).
- **New:** Missing. Backup works; Deploy will show "Golden image not found" until you set one (dashboard “Set as golden” or `scp` an image to the host as `golden.img`).

### 4. `/opt/cm4-provisioning/dashboard/` (host only)

- **Working:** Directory exists (owner 1000:1000). Dashboard normally runs in the **LXC**, so this may be leftover or unused on the host.
- **New:** No dashboard dir on host. No action needed unless you run the dashboard on the host.

### 5. Extra files in `/var/lib/cm4-provisioning/` on working

- **Working:** `build_cloudinit_status.json`, `cloudinit_templates.json`, `first_boot_status.json` (written by dashboard/LXC when using cloud-init build).
- **New:** Not present yet. They appear when you use the dashboard from the LXC; not required for flash/backup.

## Checklist for new host (100.106.128.36)

- [x] `bootcode4.bin` in `/opt/usbboot/mass-storage-gadget64/` (copied from working)
- [x] Same udev rules, trigger, and systemd units
- [x] Same env. `EMMC_SIZE_BYTES` is optional; device detection is dynamic (any new block device after rpiboot is accepted for 8/16/32 GB CM4).
- [ ] Set `golden.img` for Deploy (copy image or use dashboard “Set as golden” from a backup)
- [x] `flash-emmc-on-connect.sh` is the updated version (longer wait, diagnostics)

## If flash still fails on new host

1. Check flash.log: `ssh root@100.106.128.36 'tail -80 /var/lib/cm4-provisioning/flash.log'` — the script now logs "Current block devices" and sizes when no device is found.
2. Ensure eMMC disable jumper is set and you use the USB slave port; unplug and replug.
3. Optional: increase udev/systemd delay (e.g. `ExecStartPre=/bin/sleep 10` in `cm4-flash.service`) if the device is slow to enumerate.
