Core20 image with "post-populate-rootfs" hook


So I’ve been trying to create a custom core20 image using ubuntu-image snap with a signed model assertion. The image creates without issue, but I would also like to be able to add a systemd service as default for the image.

Normally I’d use cloud-init but as Core20 does not support this I’m trying to use the ubuntu-image post-populate-rootfs hook.

In the directory where I have my signed model assertion I have a directory called “img-hook” which contains a shell script named post-populate-rootfs echoing lines into /etc/systemd/system/mything.service (also tried to use $UBUNTU_IMAGE_HOOK_ROOTFS/etc/systemd/system/).

Finally the image is created using ubuntu-image snap --hooks-directory ./img-hook All of which seems to work, it creates a image I can boot without issues but there is no sign of the service file anywhere in the resulting filesystem.

Anyone have any hints for working with the ubuntu-image hook?

1 Like

This sort of customization is no longer allowed with Ubuntu Core 20 images, can you specify why you need this systemd service to be put into the root filesystem instead of run as a snap service?

1 Like


Force of habbit I suppose, have started making a simple snap now. All that I’m trying to do is send an hourly “I live” message with some basic metrics from the snap (a raspberry pi IoT signage device) to a log on the dashboard server (it’s an odd function but was requested so… you know).

ubuntu-image produced a message when I try using cloud-init, but not for the rootfs hook so thought it was still allowed.

Thank you so much for clearing that up.