How to Preseed Ubuntu Core Images

From my understanding “preseed” is a concept brought into Ubuntu Core for Ubuntu Server and Desktop where the install of the OS could be automated.

The only documentation I was able to find about Ubuntu Core and Preseed is the following:

I want to do some prototyping and create two images with different unattended installation instructions. The instructions only show a command (below) that will allow signing a file and adding a “preseed” argument:

ubuntu-image snap --preseed --preseed-sign-key=<gpg-key-name> -i 8G --snap [...] <model-assertion>

In the instructions, it states that a seed file is located int the location below, but I cannot find it:


user@ubuntu:~$ ls /var/lib/snapd/see
ls: cannot access '/var/lib/snapd/see': No such file or directory
user@ubuntu:~$ ls /var/lib/snapd/se
seccomp/  sequence/ 
user@ubuntu:~$ ls /var/lib/snapd/s

I want to automate my Ubuntu Core installation with the following:

  • Specify the Ubuntu One user name:
  • Configure a APN for cellular internet connectivity

I want to get an example seed.yaml file that can be an example of how to do this.

Here are my questions:

  • Where can I find this seed.yaml file?
  • What are the keys and values I need to specify for this file?
  • How do I pass in the seed file path to the “ubuntu-image” command?

have you read the page you initially linked above ? preseeding means something completely different in this context …

it is essentially there to speed up the initial seeding process of shipped snaps of an image so your first boot does not take too long …

Hmm… ok, so “preseeding” is completely different than what it means in Ubuntu Server or Ubuntu Core.

Where or how could I find out how to create a custom image with the Ubuntu One account or configure cellular APN?

you could create a “config snap” that utilizes network-control to set up networking … for the U1 account you can use a system-user assertion (i think there were plans to support pre-adding that assertion to the image but i can not find docs for it)…

i once created a snap that does create a user (not a U1 one though, just an actual local account) and network config as example (not sure it still works but it might give you some ideas), see:

@ogra I was looking at what the /etc/netplan directory looks like on the Ubuntu Core system I deployed and it has the following:

user1-company@ubuntu:~$ ls -lash /etc/netplan/
total 24K
4.0K drwxr-xr-x  2 root root 4.0K Jun  6 16:35 .
   0 drwxr-xr-x 43 root root 1.6K May  3 17:46 ..
4.0K -rw-r--r--  1 root root   36 Jun  6 16:29 00-default-nm-renderer.yaml
4.0K -rw-r--r--  1 root root   36 Jun  6 14:31 00-default-nm-renderer.yaml.dist-console_conf
4.0K -rw-r--r--  1 root root  118 Jun  6 14:32 00-snapd-config.yaml
4.0K -rw-r--r--  1 root root  713 Jun  6 16:29 90-NM-046ea52b-2a1a-3fe1-8c0a-db0a4c92779b.yaml
4.0K -rw-r--r--  1 root root  520 Jun  6 16:35 90-NM-98fe2991-f213-480c-999a-788fe632a8a0.yaml
user1-company@ubuntu:~$ cat /etc/netplan/00-default-nm-renderer.yaml
  renderer: NetworkManager
user1-company@ubuntu:~$ cat /etc/netplan/00-default-nm-renderer.yaml.dist-console_conf
  renderer: NetworkManager
user1-company@ubuntu:~$ cat /etc/netplan/00-snapd-config.yaml
# This is the network config written by 'console-conf'
      dhcp4: true
  version: 2
user1-company@ubuntu:~$ cat /etc/netplan/90-NM-046ea52b-2a1a-3fe1-8c0a-db0a4c92779b.yaml
  version: 2
      renderer: NetworkManager
        name: "eno1"
      dhcp4: true
      dhcp6: true
      ipv6-address-generation: "stable-privacy"
      wakeonlan: true
        uuid: "046ea52b-2a1a-3fe1-8c0a-db0a4c92779b"
        name: "Wired connection 1"
          connection.autoconnect-priority: "-999"
          connection.permissions: ""
          connection.timestamp: "1686068943"
          ethernet.mac-address-blacklist: ""
          ipv4.dns-search: ""
          ipv6.dns-search: ""
          ipv6.ip6-privacy: "-1"
          proxy._: ""
          .nmmeta.nm-generated: "true"
user1-company@ubuntu:~$ cat /etc/netplan/90-NM-98fe2991-f213-480c-999a-788fe632a8a0.yaml
  version: 2
      renderer: NetworkManager
        name: "cdc-wdm0"
      dhcp4: true
      dhcp6: true
      ipv6-address-generation: "stable-privacy"
      apn: "super"
        uuid: "98fe2991-f213-480c-999a-788fe632a8a0"
        name: "Twilio"
          connection.permissions: ""
          ipv4.dns-search: ""
          ipv6.dns-search: ""
          ipv6.ip6-privacy: "-1"
          proxy._: ""

Would it matter if I just left the name of the file as “netplan.yaml” or do I specifically have to follow the nomenclature: XX-YY-UUID.yaml

Do I need to use a Ubuntu specific library to generate a UUID?

@ogra I am getting an error with adding this config-snap to my image, can you help?

kris@pop-dev-se30:~/uc-image$ ubuntu-image snap my-model.model --snap /home/kris/uc-config-snap/config-snap/config-snap_0.1_amd64.snap
[0] make_temporary_directories
[1] determine_output_directory
[2] prepare_image
Error: Error preparing image: cannot override channels, add devmode snaps, local snaps, or extra snaps with a model of grade higher than dangerous

@ogra I got it to build the image by changing grade to dangerous in my-model.json. I programmed the image and the installer fails. It is stuck in a loop. This is the error that is being shown:

/usr/share/subiquity/console-conf-wrapper: line 32: snap: command not found
Press enter to configure

The only thing I changed was adding the config-snap and it is causing an issue. Did you actually try this or verify it?

Yes, i tested it in a grade dangerous UC18 image years ago (with a gadget with the necessary auto-connections) , but it is really only meant as code example and should definitely be forward ported to the matching base snap before including it in an image…

it also assumes no network-manager snap but solely netplan (a non network-manager image has only one file in the /etc/netplan dir) for a network-manager based install the networking bit will be more complex …

@ogra I need to think about what you mean about porting it from UC18 to UC20. At the moment, I just changed the base in snapcraft.yaml.

Can I also set defaults of Ubiquity installer using this method?

@ogra this isn’t working.

  1. Build the config-snap using:
sudo snapcraft --use-lxd
  1. Signed the new model
snap sign -k my-models my-model.json > my-model.model
  1. Built the new image:
ubuntu-image snap my-model.model --snap /home/kris/uc-config-snap/config-snap/config-snap_0.1_amd64.snap
  1. Boot up device with Ubuntu Desktop and write the image to the solid state drive.
  2. Ubuntu Core is stuck in a install loop.

What do I need to provide you to help get over this issue?

Is there no one out there that does unattended installs of Ubuntu Core and setting up cellular modem configuration? I would think this would be the #1 item to get going with Ubuntu Core.

@ogra when I install the snap after I get Ubuntu Core up and running, here is the message I get:

zzz@ubuntu:~$ sudo snap install config-snap_0.1_amd64.snap --dangerous
error: cannot perform the following tasks:
- Run configure hook of "config-snap" snap if present (run hook "configure": 
cp: cannot create regular file '/etc/netplan/90-NM-d0864711-fd1c-4c30-994c-2bc8a2098670.yaml': Permission denied
Failed to open connection to "system" message bus: Failed to connect to socket /var/run/dbus/system_bus_socket: Permission denied

There has got to be a better way to do this initial modem & internet configuration. It seem like an after thought.

It should work fine if the interfaces are getting properly connected… either from the brand store UI or via connections: entries in the gadget.yaml…