Closed Villemoes closed 1 year ago
Looks good. I assume that in you use-case the partitions are relatively small?
For larger partitions BLKSECDISCARD or BLKZEROOUT might perform better.
Indeed. I have two, one of ~16K and another of ~4M. If I/we wanted to optimize this I think it's pretty well-localized where to do it; around the "/ Not a regular file, non-zero pattern, or fallocate not applicable. /" comment in write_bytes().
When bootstrapping, it can be useful to ensure that a partition has completely known contents, especially when the partition just contains raw binary data and not a filesystem.
When generating an image file, this is implicitly done already because the non-written parts of the partition(s) are implicitly zero-filled when the containing image file is extended to its final size.
But when using genimage to directly populate a block device, no such implicit zero-filling is done.
Add a "fill" boolean option, and use that to decide between passing the partition's size or the child image's size to insert_image().