Fail to create GPT backup header when rootfs structure size smaller than actual rootfs contents

Bug #2045006 reported by ethan.hsieh
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Ubuntu Image
New
Undecided
Unassigned

Bug Description

Fail to create GPT backup header when rootfs structure size smaller than actual rootfs contents

Error message:
[8] populate_prepare_partitions
WARNING: rootfs structure size 750 MiB smaller than actual rootfs contents 1.63 GiB

Image built by ubuntu-image 2.x:
004: 000 0000002048 0002459647 0002457600 EFI System
005: 001 0002459648 0005874131 0003414484 writable

Image built by ubuntu-image 1.x:
004: 000 0000002048 0002459647 0002457600 EFI System
005: 001 0002459648 0005874131 0003414484 writable
006: ------- 0005874132 0005874165 0000000034 Unallocated

ubuntu-image 1.x can create GPT backup header even though rootfs structure size smaller than actual rootfs contents. But, the GPT backup header isn't generated when using ubuntu-image 2.x.

tags: added: originate-from-2043872
Revision history for this message
Paul Mars (upils) wrote :

Hey Ethan,

Actually I was not aware ubuntu-image 1.x was still used!

You probably already thought about that, but did you try ubuntu-image 3.X for this build? (maybe this is one of the builds using flash-kernel and you cannot use u-i 3 yet).

Since our current efforts are directed towards imagecraft, I doubt we will be able to invest time fixing ubuntu-image 2.X.

Anyway, an important thing to note in your gadget YAML where you define the structure of the image: The "size" key is more a "recommended/desired" value than a enforced one. This is handled by a snapd library so even with ubuntu-image 3.X you may encounter the same problem. But, recently a new "min-size" key was added in the VolumeStructure object, see [0]. I do not know for sure this could solve your problem, but using this and u-i 3.X could be worth a try.

[0] https://github.com/snapcore/snapd/blob/08888455fa5da4fe078b2d57234aec7f16d38d72/gadget/gadget.go#L279

Revision history for this message
ethan.hsieh (ethan.hsieh) wrote :

Hi Paul,

When CE team release images to customers, we release an image building guide as well. The image build guide will guide customers to set up a build env (VM) based on the version of images. If the image is uc18, the build env will be bionic (18.04) which has u-i 1.x installed.

CE released uc18 images to a customer. The u-i 1.x is used to build uc18 images. The customer would like to use a new feature "--validation=enforce" which u-i 2.x starts to support. Unfortunately, the image built by u-i 2.x doesn't has the GPT backup header. And, the system fails to boot without the GPT backup header.

There are two workarounds:
1. Update gadget.yaml to increase the partition size
2. Increase the image size by u-i parameter (--image-size)

I would like to confirm if the missing GPT backup header is expected when rootfs structure size smaller than actual rootfs contents. If it's an issue, I would expect that it can be fixed on u-i 3 and imagecraft. I haven't tried u-i 3.x. Will try it and get back to you.

Revision history for this message
ethan.hsieh (ethan.hsieh) wrote :

Hi Paul,

Tried u-i 3. The GPT backup header isn't created.

Image built by ubuntu-image 3:
004: 000 0000002048 0002459647 0002457600 EFI System
005: 001 0002459648 0005874095 0003414448 writable

As I know, "min-size" is used when size in new gadget is bigger than the one in old gadget. Snapd will check "size" in old/new gadgets when upgrading gadget. If sizes are different, system will fail to upgrade gadget.
ex:
old gadget: size: 1G
new gadget: size: 1.5G (need to increase the size because size of snaps in the image is increased)
When we set "min-size" to 1G, snapd will check both "min-size" and "size".

Revision history for this message
Emilio Lopez (lopezem) wrote :

Hi Ethan,

This issue still persists even with the --image-size parameter added. It will increase the image size but does not resize the rootfs partition. This was marked as fixed but hasn't addressed the issues

I made a comment about this in the following:

https://bugs.launchpad.net/ubuntu-image/+bug/2034926

https://bugs.launchpad.net/ubuntu-image/+bug/1981744

https://forum.snapcraft.io/t/uc20-image-based-on-reference-amd64-gadget-failing-to-install/21041/17?u=lopezem

Revision history for this message
Paul Mars (upils) wrote :

Hey Emilio,

ubuntu-image is affected by several issues regarding partitions handling and disk layout. We plan on investigate soon and we would like to improve the code quality of this make it more reliable.

Just to make sure though: what version of ubuntu-image did you use? Because since the initial issue was reported on discourse, ubuntu-image was completely re-wrote.

Revision history for this message
Emilio Lopez (lopezem) wrote :

Hi Paul,

This was found in the snap version of ubuntu-image v3.2.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.