From 58daa1d84e2cc24b707dfb48406f8ed3c24f055a Mon Sep 17 00:00:00 2001 From: Steven Merrill Date: Tue, 2 Jul 2013 20:22:11 -0400 Subject: [PATCH 1/2] Add a 'skip_compaction' step. --- builder/vmware/builder.go | 1 + builder/vmware/step_compact_disk.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/builder/vmware/builder.go b/builder/vmware/builder.go index f6388827e..e48103c73 100644 --- a/builder/vmware/builder.go +++ b/builder/vmware/builder.go @@ -39,6 +39,7 @@ type config struct { HTTPPortMax uint `mapstructure:"http_port_max"` BootCommand []string `mapstructure:"boot_command"` BootWait time.Duration `` + SkipCompaction bool `mapstructure:"skip_compaction"` ShutdownCommand string `mapstructure:"shutdown_command"` ShutdownTimeout time.Duration `` SSHUser string `mapstructure:"ssh_username"` diff --git a/builder/vmware/step_compact_disk.go b/builder/vmware/step_compact_disk.go index d399322a7..05bbc62da 100644 --- a/builder/vmware/step_compact_disk.go +++ b/builder/vmware/step_compact_disk.go @@ -4,11 +4,14 @@ import ( "fmt" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" + "log" ) -// This step compacts the virtual disk for the VM. +// This step compacts the virtual disk for the VM unless the "skip_compaction" +// boolean is true. // // Uses: +// config *config // driver Driver // full_disk_path string // ui packer.Ui @@ -18,10 +21,16 @@ import ( type stepCompactDisk struct{} func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction { + config := state["config"].(*config) driver := state["driver"].(Driver) ui := state["ui"].(packer.Ui) full_disk_path := state["full_disk_path"].(string) + if config.SkipCompaction == true { + log.Println("Skipping disk compaction step...") + return multistep.ActionContinue + } + ui.Say("Compacting the disk image") if err := driver.CompactDisk(full_disk_path); err != nil { state["error"] = fmt.Errorf("Error compacting disk: %s", err) From d620a09dd6aeeb283b018c01d6c9802c679ee087 Mon Sep 17 00:00:00 2001 From: Steven Merrill Date: Tue, 2 Jul 2013 23:48:04 -0400 Subject: [PATCH 2/2] Add documentation of the skip_compaction parameter. --- website/source/docs/builders/vmware.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/source/docs/builders/vmware.html.markdown b/website/source/docs/builders/vmware.html.markdown index 7824d3ffc..c1f0d3820 100644 --- a/website/source/docs/builders/vmware.html.markdown +++ b/website/source/docs/builders/vmware.html.markdown @@ -99,6 +99,11 @@ Optional: By default this is "output-BUILDNAME" where "BUILDNAME" is the name of the build. +* `skip_compaction` (bool) - As of Packer 0.1.4, VMware-created disks are defragmented + and compacted at the end of the build process. If you are doing your own zeroing out + of the disks you may find that the compaction step results in slightly larger boxes. + Compaction will run unless you set this value to true. + * `shutdown_command` (string) - The command to use to gracefully shut down the machine once all the provisioning is done. By default this is an empty string, which tells Packer to just forcefully shut down the machine.