Add install-flex-emmc.sh for a proper ChromeOS Flex install on eMMC

The earlier raw dd of the Flex recovery image left the installer layout
(2MB ROOT-B placeholder, fixed 6GB STATE), so Flex booted as live media
and couldn't A/B update. The script runs the image's own chromeos-install
against the eMMC from neon, chrooted into the image in a private mount
namespace with all other disks masked. Handles the cros_efi cmdline
requirement, udisks auto-mount interference, and unreliable exit status.
Tested end to end on hp-chell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ergosteur
2026-09-27 12:20:08 -04:00
co-authored by Claude Opus 5.5
parent 9c3b8e48ee
commit 93f4eca05c
2 changed files with 210 additions and 3 deletions
+30 -3
View File
@@ -138,13 +138,40 @@ sudo sh -c 'unzip -p "<path to .zip>" <path to .bin inside the zip> \
| dd of=/dev/mmcblk0 bs=4M status=progress conv=fsync'
```
Unzipped image is ~8.9GB; eMMC is 29GB, plenty of room (ChromeOS auto-
expands the stateful partition to fill the rest on first real boot).
eMMC write speed degraded over the transfer (~130MB/s at the start down
Unzipped image is ~8.9GB; eMMC is 29GB. (Original note here claimed
ChromeOS auto-expands the stateful partition on first boot — **wrong**,
see the 2026-09-27 reinstall below.) eMMC write speed degraded over the transfer (~130MB/s at the start down
to ~9MB/s by the end, total ~18 min for 8.9GB) — looks like the eMMC's
SLC write cache exhausting partway through; expected/normal for eMMC of
this class, not a fault.
**2026-09-27: reinstalled properly with `install-flex-emmc.sh`.** The
raw `dd` above left the *installer* image layout: ROOT-B a 2MB
placeholder, STATE a fixed 6GB, ~20.7GB unallocated. Flex's
`/usr/sbin/is_running_from_installer` compares ROOT-A/ROOT-B sizes, so
it booted as live media ("Install ChromeOS Flex / Try it first") and
couldn't do A/B updates. There is no flag to flip; the fix is running
the image's own `chromeos-install` (what the Install button runs)
against the eMMC. `install-flex-emmc.sh` (in this repo) does that from
neon: loop-attaches the `.bin`, chroots into its ROOT-A inside a private
mount namespace with every other disk (incl. neon's `sda`) masked by
`/dev/null`, and runs `chromeos-install --dst /dev/mmcblk0
--payload_image ... --target_bios efi`. Gotchas it handles:
- `chromeos_postinst` needs a `cros_efi` flag on the kernel cmdline;
faked via a bind over `/proc/cmdline`, plus a wrapper on the image's
`chroot` because postinst re-chroots with a non-recursive `/proc` bind.
- Plasma/udisks auto-mounts new eMMC partitions mid-install, making
`sfdisk` refuse a busy disk — a temporary `UDISKS_IGNORE` udev rule
in `/run/udev/rules.d` prevents it.
- `chromeos-install` can exit 0 on failure and logs harmless `ERROR`
lines on success — judge by its final `Installation to ... complete.`
line. Log: `/var/log/flex-install.log`.
- Whole run is only ~2.5 min (partitions copied at eMMC speed).
Result: ROOT-A/ROOT-B 4GB each, STATE 20.6GB (fills disk), KERN-A
`successful=1`. The ESP is copied from the image so its FS UUID stays
`CBE4-703E` (script still re-points `40_custom` in case it changes);
UEFI boot entries/order untouched.
**Boot selection** — both OSes are reachable two ways:
1. **From GRUB** (neon's own boot menu, visible for 5s per
`GRUB_TIMEOUT`): a custom entry "ChromeOS Flex (internal eMMC)" was