github.com/StackPointCloud/packer@v0.10.2-0.20180716202532-b28098e0f79b/website/source/docs/builders/hyperv-iso.html.md.erb (about)

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