From 8c916a8c229f4c1d2f2225a6a460ab27eb0b79f3 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 14 Jul 2015 15:08:12 +0300 Subject: [PATCH] fix partition Signed-off-by: Vasiliy Tolstov --- system/filesystem_linux.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/system/filesystem_linux.go b/system/filesystem_linux.go index 7178c70..28e082e 100644 --- a/system/filesystem_linux.go +++ b/system/filesystem_linux.go @@ -108,10 +108,11 @@ func ResizeRootFS() error { if err != nil { return err } + os.Remove(device) if err = syscall.Mknod(device, uint32(os.ModeDevice|syscall.S_IFBLK|0600), devBlk.Int()); err != nil { return err } - // defer os.Remove(device) + defer os.Remove(device) // mbr := make([]byte, 446) /* @@ -196,7 +197,11 @@ func ResizeRootFS() error { if active { stdin.Write([]byte("a\n" + fmt.Sprintf("%d", partnum) + "\n")) } - stdin.Write([]byte("t\n" + fmt.Sprintf("%d", partnum) + "\n" + parttype + "\nw")) + if partnum > 1 { + stdin.Write([]byte("t\n" + fmt.Sprintf("%d", partnum) + "\n" + parttype + "\nw")) + } else { + stdin.Write([]byte("t\n" + parttype + "\nw")) + } cmd = exec.Command("fdisk", "-u", device) cmd.Stdin = &stdin cmd.Run() @@ -238,11 +243,11 @@ func ResizeRootFS() error { } } } - + os.Remove(partition) if err = syscall.Mknod(partition, uint32(os.ModeDevice|syscall.S_IFBLK|0600), devFs.Int()); err != nil { return err } - // defer os.Remove(partition) + defer os.Remove(partition) log.Printf("resize filesystem via %s %s", "resize2fs", partition) buf, err := exec.Command("resize2fs", partition).CombinedOutput() if err != nil {