mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 18:11:35 +00:00
Don’t resize dos partition if no free space is available
Signed-off-by: Guillaume Rose <guillaume.rose@docker.com>
This commit is contained in:
parent
518220ee44
commit
0fb16ac8b0
@ -11,6 +11,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@ -87,6 +88,20 @@ func extend(d, fsType string) error {
|
|||||||
log.Printf("No free space on device to extend partition")
|
log.Printf("No free space on device to extend partition")
|
||||||
return nil
|
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 {
|
switch fsType {
|
||||||
case "ext4":
|
case "ext4":
|
||||||
|
Loading…
Reference in New Issue
Block a user