Function mbr_part_type returns one of "primary", "extended" and "logical". The type is used by parted when adding partitions.
Signed-off-by: Hu Tao <[email protected]> --- resize/resize.ml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/resize/resize.ml b/resize/resize.ml index 2ffd26e..f57b2ff 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -50,6 +50,7 @@ type partition = { p_id : partition_id; (* Partition (MBR/GPT) ID. *) p_type : partition_content; (* Content type and content size. *) p_label : string option; (* Label/name. *) + p_part_num: int; (* partition number *) (* What we're going to do: *) mutable p_operation : partition_operation; @@ -487,7 +488,7 @@ read the man page virt-resize(1). { p_name = name; p_part = part; p_bootable = bootable; p_id = id; p_type = typ; - p_label = label; + p_label = label; p_part_num = part_num; p_operation = OpCopy; p_target_partnum = 0; p_target_start = 0L; p_target_end = 0L } ) parts in @@ -1071,7 +1072,7 @@ read the man page virt-resize(1). p_part = { G.part_num = 0l; part_start = 0L; part_end = 0L; part_size = 0L }; p_bootable = false; p_id = No_ID; p_type = ContentUnknown; - p_label = None; + p_label = None; p_part_num = 0; (* Target information is meaningful. *) p_operation = OpIgnore; @@ -1097,10 +1098,15 @@ read the man page virt-resize(1). loop 1 start true partitions in + let mbr_part_type x = + if x.p_part_num <= 4 && x.p_type <> ContentExtendedPartition then "primary" + else if x.p_part_num <= 4 && x.p_type = ContentExtendedPartition then "extended" + else "logical" in + (* Now partition the target disk. *) List.iter ( fun p -> - g#part_add "/dev/sdb" "primary" p.p_target_start p.p_target_end + g#part_add "/dev/sdb" (mbr_part_type p) p.p_target_start p.p_target_end ) partitions; (* Copy over the data. *) -- 1.9.3 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
