Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --save-partlabel <glob> and --save-partindex <range> options, which save partition table metadata for existing data partitions and then restore those partitions after writing the image. --save-partlabel takes a glob pattern matching the partition label, and --save-partindex takes a partition number or range of partition numbers (possibly single-ended). For example, to save all partitions with indexes greater than 4, specify "--save-partindex 5-". The specified partitions need not exist. If no --save-* options are specified, no partitions are saved. Multiples of each option can be specified, and/or multiple filters can be specified within a single option argument by separating them with commas. There are corresponding kargs coreos.inst.save_partlabel and coreos.inst.save_partindex, which cannot be repeated but which accept comma-separated patterns. Upon restore, try to reuse the original partition number. If it's not available, renumber the partition to one more than the highest number used so far. For simplicity, never backfill entries earlier in the partition table, even if the corresponding slot is unused. If a saved partition overlaps with the image contents, fail. This can't be detected in advance, so detect the overrun during fetch and stop before the saved partition is clobbered. Also fail if the install image has a partition extending past the end of the image that overlaps with a saved partition. On any failure, after clearing the partition table, restore any saved partitions. In addition, augment partition-table clearing to clear the backup GPT, since some tools may otherwise hallucinate partitions that were overwritten during the install. All of this assumes GPT partitioning both in the image and on disk, so if --save-* options are specified for a DASD target, fail. Fixes coreos#190. Co-authored-by: Glenn West <gwest@redhat.com>
- Loading branch information