Creating an ubuntu core image with custom gadget snap

Hey guys,

I was hoping to get a little direction on my current situation. I am trying to use a model assertion along with the ubuntu-image snap to build a signed image for an amd64 device. Using the command “ubuntu-image snap example.model” I get the warning “WARNING: rootfs structure size 1.17 GiB smaller than actual rootfs contents 1.32 GiB”. Attempting to run the generated image results in an error similar to the warning above. After doing a little research, I think I need to modify the gadget snap I’m using to increase the system-seed/ubuntu-seed to 1400M. I used this guide and this gadget snap as my base. I was successful in compiling the gadget snap, but I am unable to figure out how to include it with my model assertion. Is there a command to generate a unsigned model assertion from the json representation and include the local compiled gadget snap?

look at the --snap option of ubuntu-image that allows you to point to a local snap file …

I tried that before posting. Is there a command to generate a model assertion from the json representation with a grade of dangerous? Would I still make an entry under that snaps property for the local gadget?

as long as the gadget is named the same as the one from the store it will simply override the one from the store when --snap is used, you should not need to change anything with your model (if it is already set to dangerous)

If you put "grade": "dangerous", in your model json, it’ll be included in the signed model definition. You can then use an unpublished gadget snap (i.e. no "id" or "default-channel" for its listing in "snaps").

If you just want to do a quick and dirty test, you could do the following:

  1. Use snap download to download a copy of the gadget you were using.
  2. Unpack it with unsquashfs.
  3. Edit squashfs-root/gadget.yaml to adjust the size of the ubuntu-seed partition as needed.
  4. Pack the gadget again with snap pack squashfs-root.
  5. When building your grade: dangerous image with ubuntu-image, point it at your modified snap with the --snap argument.
1 Like