diff --git a/pkg/extend/extend.go b/pkg/extend/extend.go index 7bf88baad..3a88d1445 100644 --- a/pkg/extend/extend.go +++ b/pkg/extend/extend.go @@ -11,6 +11,7 @@ import ( "path/filepath" "regexp" "sort" + "strconv" "strings" "syscall" "time" @@ -87,6 +88,20 @@ func extend(d, fsType string) error { log.Printf("No free space on device to extend partition") return nil } + if f.PartitionTable.Label == "dos" { + out, err := exec.Command("blockdev", "--getsz", d).Output() + if err != nil { + return fmt.Errorf("Unable to get total size of %s: %v", d, err) + } + totalSize, err := strconv.Atoi(strings.TrimSpace(string(out))) + if err != nil { + return fmt.Errorf("Unable to convert total size from string to int: %v", err) + } + if partition.Start+partition.Size == totalSize { + log.Printf("No free space on device to extend partition") + return nil + } + } switch fsType { case "ext4":