disk: grow root partition while re-layouting
Instead of growing the root partition in `CreatePartitionTable` do it as part of `updatePartitionStartPointOffsets`.
This commit is contained in:
parent
16ad1211c3
commit
b3c769ae02
2 changed files with 9 additions and 6 deletions
|
|
@ -316,6 +316,7 @@ func (pt *PartitionTable) GenerateUUIDs(rng *rand.Rand) {
|
|||
// Dynamically calculate and update the start point for each of the existing
|
||||
// partitions. Adjusts the overall size of image to either the supplied
|
||||
// value in `size` or to the sum of all partitions if that is lager.
|
||||
// Will grow the root partition if there is any empty space.
|
||||
// Returns the updated start point.
|
||||
func (pt *PartitionTable) updatePartitionStartPointOffsets(start, size uint64) uint64 {
|
||||
var rootIdx = -1
|
||||
|
|
@ -342,6 +343,13 @@ func (pt *PartitionTable) updatePartitionStartPointOffsets(start, size uint64) u
|
|||
pt.Size = size
|
||||
}
|
||||
|
||||
// If there is space left in the partition table, grow root
|
||||
root.Size = pt.BytesToSectors(pt.Size) - root.Start
|
||||
|
||||
// Finally we shrink the last partition, i.e. the root partition,
|
||||
// to leave space for the secondary GPT header.
|
||||
root.Size -= 100
|
||||
|
||||
return start
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue