Skip to content

Conversation

@davejbax
Copy link

Description

This PR creates a new image build method, repartition, which doesn't add much (or any, really) new functionality, but rather re-uses existing steps, effectively combining the new and resize methods.

This allows the user to, using a raw image file as a basis:

  • Overwrite the image's partition table with whatever content they define (via the existing image_partitions config)
  • Format newly created partitions with mkfs (the user chooses which partitions they want to format, as we don't know which ones are 'newly created' since we don't parse partition tables of existing images)
  • Resize the ext{2,3,4} filesystems of resized partitions with resize2fs

This is something that was especially useful in my particular use-case, but I think it could be useful more widely as well, hence this PR :)

Use-cases

  • Grow/shrink a partition in an existing image
  • Create new partitions at the end of the image file
    • Swap partition
    • Separate /home partition
  • Destroy an unwanted partition in an existing image

Backwards compatibility

I've tried to make this change entirely backwards-compatible, so that no existing builds will be affected by it.

To do this:

  • skip_mkfs defaults to false, and hence the Mkfs step behaviour is unchanged (it's only currently used with the new method, as far as I can tell, in which case we shouldn't be skipping it by default for any partitions)
  • resize_fs only has an effect when using the repartition method, and hence the behaviour of the resize step should be unchanged

Currently, the 'new' method can be used to effectively manage partitions
in an image when the source image does not have the desired layout.
However, it relies on a root filesystem archive, which is not available
in all cases (e.g. Ubuntu does not publish Raspberry Pi rootfs
archives).

The 'repartition' method allows for taking an existing image and
changing its partitions. That is, partitions may be arbitrarily created,
grown, shrunk, or destroyed: this is done according to the partition
layout we give in the image config.

This adds two new options to partition configuration:

* `resize_fs`: Whether to run resize2fs on the partition after
  repartitioning. This is necessary because:
  - Not all partitions can be resized with resize2fs (e.g. NTFS)
  - Only the user knows whether or not a partition from the source image
    has been resized
* `skip_mkfs`: If true, the partition will **not** be formatted with
  mkfs in repartition mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant