2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2025-07-04 02:22:27 +00:00

run/hetzner: upload using sparsecat and run e2fsck

docs: add demo scripts

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2022-09-10 18:15:22 +02:00
parent 6c93c8be56
commit d97b58159c
4 changed files with 360 additions and 6 deletions

View File

@ -243,12 +243,7 @@ func runHetzner(ctx context.Context, imgPath string, stdin io.Reader, stderr io.
}
}
}()
var cmd string
if runtime.GOOS == "linux" {
cmd = fmt.Sprintf("%s -r -disable-sparse-target -of %s", sparsecatPath, vmBlockPath)
} else {
cmd = fmt.Sprintf("dd of=%s", vmBlockPath)
}
cmd := fmt.Sprintf("%s -r -disable-sparse-target -of %s", sparsecatPath, vmBlockPath)
logrus.Debugf("$ %s", cmd)
if b, err := wses.CombinedOutput(cmd); err != nil {
return fmt.Errorf("%v: %s", err, string(b))
@ -281,6 +276,19 @@ func runHetzner(ctx context.Context, imgPath string, stdin io.Reader, stderr io.
} else {
logrus.Debugf(string(b))
}
cses, err := sc.NewSession()
if err != nil {
return err
}
defer cses.Close()
logrus.Infof("checking disk partition")
cmd = fmt.Sprintf("e2fsck -yf %s1", vmBlockPath)
logrus.Debugf("$ %s", cmd)
if b, err := cses.CombinedOutput(cmd); err != nil {
return fmt.Errorf("%v: %s", err, string(b))
} else {
logrus.Debugf(string(b))
}
eses, err := sc.NewSession()
if err != nil {
return err