Add GUID Partition Table (GPT) support to extend and mount packages

Signed-off-by: Federico Pellegatta <12744504+federico-pellegatta@users.noreply.github.com>
This commit is contained in:
Federico Pellegatta
2020-04-24 09:38:05 +02:00
parent 966cf121a3
commit 6133c561fd
32 changed files with 137 additions and 34 deletions

View File

@@ -82,7 +82,10 @@ func extend(d, fsType string) error {
}
partition := f.PartitionTable.Partitions[0]
if partition.Type != "83" {
// fail on anything that isn't a Linux partition
// 83 -> MBR/DOS Linux Partition ID
// 0FC63DAF-8483-4772-8E79-3D69D8477DE4 -> GPT Linux Partition GUID
if partition.Type != "83" && partition.Type != "0FC63DAF-8483-4772-8E79-3D69D8477DE4" {
return fmt.Errorf("Partition 1 on disk %s is not a Linux Partition", d)
}
@@ -176,7 +179,7 @@ func createPartition(d string, partition Partition) error {
}
createCmd := exec.Command("sfdisk", "-q", d)
createCmd.Stdin = strings.NewReader(fmt.Sprintf("%d,,83;", partition.Start))
createCmd.Stdin = strings.NewReader(fmt.Sprintf("%d,,%s;", partition.Start, partition.Type))
if err := createCmd.Run(); err != nil {
return fmt.Errorf("Error creating partition table: %v", err)
}