diff --git a/builder/vmware/driver.go b/builder/vmware/driver.go index 94a3551e7..2acf20adf 100644 --- a/builder/vmware/driver.go +++ b/builder/vmware/driver.go @@ -44,13 +44,13 @@ type Fusion5Driver struct { } func (d *Fusion5Driver) CompactDisk(diskPath string) error { - cmd := exec.Command(d.vdiskManagerPath(), "-d", diskPath) - if _, _, err := d.runAndLog(cmd); err != nil { + defragCmd := exec.Command(d.vdiskManagerPath(), "-d", diskPath) + if _, _, err := d.runAndLog(defragCmd); err != nil { return err } - cmd := exec.Command(d.vdiskManagerPath(), "-k", diskPath) - if _, _, err := d.runAndLog(cmd); err != nil { + shrinkCmd := exec.Command(d.vdiskManagerPath(), "-k", diskPath) + if _, _, err := d.runAndLog(shrinkCmd); err != nil { return err } diff --git a/builder/vmware/step_compact_disk.go b/builder/vmware/step_compact_disk.go index c4f67fa77..18034bb87 100644 --- a/builder/vmware/step_compact_disk.go +++ b/builder/vmware/step_compact_disk.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" - "path/filepath" ) // This step compacts the virtual disks for the VM. @@ -24,7 +23,7 @@ func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction { ui := state["ui"].(packer.Ui) ui.Say("Compacting the disk image") - if err := driver.CompactDisk(config.FullDiskPath, fmt.Sprintf("%dM", config.DiskSize)); err != nil { + if err := driver.CompactDisk(config.FullDiskPath); err != nil { err := fmt.Errorf("Error compacting disk: %s", err) state["error"] = err ui.Error(err.Error()) diff --git a/builder/vmware/step_create_disk.go b/builder/vmware/step_create_disk.go index 5997bf998..7a6ce21b2 100644 --- a/builder/vmware/step_create_disk.go +++ b/builder/vmware/step_create_disk.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" - "path/filepath" ) // This step creates the virtual disks for the VM.