Configure grub with Ubuntu Core 20

Hey All,

I’m currently experimenting with Ubuntu Core and wanted to port my existing 18 image to 20. No I’m struggling with the grub configuration.

I need to add something to the kernel boot cmdline. With core18 I had the grub.cfg to do this. With core20 the grub.cfg is gone:

grub: boot configuration is shipped and managed by snapd

Unfortunately I’m unable to find any documentation on that topic? Hope someone can give me a hint.

Thanks, and btw: is this the right place to ask about Ubuntu Core? If so, maybe add a category?

I moved your post to the devices category which is for UbuntuCore related questions…


Hi, unfortunately we are a bit behind implementing this feature for UC20, because the kernel command line is sealed against in the TPM for amd64, and so currently we store the kernel command line inside snapd and it is not changeable specifically for amd64 when using encryption. Snapd generates the grub.cfg that used to exist in the gadget snap to enforce that this is used.

We are aiming to soon enable the gadget snap to specify additional kernel cmdline arguments through a structured manner, but that feature is not yet implemented.

As a workaround, if you are not using encryption, you can manually edit the grub.cfg files on the ubuntu-seed and ubuntu-boot partitions after the system has finished installing (i.e. after you run console-conf). You could also do this with encryption enabled, but then the device would not be able to finish booting because it wouldn’t be able to unlock the encrypted data partition from the initramfs.

1 Like


Thank you for the explanation. In this case, I guess I will wait for the release of this feature.

@ijohnson I also find myself in need of this feature because UC20’s default cmdline value for grub.cfg specifies “console=ttyS0”, which interferes with a connected serial device.

  1. Is the interface you mentioned available at this point?
  2. When describing the interface, you specifically mentioned it’d allow one to “specify additional kernel cmdline arguments” (emphasis mine). As noted above, I’m looking to remove console=ttyS0 from the default value of cmdline. Would that be possible through this interface?

Once the feature is available, the gadget snap will be able to ship a file which provides arguments that shall be either appended to the command line or override it (with the exception some arguments set by snapd that are used during boot).

instead of adding more and more to the gadget, which forces people into re-builds, should we not perhaps focus on extending model assertions with setting of default configurations and interface connections to prevent users from rolling custom gadgets for minor config/connection adjustments ?

Not sure about connections, the original question was about kernel command lines. We did not mention this will be behind an interface.

Anyways, connections and model assertions sounds like material for a separate topic with more people involved.

no, it will be a defaults: entry which forces you to have your own gadget.yaml.

i mentioned connections: simply because they are in the same boat … both are minor adjustments most/many users need for their images and both force a custom gadget making things harder than they should be (IMHO)

PS: but i agree it should be its own topic …

My original issue was btw solved, when I realized that “console=ttyS0” is specified by default. Still, I would prefer to have the possibility to change the baud rate.
For such a simple change, I would expect it should not be necessary to build a custom gadget snap. But I think ether way will work fine.

Well customizing the kernel command line is something that definitely should be forcing a custom gadget snap, since you can have radically different behavior for the same set of snaps with new kernel command lines, so we don’t want to say that the Canonical pi gadget and Canonical pi-kernel snaps are fully supported with any random kernel command line that folks put in their model assertion, they are specifically supported with the kernel command line that we have tested them with. This same line of reasoning also arguably applies to connections and defaults in that you can make radical changes to a system through those changes that may not be fully tested or supported.

I agree we should make it easier to do these things, but at the same time we need to be careful to ensure that we are not making a false assertion of support by enabling folks to use the upstream kernel/gadget snaps in a way that we can’t support.


Hello, I probably also need this file, I want to disable some mitigations with Ubuntu Core (emulated with kvm-qemu) and I can’t find /etc/default/grub or this file commented on in the post, I accept also another way to solve this problem if know , can only see this mode to disable

the above discussed gadget option has landed by now, you need to modify the source code of a forked gadget snap according to:

then build the gadget snap and build your own image with that gadget snap added via the --snap option of ubuntu-image

Oh thank you, didn’t know this option. About that still, a question, I’m using kvm-qemu (following the test on QEMU), with this gadget modification, I need to change and create a new image and then use it with Qemu or this file goes somewhere for the use of the already created?

you need to create a new gadget and then a new image with this gadget … then use that new image with qemu

Ok, got it, thanks :slight_smile:

@ogra, one help, i try use pc-amd64-gadget and when used snapcraft is return “launch failed: Available disk (995323904 bytes) below minimum for this image (2361393152 bytes)”, where can define this size, for working?

can you post a full log ? it is hard to tell where exactly that message comes from …

Ok, Is just this or do you need something? Clone of

this looks actually like an issue with multipass, not with snapcraft or even the snap code … try a snapcraft clean and check your actual physical disk space too