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