+# Create a partition table.
+#
+# We *must* do this before copying the bootloader across, and copying
+# the bootloader must be careful not to disturb this partition table
+# (RHBZ#633766). There are two reasons for this:
+#
+# (1) The 'parted' library is stupid and broken. In many ways. In
+# this particular instance the stupid and broken bit is that it
+# overwrites the whole boot sector when initializating a partition
+# table. (Upstream don't consider this obvious problem to be a bug).
+#
+# (2) GPT has a backup partition table located at the end of the disk.
+# It's non-movable, because the primary GPT contains fixed references
+# to both the size of the disk and the backup partition table at the
+# end. This would be a problem for any resize that didn't either
+# carefully move the backup GPT (and rewrite those references) or
+# recreate the whole partition table from scratch.
+
+my $parttype;
+create_partition_table ();
+
+sub create_partition_table
+{
+ local $_;
+
+ $parttype = $g->part_get_parttype ("/dev/sda");
+ print "partition table type: $parttype\n" if $debug;
+
+ $g->part_init ("/dev/sdb", $parttype);
+}
+