Installation process

The Ubuntu Core install image is composed from the kernel, gadget, base, snapd and app snaps (see Snaps in Ubuntu Core for further details. The resultant image typically contains the following:

Any device booting an Ubuntu Core 20 installation image will create or use the partitions defined by its Storage layout and proceed through the following installation steps.

The first three (1-3) are also described in the recovery mode boot process:

  1. Boot through the bootloader, its assets, and boot configuration in ubuntu-seed.
  2. Bootloader loads the kernel from a designated recovery system.
  3. Kernel initialises the system and runs the snaps from that system in install mode. At this point, the system is running from tmpfs in an ephemeral state with all snaps from the recovery system model marked for use in install mode (as indicated by the modes field values), including the snapd snap, the gadget snap, the kernel snap and the base snap (usually the core20 snap).
  4. The snapd snap proceeds to install the actual run mode system by:
    • creating all missing partitions.
    • (optionally) encrypting ubuntu-data and ubuntu-save if supported and not disabled.
    • sealing the disk keys through hardware support.
    • setting up the run system in ubuntu-data.
    • setting boot configuration and the run mode kernel in ubuntu-boot for run mode.
  5. snapd proceeds to reboot into run mode.
  6. From run mode, snapd bootstraps itself and proceeds to seeding, installing and activating all the snaps marked for run mode use in the recovery system.

The install-device hook

A gadget can optionally define an install-device hook . This is invoked from install mode before rebooting into run mode, between steps 4 and 5 above. All partitions are created and mounted when the install-device hook runs.

The install-device hook is executed with a fresh installation (rather than during a potential factory reset, for example), and can be used to perform early hardware and firmware configuration.

If applicable, precautions should be taken to ensure that any sensitive configuration is idempotent and/or only done once for the lifetime of the device.

The install-device hook can also stop the subsequent reboot from booting into run mode (step 5, above) with the snapctl reboot command and either --halt or --poweroff arguments:

snapctl reboot --halt|--poweroff

Either reboot command will only take effect after the hook has finished.

Factory image hint

A UC20 image can be built to include a hint that an image is intended to be used, or first booted, in the device factory. This hint can then be used to govern whether factory-only resources are accessible, for instance, but no security-related decisions should be made based solely on its inclusion as it could be possible for the hint to be set again in the field.

The factory image hint is set by adding --factory-image to the ubuntu-image command when building the UC20 image:

ubuntu-image snap my-model.model --factory-image

See Building the image for details on how images are built.

The factory image hint is cleared directly before rebooting into run mode (step 5, above).

For the current boot, the state of the factory image hint can be viewed by invoking snapctl system-mode and checking whether factory: true is included in its YAML output. See The snapctl tool for more information.

Last updated 6 days ago. Help improve this document in the forum.