mirror of
https://github.com/rancher/os.git
synced 2025-08-12 03:52:37 +00:00
Resize raspberrypi device
This commit is contained in:
parent
66981b1b50
commit
2f0d0a9585
@ -181,7 +181,17 @@ func applyPreConsole(cfg *rancherConfig.CloudConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resizeDevice(cfg *rancherConfig.CloudConfig) error {
|
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.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Run()
|
cmd.Run()
|
||||||
@ -194,10 +204,6 @@ func resizeDevice(cfg *rancherConfig.CloudConfig) error {
|
|||||||
return err
|
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 = exec.Command("resize2fs", targetPartition)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/rancher/os/config/cmdline"
|
||||||
"github.com/rancher/os/pkg/init/one"
|
"github.com/rancher/os/pkg/init/one"
|
||||||
"github.com/rancher/os/pkg/log"
|
"github.com/rancher/os/pkg/log"
|
||||||
"github.com/rancher/os/pkg/netconf"
|
"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")
|
selinux.SetFileContext(graphDirectory, "system_u:object_r:var_lib_t:s0")
|
||||||
|
|
||||||
return CreateSymlinks([][]string{
|
symlinks := [][]string{
|
||||||
{"usr/lib", "/lib"},
|
{"usr/lib", "/lib"},
|
||||||
{"usr/sbin", "/sbin"},
|
{"usr/sbin", "/sbin"},
|
||||||
{"../run", "/var/run"},
|
{"../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 {
|
func firstPrepare() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user