Files in this folder will be compiled by chromeos-base/chromeos-installer
package into few programs, including:
chromeos-install
: A shell script for manual installation from USB.chromeos-recovery
: The main command for recovery shim to install image.chromeos-postinst
: The script executed by auto update or recovery shim after image installation is completed, being the symbolic link of/postinst
.cros_installer
: A program meant to be the backend of above commands (but it currently only supports post-install).
When installing manually from USB or from recovery shim, the procedure is:
chromeos-install
is invoked by either manually orchromeos-recovery
.- The script will re-create partition table on target storage device.
- The script will clone all partitions (stateful, rootfs, kernel, OEM, etc...).
- Start post-install (see below) from
/postinst
of new rootfs.
Auto update (via update_engine
) is slightly different. After the payload is
downloaded, update_engine
will try to apply the payload (may be full or
partial), then invoke the post-install from new rootfs.
After the new image is written to disk storage, there may be several steps to
activate the new partition. This is done by cros_installer
as:
- Rebuild 'verity' information. To reduce download size, the payload from auto update won't include verity hash data because that can be re-constructed. In this step the post-install program will read, verify, and regenerate hash data for the rootfs partition.
- Update GPT entries to set proper boot priorities on the new kernel partition.
- For legacy systems, update EFI or
syslinux
entries. - Run a per-board post install script
/usr/sbin/board-postinst
if it exists. The script is usually installed bychromeos-base/chromeos-bsp-$BOARD
orchromeos-base/chromeos-firmware-$BOARD
in board overlays. - Apply firmware update by running
/usr/sbin/chromeos-firmwareupdate --mode=autoupdate
if the signing signature (/root/.force_update_firmware
) is available. The special signature is needed to prevent unexpected firmware updates from self-built USB images. - Apply Cr50 firmware updates if available (error will be ignored).
- Any other misc housekeeping work. Consult
ChromeosChrootPostinst
for further details.
To make sure the new kernel and rootfs is bootable, the GPT boot priority may be set with few "try" attempts so the system will revert to the old partition when running out of "tries".
If the new kernel and rootfs boots, the update_engine
will wait for 60 seconds
and then:
- Invoke
chromeos-setgoodkernel
, to update partition records and mark current kernel as "good" for future reboots. - Invoke
chromeos-setgoodfirmware
to mark active firmware as "good" as well. At the end ofchromeos-setgoodfirmware
, it will also invoke/usr/sbin/board-setgoodfirmware
for board specific configuration if available. Theboard-setgoodfirmware
is usually provided bychromeos-base/chromeos-firmware-$BOARD
package.
In summary, if you want to add some board specific task:
- To run on every boot, do it in
/usr/sbin/board-setgoodfirmware
. - To run only after each AU or recovery, do it in
/usr/sbin/board-postinst
.