The kernel snap

The kernel snap is responsible for providing the Linux kernel image and modules for the system. The kernel snap to be used is defined in the device’s model assertion, which is produced and signed by the Brand authority.

Canonical publishes some reference kernel snaps as well as kernel snaps for main Canonical models such as official Ubuntu Core VMs on various certified public clouds, as well as general purpose computing images for popular physical devices such as the 64-bit x86 PC and Raspberry Pi.

For details on building a kernel snap, see Build a kernel snap in the Ubuntu Core documentation.

Setup files

In addition to traditional snap metadata, the kernel snap also holds some setup files fundamental to the initialization and lifecycle of the device.

The layout for a kernel snap has some variation, but usually follows:

  • meta/snap.yaml - Traditional snap details, with type: kernel explicitly defined

  • meta/kernel.yaml - Optional kernel-specific metadata defining kernel-provided assets

  • snapd-info - Information about the snapd packaged in the initrd

  • modules/<version>/ - Kernel modules; version must match the one in snap.yaml

  • firmware/ - Optional firmware files

  • dtbs/ - Optional binary device-tree files, if gadget.yaml states device-tree-origin: kernel

  • kernel - The actual kernel image

  • initrd - The initrd image

The kernel and initrd may be discrete objects, usually named kernel.img and initrd.img, respectively. However, they could also be distributed as a single Unified Kernel Image (UKI) or as a Flatted Image Tree (FIT) image. These are usually named kernel.efi or kernel.img, respectively.

kernel.yaml

The kernel.yaml provides information used by snapd to determine kernel-specific asset information. Primarily, this is about device trees and kernel modules. The standard format is:

dynamic-modules: $SNAP_DATA
assets:
  dtbs:
    update: true
    content:
      - dtbs/
  • dynamic-modules points to a folder which contains modules/ and firmware/ directories, usually created by a kernel component.

  • assets details a list of content the kernel snap provides, usually device tree files, to the gadget snap. These are then citable in the gadget snap’s gadget.yaml like so:

volumes:
  platform:
    schema: gpt
    bootloader: grub
    structure:
      - name: ubuntu-seed
        role: system-seed
        filesystem: vfat
        type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
        size: 800M
        offset: 8M
        content:
          - source: $kernel:dtbs/dtbs/
            target: /dtbs/