From 0deecce2de2632fe2774468f70b557e4afe2d564 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 8 Apr 2015 13:09:25 +0300 Subject: [PATCH] fix resize Signed-off-by: Vasiliy Tolstov --- system/filesystem_freebsd.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/system/filesystem_freebsd.go b/system/filesystem_freebsd.go index 083235f..941614c 100644 --- a/system/filesystem_freebsd.go +++ b/system/filesystem_freebsd.go @@ -62,17 +62,22 @@ func ResizeRootFS() error { if err = cmd.Wait(); err != nil || partition == "" { return fmt.Errorf("failed to find partition on %s\n", device) } - log.Printf("%s %s\n", device, partition) - /* - echo "sysctl kern.geom.debugflags=16" >> /etc/rc.local - echo "gpart resize -i 1 da0" >> /etc/rc.local - echo "gpart resize -i 1 da0s1" >> /etc/rc.local - echo "true > /dev/da0" >> /etc/rc.local - echo "true > /dev/da0s1" >> /etc/rc.local - echo "true > /dev/da0s1a" >> /etc/rc.local - echo "gpart resize -i 1 da0" >> /etc/rc.local - echo "gpart resize -i 1 da0s1" >> /etc/rc.local - echo "growfs -y /" >> /etc/rc.local - */ + + commands := []string{ + "sysctl kern.geom.debugflags=16", + "gpart resize -i 1 " + strings.Split(device, "/")[2], + "gpart resize -i 1 " + strings.Split(device, "/")[2] + partition, + "true > " + device, + "true > " + device + partition, + "true > " + device + partition + "a", + "gpart resize -i 1 " + strings.Split(device, "/")[2], + "gpart resize -i 1 " + strings.Split(device, "/")[2] + partition, + "growfs -y /", + } + + for _, command := range commands { + log.Printf("resize fs %s\n", command) + exec.Command(strings.Split(command, " ")[0], strings.Split(command, " ")[1:]...).Run() + } return nil }