Comment 6 for bug 1632085

Revision history for this message
Barry Warsaw (barry) wrote :

I want to be clear about one point: the size that this switch will control is the overall disk image size, not the size of any individual partition within the image. I.e. it's the size of the resulting file written to via the --output switch.

Thus all the discussion about fudge factors is off-topic, as those are applied to partition sizes. We will address those separately.

Here's how the image size is calculate (in prepare_filesystems()):

        self.image_size = ceil((self.rootfs_size + next_avail) /
                               1024 + 17) * 1024

I propose therefore to call the switch `--image-size` (no shortcut) which takes a value of the same format as the other size parameters in the gadget.yaml. A bare integer means bytes, and it accepts suffixes 'M' for MiB and 'G' for GiB.

Since u-i only handles single volume gadget.yamls atm, --image-size=10G would refer to the first and only image. In the future we can relax the "only" part, so that an unqualified value would refer to first volume. This would be equivalent to the (future) extended syntax --image-size=0:10G. Later we can accept multiple --image-size arguments, and/or a syntax such as --image-size=0:10G,1:1000M,2:1073741824

We'll check that --image-size is at least as big as the calculated size. I'd prefer to fail hard in that case, since it's generally easier to relax a constraint than to tighten it, but as Steve points out, that would throw away a lot of work and even though we support preserving the working directory, we don't currently have a way to resume after failure. So, if the --image-size is smaller than the calculated size, we'll warn and ignore it, going with the calculated size instead. That way, we'll preserve all of the work and won't generate a corrupted image.