Skip to content

Commit

Permalink
fix the mount by executing a mount command in the guest after executi…
Browse files Browse the repository at this point in the history
…ng "vboxmanage sharedfolder"
  • Loading branch information
mhewedy committed Aug 23, 2020
1 parent b42cac5 commit 86ad30a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions vms/mount.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package vms

import (
"fmt"
"github.com/mhewedy/vermin/command"
"github.com/mhewedy/vermin/command/ssh"
"github.com/mhewedy/vermin/db"
"github.com/mhewedy/vermin/db/props"
"github.com/mhewedy/vermin/images"
Expand Down Expand Up @@ -33,15 +35,25 @@ func Mount(vmName string, hostPath string) error {
return err
}

guestFolder := "/vermin"
shareName := strconv.FormatInt(time.Now().Unix(), 10)

if _, err = command.VBoxManage("sharedfolder",
"add",
vmName,
"--name", strconv.FormatInt(time.Now().Unix(), 10),
"--name", shareName,
"--hostpath", absHostPath,
"--transient",
"--automount",
"--auto-mount-point",
"/vermin").Call(); err != nil {
guestFolder).Call(); err != nil {
return err
}

mountCmd := fmt.Sprintf("sudo mkdir -p %s; ", guestFolder) +
fmt.Sprintf("sudo mount -t vboxsf -o uid=1000,gid=1000 %s %s", shareName, guestFolder)

if _, err = ssh.Execute(vmName, mountCmd); err != nil {
return err
}

Expand Down

0 comments on commit 86ad30a

Please sign in to comment.