diff --git a/cmd/cloudinitexecute/cloudinitexecute.go b/cmd/cloudinitexecute/cloudinitexecute.go index 41086cc4..c1dd27f2 100644 --- a/cmd/cloudinitexecute/cloudinitexecute.go +++ b/cmd/cloudinitexecute/cloudinitexecute.go @@ -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 diff --git a/pkg/dfs/scratch.go b/pkg/dfs/scratch.go index 0857c7d6..f0830ab9 100644 --- a/pkg/dfs/scratch.go +++ b/pkg/dfs/scratch.go @@ -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 {