github.com/ratanraj/packer@v1.3.2/website/source/docs/builders/hyperv-vmcx.html.md.erb (about)

     1  ---
     2  modeline: |
     3    vim: set ft=pandoc:
     4  description: |-
     5    The Hyper-V Packer builder is able to clone an existing Hyper-V virtual machine and export them.
     6  layout: "docs"
     7  sidebar_current: 'docs-builders-hyperv-vmcx'
     8  page_title: "Hyper-V Builder (from a vmcx)"
     9  ---
    10  
    11  # Hyper-V Builder (from a vmcx)
    12  
    13  Type: `hyperv-vmcx`
    14  
    15  The Hyper-V Packer builder is able to use exported virtual machines or clone
    16  existing
    17  [Hyper-V](https://www.microsoft.com/en-us/server-cloud/solutions/virtualization.aspx)
    18  virtual machines.
    19  
    20  Typically, the builder imports or clones an existing virtual machine,
    21  boots it, provisions software within the OS, and then shuts it down. The
    22  result of the Hyper-V builder is a directory containing all the files
    23  necessary to run the virtual machine portably.
    24  
    25  ## Basic Examples
    26  
    27  Here are some basic examples. Neither example would really do anything more
    28  than producing a copy of the source virtual machine. However, the examples
    29  could be used as a starting point for more advanced templates.
    30  
    31  Import from folder:
    32  
    33  ``` json
    34  {
    35    "type": "hyperv-vmcx",
    36    "clone_from_vmcx_path": "c:/virtual machines/ubuntu-12.04.5-server-amd64",
    37    "ssh_username": "packer",
    38    "ssh_password": "packer",
    39    "shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
    40  }
    41  ```
    42  
    43  Clone from existing virtual machine:
    44  
    45  ``` json
    46  {
    47      "clone_from_vm_name": "ubuntu-12.04.5-server-amd64",
    48      "shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
    49      "ssh_password": "packer",
    50      "ssh_username": "packer",
    51      "type": "hyperv-vmcx"
    52  }
    53  ```
    54  
    55  By default Packer will perform a hard power off of a virtual machine.
    56  However, when a machine is powered off this way, it is possible that
    57  changes made to the VMs file system may not be fully synced, possibly
    58  leading to corruption of files or lost changes. As such, it is important to
    59  add a `shutdown_command`. This tells Packer how to safely shutdown and
    60  power off the VM.
    61  
    62  ## Configuration Reference
    63  
    64  There are many configuration options available for the Hyper-V builder. They
    65  are organized below into two categories: required and optional. Within each
    66  category, the available options are alphabetized and described.
    67  
    68  In addition to the options listed here, a
    69  [communicator](/docs/templates/communicator.html) can be configured for this
    70  builder.
    71  
    72  ### Required for virtual machine import:
    73  
    74  -   `clone_from_vmcx_path` (string) - The path to a directory containing a
    75      previously exported virtual machine. The exported machine will be used
    76      as the source for new VM.
    77  
    78  
    79  ### Required for virtual machine clone:
    80  
    81  -   `clone_from_vm_name` (string) - The name of the VM to clone from. Ideally
    82      the machine to clone from should be shutdown.
    83  
    84  ### Optional:
    85  
    86  -   `boot_command` (array of strings) - This is an array of commands to type
    87      when the virtual machine is first booted. The goal of these commands
    88      should be to type just enough to initialize the operating system
    89      installer. Special keys can be typed as well, and are covered in the
    90      section below on the boot command. If this is not specified, it is assumed
    91      the installer will start itself.
    92  
    93  -   `boot_wait` (string) - The time to wait after booting the initial virtual
    94      machine before typing the `boot_command`. The value specified should be
    95      a duration. For example, setting a duration of "1m30s" would cause
    96      Packer to wait for 1 minute 30 seconds before typing the boot command.
    97      The default duration is "10s" (10 seconds).
    98  
    99  -   `clone_all_snapshots` (boolean) - If set to `true` all snapshots
   100      present in the source machine will be copied when the machine is
   101      cloned. The final result of the build will be an exported virtual
   102      machine that contains all the snapshots of the parent.
   103  
   104      If `clone_from_vmcx_path` is set, this setting has no effect and any
   105      snapshots associated with the source VM will also be present in the
   106      resultant VM.
   107  
   108      If `clone_from_snapshot_name` is configured, this setting has no
   109      effect and the resultant machine will not contain any snapshots.
   110  
   111  -   `clone_from_snapshot_name` (string) - The name of a snapshot in the
   112      source machine to use as a starting point for the clone. If the value
   113      given is an empty string, the last snapshot present in the source will
   114      be chosen as the starting point for the new VM.
   115  
   116      This setting only has an effect if using `clone_from_vm_name` and is
   117      ignored otherwise.
   118  
   119  -   `cpu` (number) - The number of CPUs the virtual machine should use. If
   120      this isn't specified, the default is 1 CPU.
   121  
   122  -   `enable_dynamic_memory` (boolean) - If `true` enable dynamic memory for
   123      the virtual machine. This defaults to `false`.
   124  
   125  -   `enable_mac_spoofing` (boolean) - If `true` enable MAC address spoofing
   126      for the virtual machine. This defaults to `false`.
   127  
   128  -   `enable_secure_boot` (boolean) - If `true` enable secure boot for the
   129      virtual machine. This defaults to `false`. See `secure_boot_template`
   130      below for additional settings.
   131  
   132  -   `enable_virtualization_extensions` (boolean) - If `true` enable
   133      virtualization extensions for the virtual machine. This defaults to
   134      `false`. For nested virtualization you need to enable MAC spoofing,
   135      disable dynamic memory and have at least 4GB of RAM assigned to the
   136      virtual machine.
   137  
   138  -   `floppy_dirs` (array of strings) - A list of directories to place onto
   139      the floppy disk recursively. This is similar to the `floppy_files` option
   140      except that the directory structure is preserved. This is useful for when
   141      your floppy disk includes drivers or if you just want to organize it's
   142      contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are
   143      allowed. The maximum summary size of all files in the listed directories
   144      are the same as in `floppy_files`.
   145  
   146  -   `floppy_files` (array of strings) - A list of files to place onto a floppy
   147      disk that is attached when the VM is booted. This is most useful for
   148      unattended Windows installs, which look for an `Autounattend.xml` file on
   149      removable media. By default, no floppy will be attached. All files listed
   150      in this setting get placed into the root directory of the floppy and the
   151      floppy is attached as the first floppy device. Currently, no support
   152      exists for creating sub-directories on the floppy. Wildcard characters
   153      (`*`, `?`, and `[]`) are allowed. Directory names are also allowed, which
   154      will add all the files found in the directory to the floppy.
   155  
   156  -   `guest_additions_mode` (string) - If set to `attach` then attach and
   157      mount the ISO image specified in `guest_additions_path`. If set to
   158      `none` then guest additions are not attached and mounted; This is the
   159      default.
   160  
   161  -   `guest_additions_path` (string) - The path to the ISO image for guest
   162      additions.
   163  
   164  -   `headless` (boolean) - Packer defaults to building Hyper-V virtual
   165      machines by launching a GUI that shows the console of the machine being
   166      built. When this value is set to true, the machine will start without a
   167      console.
   168  
   169  -   `http_directory` (string) - Path to a directory to serve using Packers
   170      inbuilt HTTP server. The files in this directory will be available
   171      over HTTP to the virtual machine. This is useful for hosting kickstart
   172      files and so on. By default this value is unset and the HTTP server is
   173      not started. The address and port of the HTTP server will be available
   174      as variables in `boot_command`. This is covered in more detail below.
   175  
   176  -   `http_port_min` and `http_port_max` (number) - These are the minimum and
   177      maximum port to use for the HTTP server started to serve the
   178      `http_directory`. Since Packer often runs in parallel, a randomly
   179      available port in this range will be repeatedly chosen until an
   180      available port is found. To force the HTTP server to use a specific
   181      port, set an identical value for `http_port_min` and `http_port_max`.
   182      By default the values are 8000 and 9000, respectively.
   183  
   184  -   `iso_checksum_type` (string) - The algorithm to be used when computing
   185      the checksum of the file specified in `iso_checksum`. Currently, valid
   186      values are "none", "md5", "sha1", "sha256", or "sha512". Since the
   187      validity of ISO and virtual disk files are typically crucial to a
   188      successful build, Packer performs a check of any supplied media by
   189      default. While setting "none" will cause Packer to skip this check,
   190      corruption of large files such as ISOs and virtual hard drives can
   191      occur from time to time. As such, skipping this check is not
   192      recommended.
   193  
   194  -   `iso_checksum` (string) - The checksum for the ISO file or virtual
   195      hard drive file. The algorithm to use when computing the checksum is
   196      specified with `iso_checksum_type`.
   197  
   198  -   `iso_target_extension` (string) - The extension of the ISO file after
   199      download. This defaults to "iso".
   200  
   201  -   `iso_target_path` (string) - The path where the ISO should be saved after
   202      download. By default the ISO will be saved in the Packer cache
   203      directory with a hash of the original filename as its name.
   204  
   205  -   `iso_url` (string) - A URL to the ISO or VHD containing the installation
   206      image. This URL can be either an HTTP URL or a file URL (or path to a
   207      file). If this is an HTTP URL, Packer will download iso and cache it
   208      between runs.
   209  
   210  -   `iso_urls` (array of strings) - Multiple URLs for the ISO or VHD to
   211      download. Packer will try these in order. If anything goes wrong
   212      attempting to download or while downloading a single URL, it will move on
   213      to the next.  All URLs must point to the same file (same checksum). By
   214      default this is empty and `iso_url` is used. Only one of `iso_url` or
   215      `iso_urls` can be specified.
   216  
   217  -   `mac_address` (string) - This allows a specific MAC address to be used on
   218      the default virtual network card. The MAC address must be a string with
   219      no delimiters, for example "0000deadbeef".
   220  
   221  -   `output_directory` (string) - This setting specifies the directory that
   222      artifacts from the build, such as the virtual machine files and disks,
   223      will be output to. The path to the directory may be relative or
   224      absolute. If relative, the path is relative to the working directory
   225      `packer` is executed from. This directory must not exist or, if
   226      created, must be empty prior to running the builder. By default this is
   227      "output-BUILDNAME" where "BUILDNAME" is the name of the build.
   228  
   229  -   `ram_size` (number) - The amount, in megabytes, of RAM to assign to the
   230      VM. By default, this is 1 GB.
   231  
   232  -   `secondary_iso_images` (array of strings) - A list of ISO paths to
   233      attach to a VM when it is booted. This is most useful for unattended
   234      Windows installs, which look for an `Autounattend.xml` file on removable
   235      media. By default, no secondary ISO will be attached.
   236  
   237  -   `secure_boot_template` (string) - The secure boot template to be
   238      configured. Valid values are "MicrosoftWindows" (Windows) or
   239      "MicrosoftUEFICertificateAuthority" (Linux). This only takes effect if
   240      `enable_secure_boot` is set to "true". This defaults to "MicrosoftWindows".
   241  
   242  -   `shutdown_command` (string) - The command to use to gracefully shut down
   243      the machine once all provisioning is complete. By default this is an
   244      empty string, which tells Packer to just forcefully shut down the
   245      machine. This setting can be safely omitted if for example, a shutdown
   246      command to gracefully halt the machine is configured inside a
   247      provisioning script. If one or more scripts require a reboot it is
   248      suggested to leave this blank (since reboots may fail) and instead
   249      specify the final shutdown command in your last script.
   250  
   251  -   `shutdown_timeout` (string) - The amount of time to wait after executing
   252      the `shutdown_command` for the virtual machine to actually shut down.
   253      If the machine doesn't shut down in this time it is considered an
   254      error. By default, the time out is "5m" (five minutes).
   255  
   256  -   `skip_compaction` (boolean) - If `true` skip compacting the hard disk for
   257      the virtual machine when exporting. This defaults to `false`.
   258  
   259  -   `skip_export` (boolean) - If `true` Packer will skip the export of the VM.
   260      If you are interested only in the VHD/VHDX files, you can enable this
   261      option. The resulting VHD/VHDX file will be output to
   262      `<output_directory>/Virtual Hard Disks`. By default this option is `false`
   263      and Packer will export the VM to `output_directory`.
   264  
   265  -   `switch_name` (string) - The name of the switch to connect the virtual
   266      machine to. By default, leaving this value unset will cause Packer to
   267      try and determine the switch to use by looking for an external switch
   268      that is up and running.
   269  
   270  -   `switch_vlan_id` (string) - This is the VLAN of the virtual switch's
   271      network card. By default none is set. If none is set then a VLAN is not
   272      set on the switch's network card. If this value is set it should match
   273      the VLAN specified in by `vlan_id`.
   274  
   275  -   `temp_path` (string) - The location under which Packer will create a
   276      directory to house all the VM files and folders during the build.
   277      By default `%TEMP%` is used which, for most systems, will evaluate to
   278      `%USERPROFILE%/AppData/Local/Temp`.
   279  
   280      The build directory housed under `temp_path` will have a name similar
   281      to `packerhv1234567`. The seven digit number at the end of the name is
   282      automatically generated by Packer to ensure the directory name is
   283      unique.
   284  
   285  -   `vlan_id` (string) - This is the VLAN of the virtual machine's network
   286      card for the new virtual machine. By default none is set. If none is set
   287      then VLANs are not set on the virtual machine's network card.
   288  
   289  -   `vm_name` (string) - This is the name of the new virtual machine,
   290      without the file extension. By default this is "packer-BUILDNAME",
   291      where "BUILDNAME" is the name of the build.
   292  
   293  ## Boot Command
   294  
   295  The `boot_command` configuration is very important: it specifies the keys to
   296  type when the virtual machine is first booted in order to start the OS
   297  installer. This command is typed after `boot_wait`, which gives the virtual
   298  machine some time to actually load the ISO.
   299  
   300  As documented above, the `boot_command` is an array of strings. The strings
   301  are all typed in sequence. It is an array only to improve readability within
   302  the template.
   303  
   304  The boot command is "typed" character for character over the virtual keyboard
   305  to the machine, simulating a human actually typing the keyboard.
   306  
   307  <%= partial "partials/builders/boot-command" %>
   308  
   309  The example shown below is a working boot command used to start an Ubuntu
   310  12.04 installer:
   311  
   312  ``` json
   313  [
   314    "<esc><esc><enter><wait>",
   315    "/install/vmlinuz noapic ",
   316    "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
   317    "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
   318    "hostname={{ .Name }} ",
   319    "fb=false debconf/frontend=noninteractive ",
   320    "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
   321    "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
   322    "initrd=/install/initrd.gz -- <enter>"
   323  ]
   324  ```
   325  
   326  For more examples of various boot commands, see the sample projects from our
   327  [community templates page](/community-tools.html#templates).
   328  
   329  ## Integration Services
   330  
   331  Packer will automatically attach the integration services ISO as a DVD drive
   332  for the version of Hyper-V that is running.
   333  
   334  ## Generation 1 vs Generation 2
   335  
   336  Floppy drives are no longer supported by generation 2 machines. This requires
   337  you to take another approach when dealing with preseed or answer files. Two
   338  possible options are using virtual DVD drives or using Packers built in web
   339  server.
   340  
   341  When dealing with Windows you need to enable UEFI drives for generation 2
   342  virtual machines.
   343  
   344  ## Creating an ISO From a Directory
   345  
   346  Programs like mkisofs can be used to create an ISO from a directory. There is
   347  a [windows version of
   348  mkisofs](http://opensourcepack.blogspot.co.uk/p/cdrtools.html) available.
   349  
   350  Below is a working PowerShell script that can be used to create a Windows
   351  answer ISO:
   352  
   353  ``` powershell
   354  $isoFolder = "answer-iso"
   355  if (test-path $isoFolder){
   356    remove-item $isoFolder -Force -Recurse
   357  }
   358  
   359  if (test-path windows\windows-2012R2-serverdatacenter-amd64\answer.iso){
   360    remove-item windows\windows-2012R2-serverdatacenter-amd64\answer.iso -Force
   361  }
   362  
   363  mkdir $isoFolder
   364  
   365  copy windows\windows-2012R2-serverdatacenter-amd64\Autounattend.xml $isoFolder\
   366  copy windows\windows-2012R2-serverdatacenter-amd64\sysprep-unattend.xml $isoFolder\
   367  copy windows\common\set-power-config.ps1 $isoFolder\
   368  copy windows\common\microsoft-updates.ps1 $isoFolder\
   369  copy windows\common\win-updates.ps1 $isoFolder\
   370  copy windows\common\run-sysprep.ps1 $isoFolder\
   371  copy windows\common\run-sysprep.cmd $isoFolder\
   372  
   373  $textFile = "$isoFolder\Autounattend.xml"
   374  
   375  $c = Get-Content -Encoding UTF8 $textFile
   376  
   377  # Enable UEFI and disable Non EUFI
   378  $c | % { $_ -replace '<!-- Start Non UEFI -->','<!-- Start Non UEFI' } | % { $_ -replace '<!-- Finish Non UEFI -->','Finish Non UEFI -->' } | % { $_ -replace '<!-- Start UEFI compatible','<!-- Start UEFI compatible -->' } | % { $_ -replace 'Finish UEFI compatible -->','<!-- Finish UEFI compatible -->' } | sc -Path $textFile
   379  
   380  & .\mkisofs.exe -r -iso-level 4 -UDF -o windows\windows-2012R2-serverdatacenter-amd64\answer.iso $isoFolder
   381  
   382  if (test-path $isoFolder){
   383    remove-item $isoFolder -Force -Recurse
   384  }
   385  ```
   386  
   387  ## Example For Windows Server 2012 R2 Generation 2
   388  
   389  Packer config:
   390  
   391  ``` json
   392  {
   393    "builders": [
   394      {
   395        "vm_name":"windows2012r2",
   396        "type": "hyperv-iso",
   397        "disk_size": 61440,
   398        "floppy_files": [],
   399        "secondary_iso_images": [
   400          "./windows/windows-2012R2-serverdatacenter-amd64/answer.iso"
   401        ],
   402        "http_directory": "./windows/common/http/",
   403        "boot_wait": "0s",
   404        "boot_command": [
   405          "a<wait>a<wait>a"
   406        ],
   407        "iso_url": "http://download.microsoft.com/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO",
   408        "iso_checksum_type": "md5",
   409        "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a",
   410        "communicator":"winrm",
   411        "winrm_username": "vagrant",
   412        "winrm_password": "vagrant",
   413        "winrm_timeout" : "4h",
   414        "shutdown_command": "f:\\run-sysprep.cmd",
   415        "ram_size": 4096,
   416        "cpu": 4,
   417        "generation": 2,
   418        "switch_name":"LAN",
   419        "enable_secure_boot":true
   420      }
   421    ],
   422    "provisioners": [
   423      {
   424        "type": "powershell",
   425        "elevated_user":"vagrant",
   426        "elevated_password":"vagrant",
   427        "scripts": [
   428          "./windows/common/install-7zip.ps1",
   429          "./windows/common/install-chef.ps1",
   430          "./windows/common/compile-dotnet-assemblies.ps1",
   431          "./windows/common/cleanup.ps1",
   432          "./windows/common/ultradefrag.ps1",
   433          "./windows/common/sdelete.ps1"
   434        ]
   435      }
   436    ],
   437    "post-processors": [
   438      {
   439        "type": "vagrant",
   440        "keep_input_artifact": false,
   441        "output": "{{.Provider}}_windows-2012r2_chef.box"
   442      }
   443    ]
   444  }
   445  ```
   446  
   447  autounattend.xml:
   448  
   449  ``` xml
   450  <?xml version="1.0" encoding="utf-8"?>
   451  <unattend xmlns="urn:schemas-microsoft-com:unattend">
   452      <settings pass="windowsPE">
   453          <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   454              <SetupUILanguage>
   455                  <UILanguage>en-US</UILanguage>
   456              </SetupUILanguage>
   457              <InputLocale>en-US</InputLocale>
   458              <SystemLocale>en-US</SystemLocale>
   459              <UILanguage>en-US</UILanguage>
   460              <UILanguageFallback>en-US</UILanguageFallback>
   461              <UserLocale>en-US</UserLocale>
   462          </component>
   463          <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   464              <!-- Start Non UEFI -->
   465              <DiskConfiguration>
   466                  <Disk wcm:action="add">
   467                      <CreatePartitions>
   468                          <CreatePartition wcm:action="add">
   469                              <Type>Primary</Type>
   470                              <Order>1</Order>
   471                              <Size>350</Size>
   472                          </CreatePartition>
   473                          <CreatePartition wcm:action="add">
   474                              <Order>2</Order>
   475                              <Type>Primary</Type>
   476                              <Extend>true</Extend>
   477                          </CreatePartition>
   478                      </CreatePartitions>
   479                      <ModifyPartitions>
   480                          <ModifyPartition wcm:action="add">
   481                              <Active>true</Active>
   482                              <Format>NTFS</Format>
   483                              <Label>boot</Label>
   484                              <Order>1</Order>
   485                              <PartitionID>1</PartitionID>
   486                          </ModifyPartition>
   487                          <ModifyPartition wcm:action="add">
   488                              <Format>NTFS</Format>
   489                              <Label>Windows 2012 R2</Label>
   490                              <Letter>C</Letter>
   491                              <Order>2</Order>
   492                              <PartitionID>2</PartitionID>
   493                          </ModifyPartition>
   494                      </ModifyPartitions>
   495                      <DiskID>0</DiskID>
   496                      <WillWipeDisk>true</WillWipeDisk>
   497                  </Disk>
   498              </DiskConfiguration>
   499              <ImageInstall>
   500                  <OSImage>
   501                      <InstallFrom>
   502                          <MetaData wcm:action="add">
   503                              <Key>/IMAGE/NAME </Key>
   504                              <Value>Windows Server 2012 R2 SERVERSTANDARD</Value>
   505                          </MetaData>
   506                      </InstallFrom>
   507                      <InstallTo>
   508                          <DiskID>0</DiskID>
   509                          <PartitionID>2</PartitionID>
   510                      </InstallTo>
   511                  </OSImage>
   512              </ImageInstall>
   513              <!-- Finish Non UEFI -->
   514              <!-- Start UEFI compatible
   515              <DiskConfiguration>
   516                  <Disk wcm:action="add">
   517                      <CreatePartitions>
   518                          <CreatePartition wcm:action="add">
   519                              <Order>1</Order>
   520                              <Size>300</Size>
   521                              <Type>Primary</Type>
   522                          </CreatePartition>
   523                          <CreatePartition wcm:action="add">
   524                              <Order>2</Order>
   525                              <Size>100</Size>
   526                              <Type>EFI</Type>
   527                          </CreatePartition>
   528                          <CreatePartition wcm:action="add">
   529                              <Order>3</Order>
   530                              <Size>128</Size>
   531                              <Type>MSR</Type>
   532                          </CreatePartition>
   533                          <CreatePartition wcm:action="add">
   534                              <Order>4</Order>
   535                              <Extend>true</Extend>
   536                              <Type>Primary</Type>
   537                          </CreatePartition>
   538                      </CreatePartitions>
   539                      <ModifyPartitions>
   540                          <ModifyPartition wcm:action="add">
   541                              <Order>1</Order>
   542                              <PartitionID>1</PartitionID>
   543                              <Label>WINRE</Label>
   544                              <Format>NTFS</Format>
   545                              <TypeID>de94bba4-06d1-4d40-a16a-bfd50179d6ac</TypeID>
   546                          </ModifyPartition>
   547                          <ModifyPartition wcm:action="add">
   548                              <Order>2</Order>
   549                              <PartitionID>2</PartitionID>
   550                              <Label>System</Label>
   551                              <Format>FAT32</Format>
   552                          </ModifyPartition>
   553                          <ModifyPartition wcm:action="add">
   554                              <Order>3</Order>
   555                              <PartitionID>3</PartitionID>
   556                          </ModifyPartition>
   557                          <ModifyPartition wcm:action="add">
   558                              <Order>4</Order>
   559                              <PartitionID>4</PartitionID>
   560                              <Label>Windows</Label>
   561                              <Format>NTFS</Format>
   562                          </ModifyPartition>
   563                      </ModifyPartitions>
   564                      <DiskID>0</DiskID>
   565                      <WillWipeDisk>true</WillWipeDisk>
   566                  </Disk>
   567                  <WillShowUI>OnError</WillShowUI>
   568              </DiskConfiguration>
   569              <ImageInstall>
   570                  <OSImage>
   571                      <InstallFrom>
   572                          <MetaData wcm:action="add">
   573                              <Key>/IMAGE/NAME </Key>
   574                              <Value>Windows Server 2012 R2 SERVERSTANDARD</Value>
   575                          </MetaData>
   576                      </InstallFrom>
   577                      <InstallTo>
   578                          <DiskID>0</DiskID>
   579                          <PartitionID>4</PartitionID>
   580                      </InstallTo>
   581                  </OSImage>
   582              </ImageInstall>
   583              Finish UEFI compatible -->
   584              <UserData>
   585                  <!-- Product Key from http://technet.microsoft.com/en-us/library/jj612867.aspx -->
   586                  <ProductKey>
   587                      <!-- Do not uncomment the Key element if you are using trial ISOs -->
   588                      <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs -->
   589                      <!--<Key>D2N9P-3P6X9-2R39C-7RTCD-MDVJX</Key>-->
   590                      <WillShowUI>OnError</WillShowUI>
   591                  </ProductKey>
   592                  <AcceptEula>true</AcceptEula>
   593                  <FullName>Vagrant</FullName>
   594                  <Organization>Vagrant</Organization>
   595              </UserData>
   596          </component>
   597      </settings>
   598      <settings pass="specialize">
   599          <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   600              <OEMInformation>
   601                  <HelpCustomized>false</HelpCustomized>
   602              </OEMInformation>
   603              <ComputerName>vagrant-2012r2</ComputerName>
   604              <TimeZone>Coordinated Universal Time</TimeZone>
   605              <RegisteredOwner />
   606          </component>
   607          <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   608              <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
   609          </component>
   610          <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   611              <IEHardenAdmin>false</IEHardenAdmin>
   612              <IEHardenUser>false</IEHardenUser>
   613          </component>
   614          <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   615              <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
   616          </component>
   617          <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   618              <SkipAutoActivation>true</SkipAutoActivation>
   619          </component>
   620      </settings>
   621      <settings pass="oobeSystem">
   622  <!-- Start Setup cache proxy during installation
   623          <component name="Microsoft-Windows-IE-ClientNetworkProtocolImplementation" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   624              <POLICYProxySettingsPerUser>0</POLICYProxySettingsPerUser>
   625              <HKLMProxyEnable>true</HKLMProxyEnable>
   626              <HKLMProxyServer>cache-proxy:3142</HKLMProxyServer>
   627          </component>
   628  Finish Setup cache proxy during installation -->
   629          <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   630              <AutoLogon>
   631                  <Password>
   632                      <Value>vagrant</Value>
   633                      <PlainText>true</PlainText>
   634                  </Password>
   635                  <Enabled>true</Enabled>
   636                  <Username>vagrant</Username>
   637              </AutoLogon>
   638              <FirstLogonCommands>
   639                  <SynchronousCommand wcm:action="add">
   640                      <CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
   641                      <Description>Set Execution Policy 64 Bit</Description>
   642                      <Order>1</Order>
   643                      <RequiresUserInput>true</RequiresUserInput>
   644                  </SynchronousCommand>
   645                  <SynchronousCommand wcm:action="add">
   646                      <CommandLine>C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
   647                      <Description>Set Execution Policy 32 Bit</Description>
   648                      <Order>2</Order>
   649                      <RequiresUserInput>true</RequiresUserInput>
   650                  </SynchronousCommand>
   651                  <SynchronousCommand wcm:action="add">
   652                      <CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine>
   653                      <Description>winrm quickconfig -q</Description>
   654                      <Order>3</Order>
   655                      <RequiresUserInput>true</RequiresUserInput>
   656                  </SynchronousCommand>
   657                  <SynchronousCommand wcm:action="add">
   658                      <CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine>
   659                      <Description>winrm quickconfig -transport:http</Description>
   660                      <Order>4</Order>
   661                      <RequiresUserInput>true</RequiresUserInput>
   662                  </SynchronousCommand>
   663                  <SynchronousCommand wcm:action="add">
   664                      <CommandLine>cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}</CommandLine>
   665                      <Description>Win RM MaxTimeoutms</Description>
   666                      <Order>5</Order>
   667                      <RequiresUserInput>true</RequiresUserInput>
   668                  </SynchronousCommand>
   669                  <SynchronousCommand wcm:action="add">
   670                      <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}</CommandLine>
   671                      <Description>Win RM MaxMemoryPerShellMB</Description>
   672                      <Order>6</Order>
   673                      <RequiresUserInput>true</RequiresUserInput>
   674                  </SynchronousCommand>
   675                  <SynchronousCommand wcm:action="add">
   676                      <CommandLine>cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine>
   677                      <Description>Win RM AllowUnencrypted</Description>
   678                      <Order>7</Order>
   679                      <RequiresUserInput>true</RequiresUserInput>
   680                  </SynchronousCommand>
   681                  <SynchronousCommand wcm:action="add">
   682                      <CommandLine>cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}</CommandLine>
   683                      <Description>Win RM auth Basic</Description>
   684                      <Order>8</Order>
   685                      <RequiresUserInput>true</RequiresUserInput>
   686                  </SynchronousCommand>
   687                  <SynchronousCommand wcm:action="add">
   688                      <CommandLine>cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}</CommandLine>
   689                      <Description>Win RM client auth Basic</Description>
   690                      <Order>9</Order>
   691                      <RequiresUserInput>true</RequiresUserInput>
   692                  </SynchronousCommand>
   693                  <SynchronousCommand wcm:action="add">
   694                      <CommandLine>cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} </CommandLine>
   695                      <Description>Win RM listener Address/Port</Description>
   696                      <Order>10</Order>
   697                      <RequiresUserInput>true</RequiresUserInput>
   698                  </SynchronousCommand>
   699                  <SynchronousCommand wcm:action="add">
   700                      <CommandLine>cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes </CommandLine>
   701                      <Description>Win RM adv firewall enable</Description>
   702                      <Order>11</Order>
   703                      <RequiresUserInput>true</RequiresUserInput>
   704                  </SynchronousCommand>
   705                  <SynchronousCommand wcm:action="add">
   706                      <CommandLine>cmd.exe /c netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow</CommandLine>
   707                      <Description>Win RM port open</Description>
   708                      <Order>12</Order>
   709                      <RequiresUserInput>true</RequiresUserInput>
   710                  </SynchronousCommand>
   711                  <SynchronousCommand wcm:action="add">
   712                      <CommandLine>cmd.exe /c netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow</CommandLine>
   713                      <Description>Win RM port open</Description>
   714                      <Order>13</Order>
   715                      <RequiresUserInput>true</RequiresUserInput>
   716                  </SynchronousCommand>
   717                  <SynchronousCommand wcm:action="add">
   718                      <CommandLine>cmd.exe /c net stop winrm </CommandLine>
   719                      <Description>Stop Win RM Service </Description>
   720                      <Order>14</Order>
   721                      <RequiresUserInput>true</RequiresUserInput>
   722                  </SynchronousCommand>
   723                  <SynchronousCommand wcm:action="add">
   724                      <CommandLine>cmd.exe /c sc config winrm start= disabled</CommandLine>
   725                      <Description>Win RM Autostart</Description>
   726                      <Order>15</Order>
   727                      <RequiresUserInput>true</RequiresUserInput>
   728                  </SynchronousCommand>
   729                  <SynchronousCommand wcm:action="add">
   730                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine>
   731                      <Order>16</Order>
   732                      <Description>Show file extensions in Explorer</Description>
   733                  </SynchronousCommand>
   734                  <SynchronousCommand wcm:action="add">
   735                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine>
   736                      <Order>17</Order>
   737                      <Description>Enable QuickEdit mode</Description>
   738                  </SynchronousCommand>
   739                  <SynchronousCommand wcm:action="add">
   740                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine>
   741                      <Order>18</Order>
   742                      <Description>Show Run command in Start Menu</Description>
   743                  </SynchronousCommand>
   744                  <SynchronousCommand wcm:action="add">
   745                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine>
   746                      <Order>19</Order>
   747                      <Description>Show Administrative Tools in Start Menu</Description>
   748                  </SynchronousCommand>
   749                  <SynchronousCommand wcm:action="add">
   750                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine>
   751                      <Order>20</Order>
   752                      <Description>Zero Hibernation File</Description>
   753                  </SynchronousCommand>
   754                  <SynchronousCommand wcm:action="add">
   755                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine>
   756                      <Order>21</Order>
   757                      <Description>Disable Hibernation Mode</Description>
   758                  </SynchronousCommand>
   759                  <SynchronousCommand wcm:action="add">
   760                      <CommandLine>cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE</CommandLine>
   761                      <Order>22</Order>
   762                      <Description>Disable password expiration for vagrant user</Description>
   763                  </SynchronousCommand>
   764                  <SynchronousCommand wcm:action="add">
   765                      <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxShellsPerUser="30"}</CommandLine>
   766                      <Description>Win RM MaxShellsPerUser</Description>
   767                      <Order>23</Order>
   768                      <RequiresUserInput>true</RequiresUserInput>
   769                  </SynchronousCommand>
   770                  <SynchronousCommand wcm:action="add">
   771                      <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxProcessesPerShell="25"}</CommandLine>
   772                      <Description>Win RM MaxProcessesPerShell</Description>
   773                      <Order>24</Order>
   774                      <RequiresUserInput>true</RequiresUserInput>
   775                  </SynchronousCommand>
   776                  <SynchronousCommand wcm:action="add">
   777                      <CommandLine>%SystemRoot%\System32\reg.exe ADD "HKLM\System\CurrentControlSet\Services\Netlogon\Parameters" /v DisablePasswordChange /t REG_DWORD /d 1 /f</CommandLine>
   778                      <Description>Turn off computer password</Description>
   779                      <Order>25</Order>
   780                  </SynchronousCommand>
   781                  <SynchronousCommand wcm:action="add">
   782                      <CommandLine>cmd.exe /c netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow</CommandLine>
   783                      <Description>ICMP open for ping</Description>
   784                      <Order>26</Order>
   785                      <RequiresUserInput>true</RequiresUserInput>
   786                  </SynchronousCommand>
   787                  <!-- WITH WINDOWS UPDATES -->
   788                  <SynchronousCommand wcm:action="add">
   789                      <CommandLine>cmd.exe /c IF EXIST a:\set-power-config.ps1 (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\set-power-config.ps1) ELSE (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File f:\set-power-config.ps1)</CommandLine>
   790                      <Order>97</Order>
   791                      <Description>Turn off all power saving and timeouts</Description>
   792                      <RequiresUserInput>true</RequiresUserInput>
   793                  </SynchronousCommand>
   794                  <SynchronousCommand wcm:action="add">
   795                      <CommandLine>cmd.exe /c IF EXIST a:\microsoft-updates.ps1 (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\microsoft-updates.ps1) ELSE (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File f:\microsoft-updates.ps1)</CommandLine>
   796                      <Order>98</Order>
   797                      <Description>Enable Microsoft Updates</Description>
   798                      <RequiresUserInput>true</RequiresUserInput>
   799                  </SynchronousCommand>
   800                  <SynchronousCommand wcm:action="add">
   801                      <CommandLine>cmd.exe /c IF EXIST a:\win-updates.ps1 (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1) ELSE (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File f:\win-updates.ps1)</CommandLine>
   802                      <Description>Install Windows Updates</Description>
   803                      <Order>100</Order>
   804                      <RequiresUserInput>true</RequiresUserInput>
   805                  </SynchronousCommand>
   806                  <!-- END WITH WINDOWS UPDATES -->
   807              </FirstLogonCommands>
   808              <OOBE>
   809                  <HideEULAPage>true</HideEULAPage>
   810                  <HideLocalAccountScreen>true</HideLocalAccountScreen>
   811                  <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
   812                  <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
   813                  <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
   814                  <NetworkLocation>Work</NetworkLocation>
   815                  <ProtectYourPC>1</ProtectYourPC>
   816              </OOBE>
   817              <UserAccounts>
   818                  <AdministratorPassword>
   819                      <Value>vagrant</Value>
   820                      <PlainText>true</PlainText>
   821                  </AdministratorPassword>
   822                  <LocalAccounts>
   823                      <LocalAccount wcm:action="add">
   824                          <Password>
   825                              <Value>vagrant</Value>
   826                              <PlainText>true</PlainText>
   827                          </Password>
   828                          <Group>administrators</Group>
   829                          <DisplayName>Vagrant</DisplayName>
   830                          <Name>vagrant</Name>
   831                          <Description>Vagrant User</Description>
   832                      </LocalAccount>
   833                  </LocalAccounts>
   834              </UserAccounts>
   835              <RegisteredOwner />
   836              <TimeZone>Coordinated Universal Time</TimeZone>
   837          </component>
   838      </settings>
   839      <settings pass="offlineServicing">
   840          <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   841              <EnableLUA>false</EnableLUA>
   842          </component>
   843      </settings>
   844      <cpi:offlineImage cpi:source="wim:c:/projects/baseboxes/9600.16384.winblue_rtm.130821-1623_x64fre_server_eval_en-us-irm_sss_x64free_en-us_dv5_slipstream/sources/install.wim#Windows Server 2012 R2 SERVERDATACENTER" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
   845  </unattend>
   846  ```
   847  
   848  sysprep-unattend.xml:
   849  
   850  ``` xml
   851  <?xml version="1.0" encoding="utf-8"?>
   852  <unattend xmlns="urn:schemas-microsoft-com:unattend">
   853      <settings pass="generalize">
   854          <component language="neutral" name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   855              <SkipRearm>1</SkipRearm>
   856          </component>
   857      </settings>
   858      <settings pass="oobeSystem">
   859  <!-- Setup proxy after sysprep
   860         <component name="Microsoft-Windows-IE-ClientNetworkProtocolImplementation" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   861              <POLICYProxySettingsPerUser>1</POLICYProxySettingsPerUser>
   862              <HKLMProxyEnable>false</HKLMProxyEnable>
   863              <HKLMProxyServer>cache-proxy:3142</HKLMProxyServer>
   864          </component>
   865  Finish proxy after sysprep -->
   866          <component language="neutral" name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   867              <InputLocale>0809:00000809</InputLocale>
   868              <SystemLocale>en-GB</SystemLocale>
   869              <UILanguage>en-US</UILanguage>
   870              <UILanguageFallback>en-US</UILanguageFallback>
   871              <UserLocale>en-GB</UserLocale>
   872          </component>
   873          <component language="neutral" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   874              <OOBE>
   875                  <HideEULAPage>true</HideEULAPage>
   876                  <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
   877                  <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
   878                  <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
   879                  <NetworkLocation>Work</NetworkLocation>
   880                  <ProtectYourPC>1</ProtectYourPC>
   881                  <SkipUserOOBE>true</SkipUserOOBE>
   882                  <SkipMachineOOBE>true</SkipMachineOOBE>
   883              </OOBE>
   884              <UserAccounts>
   885                  <AdministratorPassword>
   886                      <Value>vagrant</Value>
   887                      <PlainText>true</PlainText>
   888                  </AdministratorPassword>
   889                  <LocalAccounts>
   890                      <LocalAccount wcm:action="add">
   891                          <Password>
   892                              <Value>vagrant</Value>
   893                              <PlainText>true</PlainText>
   894                          </Password>
   895                          <Group>administrators</Group>
   896                          <DisplayName>Vagrant</DisplayName>
   897                          <Name>vagrant</Name>
   898                          <Description>Vagrant User</Description>
   899                      </LocalAccount>
   900                  </LocalAccounts>
   901              </UserAccounts>
   902              <DisableAutoDaylightTimeSet>true</DisableAutoDaylightTimeSet>
   903              <TimeZone>Coordinated Universal Time</TimeZone>
   904              <VisualEffects>
   905                  <SystemDefaultBackgroundColor>2</SystemDefaultBackgroundColor>
   906              </VisualEffects>
   907          </component>
   908      </settings>
   909  </unattend>
   910  ```
   911  
   912  ## Example For Ubuntu Vivid Generation 2
   913  
   914  If you are running Windows under virtualization, you may need to create a
   915  virtual switch with an `External` connection type.
   916  
   917  ### Packer config:
   918  
   919  ``` json
   920  {
   921    "variables": {
   922      "vm_name": "ubuntu-xenial",
   923      "cpu": "2",
   924      "ram_size": "1024",
   925      "disk_size": "21440",
   926      "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.1-server-amd64.iso",
   927      "iso_checksum_type": "sha1",
   928      "iso_checksum": "DE5EE8665048F009577763EFBF4A6F0558833E59"
   929    },
   930    "builders": [
   931      {
   932        "vm_name":"{{user `vm_name`}}",
   933        "type": "hyperv-iso",
   934        "disk_size": "{{user `disk_size`}}",
   935        "guest_additions_mode": "disable",
   936        "iso_url": "{{user `iso_url`}}",
   937        "iso_checksum_type": "{{user `iso_checksum_type`}}",
   938        "iso_checksum": "{{user `iso_checksum`}}",
   939        "communicator":"ssh",
   940        "ssh_username": "packer",
   941        "ssh_password": "packer",
   942        "ssh_timeout" : "4h",
   943        "http_directory": "./",
   944        "boot_wait": "5s",
   945        "boot_command": [
   946          "<esc><wait10><esc><esc><enter><wait>",
   947          "set gfxpayload=1024x768<enter>",
   948          "linux /install/vmlinuz ",
   949          "preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/hyperv-taliesins.cfg ",
   950          "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
   951          "hostname={{.Name}} ",
   952          "fb=false debconf/frontend=noninteractive ",
   953          "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
   954          "keyboard-configuration/variant=USA console-setup/ask_detect=false <enter>",
   955          "initrd /install/initrd.gz<enter>",
   956          "boot<enter>"
   957        ],
   958        "shutdown_command": "echo 'packer' | sudo -S -E shutdown -P now",
   959        "ram_size": "{{user `ram_size`}}",
   960        "cpu": "{{user `cpu`}}",
   961        "generation": 2,
   962        "enable_secure_boot": false
   963      }
   964    ]
   965  }
   966  ```
   967  
   968  ### preseed.cfg:
   969  
   970  ``` text
   971  ## Options to set on the command line
   972  d-i debian-installer/locale string en_US.utf8
   973  d-i console-setup/ask_detect boolean false
   974  d-i console-setup/layout string us
   975  
   976  d-i netcfg/get_hostname string nl-ams-basebox3
   977  d-i netcfg/get_domain string unassigned-domain
   978  
   979  d-i time/zone string UTC
   980  d-i clock-setup/utc-auto boolean true
   981  d-i clock-setup/utc boolean true
   982  
   983  d-i kbd-chooser/method select American English
   984  
   985  d-i netcfg/wireless_wep string
   986  
   987  d-i base-installer/kernel/override-image string linux-server
   988  
   989  d-i debconf debconf/frontend select Noninteractive
   990  
   991  d-i pkgsel/install-language-support boolean false
   992  tasksel tasksel/first multiselect standard, ubuntu-server
   993  
   994  ## Partitioning
   995  d-i partman-auto/method string lvm
   996  
   997  d-i partman-lvm/confirm boolean true
   998  d-i partman-lvm/device_remove_lvm boolean true
   999  d-i partman-lvm/confirm boolean true
  1000  
  1001  d-i partman-auto-lvm/guided_size string max
  1002  d-i partman-auto/choose_recipe select atomic
  1003  
  1004  d-i partman/confirm_write_new_label boolean true
  1005  d-i partman/choose_partition select finish
  1006  d-i partman/confirm boolean true
  1007  d-i partman/confirm_nooverwrite boolean true
  1008  
  1009  # Write the changes to disks and configure LVM?
  1010  d-i partman-lvm/confirm boolean true
  1011  d-i partman-lvm/confirm_nooverwrite boolean true
  1012  
  1013  d-i partman-partitioning/no_bootable_gpt_biosgrub boolean false
  1014  d-i partman-partitioning/no_bootable_gpt_efi boolean false
  1015  d-i partman-efi/non_efi_system boolean true
  1016  
  1017  # Default user
  1018  d-i passwd/user-fullname string packer
  1019  d-i passwd/username string packer
  1020  d-i passwd/user-password password packer
  1021  d-i passwd/user-password-again password packer
  1022  d-i user-setup/encrypt-home boolean false
  1023  d-i user-setup/allow-password-weak boolean true
  1024  
  1025  # Minimum packages
  1026  d-i pkgsel/include string openssh-server ntp linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) linux-cloud-tools-common
  1027  
  1028  # Upgrade packages after debootstrap? (none, safe-upgrade, full-upgrade)
  1029  # (note: set to none for speed)
  1030  d-i pkgsel/upgrade select none
  1031  
  1032  d-i grub-installer/only_debian boolean true
  1033  d-i grub-installer/with_other_os boolean true
  1034  d-i finish-install/reboot_in_progress note
  1035  
  1036  d-i pkgsel/update-policy select none
  1037  
  1038  choose-mirror-bin mirror/http/proxy string
  1039  ```