1
0
mirror of https://github.com/rancher/os.git synced 2025-08-01 23:17:50 +00:00

Resize raspberrypi device

This commit is contained in:
Jason-ZW 2019-05-20 09:48:20 +08:00 committed by niusmallnan
parent 66981b1b50
commit 2f0d0a9585
2 changed files with 24 additions and 7 deletions

View File

@ -181,7 +181,17 @@ func applyPreConsole(cfg *rancherConfig.CloudConfig) {
}
func resizeDevice(cfg *rancherConfig.CloudConfig) error {
cmd := exec.Command("growpart", cfg.Rancher.ResizeDevice, "1")
partition := "1"
targetPartition := fmt.Sprintf("%s%s", cfg.Rancher.ResizeDevice, partition)
if strings.Contains(cfg.Rancher.ResizeDevice, "mmcblk") {
partition = "2"
targetPartition = fmt.Sprintf("%sp%s", cfg.Rancher.ResizeDevice, partition)
} else if strings.Contains(cfg.Rancher.ResizeDevice, "nvme") {
targetPartition = fmt.Sprintf("%sp%s", cfg.Rancher.ResizeDevice, partition)
}
cmd := exec.Command("growpart", cfg.Rancher.ResizeDevice, partition)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
@ -194,10 +204,6 @@ func resizeDevice(cfg *rancherConfig.CloudConfig) error {
return err
}
targetPartition := fmt.Sprintf("%s1", cfg.Rancher.ResizeDevice)
if strings.Contains(cfg.Rancher.ResizeDevice, "nvme") {
targetPartition = fmt.Sprintf("%sp1", cfg.Rancher.ResizeDevice)
}
cmd = exec.Command("resize2fs", targetPartition)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

View File

@ -11,6 +11,7 @@ import (
"strings"
"syscall"
"github.com/rancher/os/config/cmdline"
"github.com/rancher/os/pkg/init/one"
"github.com/rancher/os/pkg/log"
"github.com/rancher/os/pkg/netconf"
@ -548,11 +549,21 @@ func createLayout(config *Config) error {
selinux.SetFileContext(graphDirectory, "system_u:object_r:var_lib_t:s0")
return CreateSymlinks([][]string{
symlinks := [][]string{
{"usr/lib", "/lib"},
{"usr/sbin", "/sbin"},
{"../run", "/var/run"},
})
}
rootCmdline := cmdline.GetCmdline("root")
rootDevice := rootCmdline.(string)
if rootDevice != "" {
if _, err := os.Stat("/dev/root"); os.IsNotExist(err) {
symlinks = append(symlinks, []string{rootDevice, "/dev/root"})
}
}
return CreateSymlinks(symlinks)
}
func firstPrepare() error {