Boot failure with modified kernel (x1)

I am trying to load a Ubuntu Core image with a modified kernel.

Boot fails with:
error: file `/system-data/var/lib/snapd/snaps/1000kernel_x1.snap’ not found.
error: no server is specified.
error: you need to load the kernel first.

Press any key to continue…

When I unzip my img file on the build machine I see following:

system-data\var\lib\snapd\snaps
image
image

My system-data\var\lib\snapd\seed\snaps looks like this:
image

well, for whatever reason the name of your snap seems to be 1000kernel_x1.snap (just to state the obvious :slight_smile: )

Typo. Please read as 1000kernel_x1.snap in all the text and snapshots that I have posted.

Is this an amd64 device you’re booting? If so, what’s in your grubenv, and also what’s the contents of the seed.yaml?

Following are the details when I load our store image with snaps from edge channel:

grubenv:

# GRUB Environment Block`
snap_kernel=1000kernel_5.snap
snap_mode=
snap_try_core=
snap_try_kernel=
snap_menuentry=MyDev
snap_core=core18_1705.snap
################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################# 

seed.yaml (kernel specific snippet):

- name: 1000kernel
  snap-id: <<Removed Intentionally>>
  channel: beta
  file: 1000kernel_5.snap

This is a Intel x86_64 Atom processor.

Thanks for that, note that you have in your grubenv

snap_kernel=1000kernel_5.snap

so grub should try to load 1000kernel_5.snap when it boots. While the kernel in your system appears to be 1000kernel_x1.snap. Did you try to install a new kernel snap on the device when it was booted?

The o/p that I gave was for your reference from a device that boots with our store image which is built by pulling all the snaps like gadget, kernel and others from the store and finally using ‘ubuntu-image’ command. Hence you see a different kernel name.

While my issue happens when I try to load an image that is built with modified kernel. After building the kernel snap, I rename the snap to 1000kernel_x1.snap and then do following (please note the - $ubuntu_image_extra_args):

sudo UBUNTU_STORE_ID=<<REMOVED>> UBUNTU_STORE_AUTH_DATA_FILENAME=store.auth ubuntu-image snap \
            --channel="$channel" \
            --cloud-init=cloud.config \
            -O "$(pwd)" \
            "$ubuntu_image_extra_args --snap 1000kernel_*.snap" \
            "$model".model

I am sure the grub related settings are modified accordingly during build process. But as of now I do not know how and where this happens in build process. I am trying to figure that out.

My seed.manifest for the kernel part looks like this: 1000kernel x1

What does your grub.cfg look like?

List env o/p:

grub> list_env
snap_mode=
snap_try_core=
snap_try_kernel=
snap_menuentry=<< REMOVED >>
snap_core=core18_1705.snap
snap_kernel=1000kernel_x1.snap
grub>

grub.cfg file

FS1:\EFI\ubuntu\> cat grub.cfg
    set default=0
    set timeout=3

    insmod part_gpt
    insmod ext2

    if [ -s $prefix/grubenv ]; then
      load_env
    fi

    # allow customizing the menu entry via grubenv
    if [ -z "$snap_menuentry" ]; then
        set snap_menuentry="Ubuntu Core 16"
    fi

    if [ "$snap_mode" = "try" ]; then
        # a new core or kernel got installed
        set snap_mode="trying"
        save_env snap_mode

        if [ x"$snap_try_core" != x"" ]; then
            set snap_core="$snap_try_core"
        fi
        if [ x"$snap_try_kernel" != x"" ]; then
            set snap_kernel="$snap_try_kernel"
        fi
    elif [ "$snap_mode" = "trying" ]; then
        # nothing cleared the "trying snap" so the boot failed
        # we clear the mode and boot normally
        set snap_mode=""
        save_env snap_mode
    fi

    set label="writable"
    set cmdline="root=LABEL=$label snap_core=$snap_core snap_kernel=$snap_kernel ro net.ifnames=0 init=/lib/systemd/systemd console=
    ttyS0 console=tty1 panic=-1"

    menuentry "$snap_menuentry" {
        search --label $label --set=writable
        loopback loop ($writable)/system-data/var/lib/snapd/snaps/$snap_kernel
        linux (loop)/kernel.img $cmdline console=ttyS0,9600 acpi_osi="Linux" tpm_tis.interrupts=0 tpm_tis.force=1
        initrd (loop)/initrd.img
    }

    FS1:\EFI\ubuntu\>