github.com/ratanraj/packer@v1.3.2/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 setting specifies the directory that
   205      artifacts from the build, such as the virtual machine files and disks,
   206      will be output to. The path to the directory may be relative or
   207      absolute. If relative, the path is relative to the working directory
   208      `packer` is executed from. This directory must not exist or, if
   209      created, must be empty prior to running the builder. By default this is
   210      "output-BUILDNAME" where "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 VM.
   243      If you are interested only in the VHD/VHDX files, you can enable this
   244      option. The resulting VHD/VHDX file will be output to
   245      `<output_directory>/Virtual Hard Disks`. By default this option is `false`
   246      and Packer will export the VM to `output_directory`.
   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  -   `temp_path` (string) - The location under which Packer will create a
   259      directory to house all the VM files and folders during the build.
   260      By default `%TEMP%` is used which, for most systems, will evaluate to
   261      `%USERPROFILE%/AppData/Local/Temp`.
   262  
   263      The build directory housed under `temp_path` will have a name similar
   264      to `packerhv1234567`. The seven digit number at the end of the name is
   265      automatically generated by Packer to ensure the directory name is
   266      unique.
   267  
   268  -   `use_fixed_vhd_format` (boolean) - If true, creates the boot disk on the
   269      virtual machine as a fixed VHD format disk. The default is `false`, which
   270      creates a dynamic VHDX format disk. This option requires setting
   271      `generation` to `1`, `skip_compaction` to `true`, and
   272      `differencing_disk` to `false`. Additionally, any value entered for
   273      `disk_block_size` will be ignored. The most likely use case for this
   274      option is outputing a disk that is in the format required for upload to
   275      Azure.
   276  
   277  -   `vlan_id` (string) - This is the VLAN of the virtual machine's network
   278      card for the new virtual machine. By default none is set. If none is set
   279      then VLANs are not set on the virtual machine's network card.
   280  
   281  -   `vm_name` (string) - This is the name of the new virtual machine,
   282      without the file extension. By default this is "packer-BUILDNAME",
   283      where "BUILDNAME" is the name of the build.
   284  
   285  ## Boot Command
   286  
   287  The `boot_command` configuration is very important: it specifies the keys to
   288  type when the virtual machine is first booted in order to start the OS
   289  installer. This command is typed after `boot_wait`, which gives the virtual
   290  machine some time to actually load the ISO.
   291  
   292  As documented above, the `boot_command` is an array of strings. The strings
   293  are all typed in sequence. It is an array only to improve readability within
   294  the template.
   295  
   296  The boot command is "typed" character for character over the virtual keyboard
   297  to the machine, simulating a human actually typing the keyboard.
   298  
   299  <%= partial "partials/builders/boot-command" %>
   300  
   301  The example shown below is a working boot command used to start an Ubuntu
   302  12.04 installer:
   303  
   304  ``` json
   305  [
   306    "<esc><esc><enter><wait>",
   307    "/install/vmlinuz noapic ",
   308    "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
   309    "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
   310    "hostname={{ .Name }} ",
   311    "fb=false debconf/frontend=noninteractive ",
   312    "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
   313    "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
   314    "initrd=/install/initrd.gz -- <enter>"
   315  ]
   316  ```
   317  
   318  For more examples of various boot commands, see the sample projects from our
   319  [community templates page](/community-tools.html#templates).
   320  
   321  ## Integration Services
   322  
   323  Packer will automatically attach the integration services ISO as a DVD drive
   324  for the version of Hyper-V that is running.
   325  
   326  ## Generation 1 vs Generation 2
   327  
   328  Floppy drives are no longer supported by generation 2 machines. This requires
   329  you to take another approach when dealing with preseed or answer files. Two
   330  possible options are using virtual DVD drives or using Packers built in web
   331  server.
   332  
   333  When dealing with Windows you need to enable UEFI drives for generation 2
   334  virtual machines.
   335  
   336  ## Creating an ISO From a Directory
   337  
   338  Programs like mkisofs can be used to create an ISO from a directory. There is
   339  a [windows version of
   340  mkisofs](http://opensourcepack.blogspot.co.uk/p/cdrtools.html) available.
   341  
   342  Below is a working PowerShell script that can be used to create a Windows
   343  answer ISO:
   344  
   345  ``` powershell
   346  $isoFolder = "answer-iso"
   347  if (test-path $isoFolder){
   348    remove-item $isoFolder -Force -Recurse
   349  }
   350  
   351  if (test-path windows\windows-2012R2-serverdatacenter-amd64\answer.iso){
   352    remove-item windows\windows-2012R2-serverdatacenter-amd64\answer.iso -Force
   353  }
   354  
   355  mkdir $isoFolder
   356  
   357  copy windows\windows-2012R2-serverdatacenter-amd64\Autounattend.xml $isoFolder\
   358  copy windows\windows-2012R2-serverdatacenter-amd64\sysprep-unattend.xml $isoFolder\
   359  copy windows\common\set-power-config.ps1 $isoFolder\
   360  copy windows\common\microsoft-updates.ps1 $isoFolder\
   361  copy windows\common\win-updates.ps1 $isoFolder\
   362  copy windows\common\run-sysprep.ps1 $isoFolder\
   363  copy windows\common\run-sysprep.cmd $isoFolder\
   364  
   365  $textFile = "$isoFolder\Autounattend.xml"
   366  
   367  $c = Get-Content -Encoding UTF8 $textFile
   368  
   369  # Enable UEFI and disable Non EUFI
   370  $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
   371  
   372  & .\mkisofs.exe -r -iso-level 4 -UDF -o windows\windows-2012R2-serverdatacenter-amd64\answer.iso $isoFolder
   373  
   374  if (test-path $isoFolder){
   375    remove-item $isoFolder -Force -Recurse
   376  }
   377  ```
   378  
   379  ## Example For Windows Server 2012 R2 Generation 2
   380  
   381  Packer config:
   382  
   383  ``` json
   384  {
   385    "builders": [
   386      {
   387        "vm_name":"windows2012r2",
   388        "type": "hyperv-iso",
   389        "disk_size": 61440,
   390        "floppy_files": [],
   391        "secondary_iso_images": [
   392          "./windows/windows-2012R2-serverdatacenter-amd64/answer.iso"
   393        ],
   394        "http_directory": "./windows/common/http/",
   395        "boot_wait": "0s",
   396        "boot_command": [
   397          "a<wait>a<wait>a"
   398        ],
   399        "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",
   400        "iso_checksum_type": "md5",
   401        "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a",
   402        "communicator":"winrm",
   403        "winrm_username": "vagrant",
   404        "winrm_password": "vagrant",
   405        "winrm_timeout" : "4h",
   406        "shutdown_command": "f:\\run-sysprep.cmd",
   407        "ram_size": 4096,
   408        "cpu": 4,
   409        "generation": 2,
   410        "switch_name":"LAN",
   411        "enable_secure_boot":true
   412      }
   413    ],
   414    "provisioners": [
   415      {
   416        "type": "powershell",
   417        "elevated_user":"vagrant",
   418        "elevated_password":"vagrant",
   419        "scripts": [
   420          "./windows/common/install-7zip.ps1",
   421          "./windows/common/install-chef.ps1",
   422          "./windows/common/compile-dotnet-assemblies.ps1",
   423          "./windows/common/cleanup.ps1",
   424          "./windows/common/ultradefrag.ps1",
   425          "./windows/common/sdelete.ps1"
   426        ]
   427      }
   428    ],
   429    "post-processors": [
   430      {
   431        "type": "vagrant",
   432        "keep_input_artifact": false,
   433        "output": "{{.Provider}}_windows-2012r2_chef.box"
   434      }
   435    ]
   436  }
   437  ```
   438  
   439  autounattend.xml:
   440  
   441  ``` xml
   442  <?xml version="1.0" encoding="utf-8"?>
   443  <unattend xmlns="urn:schemas-microsoft-com:unattend">
   444      <settings pass="windowsPE">
   445          <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">
   446              <SetupUILanguage>
   447                  <UILanguage>en-US</UILanguage>
   448              </SetupUILanguage>
   449              <InputLocale>en-US</InputLocale>
   450              <SystemLocale>en-US</SystemLocale>
   451              <UILanguage>en-US</UILanguage>
   452              <UILanguageFallback>en-US</UILanguageFallback>
   453              <UserLocale>en-US</UserLocale>
   454          </component>
   455          <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">
   456              <!-- Start Non UEFI -->
   457              <DiskConfiguration>
   458                  <Disk wcm:action="add">
   459                      <CreatePartitions>
   460                          <CreatePartition wcm:action="add">
   461                              <Type>Primary</Type>
   462                              <Order>1</Order>
   463                              <Size>350</Size>
   464                          </CreatePartition>
   465                          <CreatePartition wcm:action="add">
   466                              <Order>2</Order>
   467                              <Type>Primary</Type>
   468                              <Extend>true</Extend>
   469                          </CreatePartition>
   470                      </CreatePartitions>
   471                      <ModifyPartitions>
   472                          <ModifyPartition wcm:action="add">
   473                              <Active>true</Active>
   474                              <Format>NTFS</Format>
   475                              <Label>boot</Label>
   476                              <Order>1</Order>
   477                              <PartitionID>1</PartitionID>
   478                          </ModifyPartition>
   479                          <ModifyPartition wcm:action="add">
   480                              <Format>NTFS</Format>
   481                              <Label>Windows 2012 R2</Label>
   482                              <Letter>C</Letter>
   483                              <Order>2</Order>
   484                              <PartitionID>2</PartitionID>
   485                          </ModifyPartition>
   486                      </ModifyPartitions>
   487                      <DiskID>0</DiskID>
   488                      <WillWipeDisk>true</WillWipeDisk>
   489                  </Disk>
   490              </DiskConfiguration>
   491              <ImageInstall>
   492                  <OSImage>
   493                      <InstallFrom>
   494                          <MetaData wcm:action="add">
   495                              <Key>/IMAGE/NAME </Key>
   496                              <Value>Windows Server 2012 R2 SERVERSTANDARD</Value>
   497                          </MetaData>
   498                      </InstallFrom>
   499                      <InstallTo>
   500                          <DiskID>0</DiskID>
   501                          <PartitionID>2</PartitionID>
   502                      </InstallTo>
   503                  </OSImage>
   504              </ImageInstall>
   505              <!-- Finish Non UEFI -->
   506              <!-- Start UEFI compatible
   507              <DiskConfiguration>
   508                  <Disk wcm:action="add">
   509                      <CreatePartitions>
   510                          <CreatePartition wcm:action="add">
   511                              <Order>1</Order>
   512                              <Size>300</Size>
   513                              <Type>Primary</Type>
   514                          </CreatePartition>
   515                          <CreatePartition wcm:action="add">
   516                              <Order>2</Order>
   517                              <Size>100</Size>
   518                              <Type>EFI</Type>
   519                          </CreatePartition>
   520                          <CreatePartition wcm:action="add">
   521                              <Order>3</Order>
   522                              <Size>128</Size>
   523                              <Type>MSR</Type>
   524                          </CreatePartition>
   525                          <CreatePartition wcm:action="add">
   526                              <Order>4</Order>
   527                              <Extend>true</Extend>
   528                              <Type>Primary</Type>
   529                          </CreatePartition>
   530                      </CreatePartitions>
   531                      <ModifyPartitions>
   532                          <ModifyPartition wcm:action="add">
   533                              <Order>1</Order>
   534                              <PartitionID>1</PartitionID>
   535                              <Label>WINRE</Label>
   536                              <Format>NTFS</Format>
   537                              <TypeID>de94bba4-06d1-4d40-a16a-bfd50179d6ac</TypeID>
   538                          </ModifyPartition>
   539                          <ModifyPartition wcm:action="add">
   540                              <Order>2</Order>
   541                              <PartitionID>2</PartitionID>
   542                              <Label>System</Label>
   543                              <Format>FAT32</Format>
   544                          </ModifyPartition>
   545                          <ModifyPartition wcm:action="add">
   546                              <Order>3</Order>
   547                              <PartitionID>3</PartitionID>
   548                          </ModifyPartition>
   549                          <ModifyPartition wcm:action="add">
   550                              <Order>4</Order>
   551                              <PartitionID>4</PartitionID>
   552                              <Label>Windows</Label>
   553                              <Format>NTFS</Format>
   554                          </ModifyPartition>
   555                      </ModifyPartitions>
   556                      <DiskID>0</DiskID>
   557                      <WillWipeDisk>true</WillWipeDisk>
   558                  </Disk>
   559                  <WillShowUI>OnError</WillShowUI>
   560              </DiskConfiguration>
   561              <ImageInstall>
   562                  <OSImage>
   563                      <InstallFrom>
   564                          <MetaData wcm:action="add">
   565                              <Key>/IMAGE/NAME </Key>
   566                              <Value>Windows Server 2012 R2 SERVERSTANDARD</Value>
   567                          </MetaData>
   568                      </InstallFrom>
   569                      <InstallTo>
   570                          <DiskID>0</DiskID>
   571                          <PartitionID>4</PartitionID>
   572                      </InstallTo>
   573                  </OSImage>
   574              </ImageInstall>
   575              Finish UEFI compatible -->
   576              <UserData>
   577                  <!-- Product Key from http://technet.microsoft.com/en-us/library/jj612867.aspx -->
   578                  <ProductKey>
   579                      <!-- Do not uncomment the Key element if you are using trial ISOs -->
   580                      <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs -->
   581                      <!--<Key>D2N9P-3P6X9-2R39C-7RTCD-MDVJX</Key>-->
   582                      <WillShowUI>OnError</WillShowUI>
   583                  </ProductKey>
   584                  <AcceptEula>true</AcceptEula>
   585                  <FullName>Vagrant</FullName>
   586                  <Organization>Vagrant</Organization>
   587              </UserData>
   588          </component>
   589      </settings>
   590      <settings pass="specialize">
   591          <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">
   592              <OEMInformation>
   593                  <HelpCustomized>false</HelpCustomized>
   594              </OEMInformation>
   595              <ComputerName>vagrant-2012r2</ComputerName>
   596              <TimeZone>Coordinated Universal Time</TimeZone>
   597              <RegisteredOwner />
   598          </component>
   599          <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">
   600              <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
   601          </component>
   602          <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">
   603              <IEHardenAdmin>false</IEHardenAdmin>
   604              <IEHardenUser>false</IEHardenUser>
   605          </component>
   606          <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">
   607              <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
   608          </component>
   609          <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">
   610              <SkipAutoActivation>true</SkipAutoActivation>
   611          </component>
   612      </settings>
   613      <settings pass="oobeSystem">
   614  <!-- Start Setup cache proxy during installation
   615          <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">
   616              <POLICYProxySettingsPerUser>0</POLICYProxySettingsPerUser>
   617              <HKLMProxyEnable>true</HKLMProxyEnable>
   618              <HKLMProxyServer>cache-proxy:3142</HKLMProxyServer>
   619          </component>
   620  Finish Setup cache proxy during installation -->
   621          <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">
   622              <AutoLogon>
   623                  <Password>
   624                      <Value>vagrant</Value>
   625                      <PlainText>true</PlainText>
   626                  </Password>
   627                  <Enabled>true</Enabled>
   628                  <Username>vagrant</Username>
   629              </AutoLogon>
   630              <FirstLogonCommands>
   631                  <SynchronousCommand wcm:action="add">
   632                      <CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
   633                      <Description>Set Execution Policy 64 Bit</Description>
   634                      <Order>1</Order>
   635                      <RequiresUserInput>true</RequiresUserInput>
   636                  </SynchronousCommand>
   637                  <SynchronousCommand wcm:action="add">
   638                      <CommandLine>C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
   639                      <Description>Set Execution Policy 32 Bit</Description>
   640                      <Order>2</Order>
   641                      <RequiresUserInput>true</RequiresUserInput>
   642                  </SynchronousCommand>
   643                  <SynchronousCommand wcm:action="add">
   644                      <CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine>
   645                      <Description>winrm quickconfig -q</Description>
   646                      <Order>3</Order>
   647                      <RequiresUserInput>true</RequiresUserInput>
   648                  </SynchronousCommand>
   649                  <SynchronousCommand wcm:action="add">
   650                      <CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine>
   651                      <Description>winrm quickconfig -transport:http</Description>
   652                      <Order>4</Order>
   653                      <RequiresUserInput>true</RequiresUserInput>
   654                  </SynchronousCommand>
   655                  <SynchronousCommand wcm:action="add">
   656                      <CommandLine>cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}</CommandLine>
   657                      <Description>Win RM MaxTimeoutms</Description>
   658                      <Order>5</Order>
   659                      <RequiresUserInput>true</RequiresUserInput>
   660                  </SynchronousCommand>
   661                  <SynchronousCommand wcm:action="add">
   662                      <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}</CommandLine>
   663                      <Description>Win RM MaxMemoryPerShellMB</Description>
   664                      <Order>6</Order>
   665                      <RequiresUserInput>true</RequiresUserInput>
   666                  </SynchronousCommand>
   667                  <SynchronousCommand wcm:action="add">
   668                      <CommandLine>cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine>
   669                      <Description>Win RM AllowUnencrypted</Description>
   670                      <Order>7</Order>
   671                      <RequiresUserInput>true</RequiresUserInput>
   672                  </SynchronousCommand>
   673                  <SynchronousCommand wcm:action="add">
   674                      <CommandLine>cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}</CommandLine>
   675                      <Description>Win RM auth Basic</Description>
   676                      <Order>8</Order>
   677                      <RequiresUserInput>true</RequiresUserInput>
   678                  </SynchronousCommand>
   679                  <SynchronousCommand wcm:action="add">
   680                      <CommandLine>cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}</CommandLine>
   681                      <Description>Win RM client auth Basic</Description>
   682                      <Order>9</Order>
   683                      <RequiresUserInput>true</RequiresUserInput>
   684                  </SynchronousCommand>
   685                  <SynchronousCommand wcm:action="add">
   686                      <CommandLine>cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} </CommandLine>
   687                      <Description>Win RM listener Address/Port</Description>
   688                      <Order>10</Order>
   689                      <RequiresUserInput>true</RequiresUserInput>
   690                  </SynchronousCommand>
   691                  <SynchronousCommand wcm:action="add">
   692                      <CommandLine>cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes </CommandLine>
   693                      <Description>Win RM adv firewall enable</Description>
   694                      <Order>11</Order>
   695                      <RequiresUserInput>true</RequiresUserInput>
   696                  </SynchronousCommand>
   697                  <SynchronousCommand wcm:action="add">
   698                      <CommandLine>cmd.exe /c netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow</CommandLine>
   699                      <Description>Win RM port open</Description>
   700                      <Order>12</Order>
   701                      <RequiresUserInput>true</RequiresUserInput>
   702                  </SynchronousCommand>
   703                  <SynchronousCommand wcm:action="add">
   704                      <CommandLine>cmd.exe /c netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow</CommandLine>
   705                      <Description>Win RM port open</Description>
   706                      <Order>13</Order>
   707                      <RequiresUserInput>true</RequiresUserInput>
   708                  </SynchronousCommand>
   709                  <SynchronousCommand wcm:action="add">
   710                      <CommandLine>cmd.exe /c net stop winrm </CommandLine>
   711                      <Description>Stop Win RM Service </Description>
   712                      <Order>14</Order>
   713                      <RequiresUserInput>true</RequiresUserInput>
   714                  </SynchronousCommand>
   715                  <SynchronousCommand wcm:action="add">
   716                      <CommandLine>cmd.exe /c sc config winrm start= disabled</CommandLine>
   717                      <Description>Win RM Autostart</Description>
   718                      <Order>15</Order>
   719                      <RequiresUserInput>true</RequiresUserInput>
   720                  </SynchronousCommand>
   721                  <SynchronousCommand wcm:action="add">
   722                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine>
   723                      <Order>16</Order>
   724                      <Description>Show file extensions in Explorer</Description>
   725                  </SynchronousCommand>
   726                  <SynchronousCommand wcm:action="add">
   727                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine>
   728                      <Order>17</Order>
   729                      <Description>Enable QuickEdit mode</Description>
   730                  </SynchronousCommand>
   731                  <SynchronousCommand wcm:action="add">
   732                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine>
   733                      <Order>18</Order>
   734                      <Description>Show Run command in Start Menu</Description>
   735                  </SynchronousCommand>
   736                  <SynchronousCommand wcm:action="add">
   737                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine>
   738                      <Order>19</Order>
   739                      <Description>Show Administrative Tools in Start Menu</Description>
   740                  </SynchronousCommand>
   741                  <SynchronousCommand wcm:action="add">
   742                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine>
   743                      <Order>20</Order>
   744                      <Description>Zero Hibernation File</Description>
   745                  </SynchronousCommand>
   746                  <SynchronousCommand wcm:action="add">
   747                      <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine>
   748                      <Order>21</Order>
   749                      <Description>Disable Hibernation Mode</Description>
   750                  </SynchronousCommand>
   751                  <SynchronousCommand wcm:action="add">
   752                      <CommandLine>cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE</CommandLine>
   753                      <Order>22</Order>
   754                      <Description>Disable password expiration for vagrant user</Description>
   755                  </SynchronousCommand>
   756                  <SynchronousCommand wcm:action="add">
   757                      <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxShellsPerUser="30"}</CommandLine>
   758                      <Description>Win RM MaxShellsPerUser</Description>
   759                      <Order>23</Order>
   760                      <RequiresUserInput>true</RequiresUserInput>
   761                  </SynchronousCommand>
   762                  <SynchronousCommand wcm:action="add">
   763                      <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxProcessesPerShell="25"}</CommandLine>
   764                      <Description>Win RM MaxProcessesPerShell</Description>
   765                      <Order>24</Order>
   766                      <RequiresUserInput>true</RequiresUserInput>
   767                  </SynchronousCommand>
   768                  <SynchronousCommand wcm:action="add">
   769                      <CommandLine>%SystemRoot%\System32\reg.exe ADD "HKLM\System\CurrentControlSet\Services\Netlogon\Parameters" /v DisablePasswordChange /t REG_DWORD /d 1 /f</CommandLine>
   770                      <Description>Turn off computer password</Description>
   771                      <Order>25</Order>
   772                  </SynchronousCommand>
   773                  <SynchronousCommand wcm:action="add">
   774                      <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>
   775                      <Description>ICMP open for ping</Description>
   776                      <Order>26</Order>
   777                      <RequiresUserInput>true</RequiresUserInput>
   778                  </SynchronousCommand>
   779                  <!-- WITH WINDOWS UPDATES -->
   780                  <SynchronousCommand wcm:action="add">
   781                      <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>
   782                      <Order>97</Order>
   783                      <Description>Turn off all power saving and timeouts</Description>
   784                      <RequiresUserInput>true</RequiresUserInput>
   785                  </SynchronousCommand>
   786                  <SynchronousCommand wcm:action="add">
   787                      <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>
   788                      <Order>98</Order>
   789                      <Description>Enable Microsoft Updates</Description>
   790                      <RequiresUserInput>true</RequiresUserInput>
   791                  </SynchronousCommand>
   792                  <SynchronousCommand wcm:action="add">
   793                      <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>
   794                      <Description>Install Windows Updates</Description>
   795                      <Order>100</Order>
   796                      <RequiresUserInput>true</RequiresUserInput>
   797                  </SynchronousCommand>
   798                  <!-- END WITH WINDOWS UPDATES -->
   799              </FirstLogonCommands>
   800              <OOBE>
   801                  <HideEULAPage>true</HideEULAPage>
   802                  <HideLocalAccountScreen>true</HideLocalAccountScreen>
   803                  <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
   804                  <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
   805                  <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
   806                  <NetworkLocation>Work</NetworkLocation>
   807                  <ProtectYourPC>1</ProtectYourPC>
   808              </OOBE>
   809              <UserAccounts>
   810                  <AdministratorPassword>
   811                      <Value>vagrant</Value>
   812                      <PlainText>true</PlainText>
   813                  </AdministratorPassword>
   814                  <LocalAccounts>
   815                      <LocalAccount wcm:action="add">
   816                          <Password>
   817                              <Value>vagrant</Value>
   818                              <PlainText>true</PlainText>
   819                          </Password>
   820                          <Group>administrators</Group>
   821                          <DisplayName>Vagrant</DisplayName>
   822                          <Name>vagrant</Name>
   823                          <Description>Vagrant User</Description>
   824                      </LocalAccount>
   825                  </LocalAccounts>
   826              </UserAccounts>
   827              <RegisteredOwner />
   828              <TimeZone>Coordinated Universal Time</TimeZone>
   829          </component>
   830      </settings>
   831      <settings pass="offlineServicing">
   832          <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">
   833              <EnableLUA>false</EnableLUA>
   834          </component>
   835      </settings>
   836      <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" />
   837  </unattend>
   838  ```
   839  
   840  sysprep-unattend.xml:
   841  
   842  ``` xml
   843  <?xml version="1.0" encoding="utf-8"?>
   844  <unattend xmlns="urn:schemas-microsoft-com:unattend">
   845      <settings pass="generalize">
   846          <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">
   847              <SkipRearm>1</SkipRearm>
   848          </component>
   849      </settings>
   850      <settings pass="oobeSystem">
   851  <!-- Setup proxy after sysprep
   852         <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">
   853              <POLICYProxySettingsPerUser>1</POLICYProxySettingsPerUser>
   854              <HKLMProxyEnable>false</HKLMProxyEnable>
   855              <HKLMProxyServer>cache-proxy:3142</HKLMProxyServer>
   856          </component>
   857  Finish proxy after sysprep -->
   858          <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">
   859              <InputLocale>0809:00000809</InputLocale>
   860              <SystemLocale>en-GB</SystemLocale>
   861              <UILanguage>en-US</UILanguage>
   862              <UILanguageFallback>en-US</UILanguageFallback>
   863              <UserLocale>en-GB</UserLocale>
   864          </component>
   865          <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">
   866              <OOBE>
   867                  <HideEULAPage>true</HideEULAPage>
   868                  <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
   869                  <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
   870                  <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
   871                  <NetworkLocation>Work</NetworkLocation>
   872                  <ProtectYourPC>1</ProtectYourPC>
   873                  <SkipUserOOBE>true</SkipUserOOBE>
   874                  <SkipMachineOOBE>true</SkipMachineOOBE>
   875              </OOBE>
   876              <UserAccounts>
   877                  <AdministratorPassword>
   878                      <Value>vagrant</Value>
   879                      <PlainText>true</PlainText>
   880                  </AdministratorPassword>
   881                  <LocalAccounts>
   882                      <LocalAccount wcm:action="add">
   883                          <Password>
   884                              <Value>vagrant</Value>
   885                              <PlainText>true</PlainText>
   886                          </Password>
   887                          <Group>administrators</Group>
   888                          <DisplayName>Vagrant</DisplayName>
   889                          <Name>vagrant</Name>
   890                          <Description>Vagrant User</Description>
   891                      </LocalAccount>
   892                  </LocalAccounts>
   893              </UserAccounts>
   894              <DisableAutoDaylightTimeSet>true</DisableAutoDaylightTimeSet>
   895              <TimeZone>Coordinated Universal Time</TimeZone>
   896              <VisualEffects>
   897                  <SystemDefaultBackgroundColor>2</SystemDefaultBackgroundColor>
   898              </VisualEffects>
   899          </component>
   900      </settings>
   901  </unattend>
   902  ```
   903  
   904  ## Example For Ubuntu Vivid Generation 2
   905  
   906  If you are running Windows under virtualization, you may need to create a
   907  virtual switch with an `External` connection type.
   908  
   909  ### Packer config:
   910  
   911  ``` json
   912  {
   913    "variables": {
   914      "vm_name": "ubuntu-xenial",
   915      "cpu": "2",
   916      "ram_size": "1024",
   917      "disk_size": "21440",
   918      "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.1-server-amd64.iso",
   919      "iso_checksum_type": "sha1",
   920      "iso_checksum": "DE5EE8665048F009577763EFBF4A6F0558833E59"
   921    },
   922    "builders": [
   923      {
   924        "vm_name":"{{user `vm_name`}}",
   925        "type": "hyperv-iso",
   926        "disk_size": "{{user `disk_size`}}",
   927        "guest_additions_mode": "disable",
   928        "iso_url": "{{user `iso_url`}}",
   929        "iso_checksum_type": "{{user `iso_checksum_type`}}",
   930        "iso_checksum": "{{user `iso_checksum`}}",
   931        "communicator":"ssh",
   932        "ssh_username": "packer",
   933        "ssh_password": "packer",
   934        "ssh_timeout" : "4h",
   935        "http_directory": "./",
   936        "boot_wait": "5s",
   937        "boot_command": [
   938          "<esc><wait10><esc><esc><enter><wait>",
   939          "set gfxpayload=1024x768<enter>",
   940          "linux /install/vmlinuz ",
   941          "preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/hyperv-taliesins.cfg ",
   942          "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
   943          "hostname={{.Name}} ",
   944          "fb=false debconf/frontend=noninteractive ",
   945          "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
   946          "keyboard-configuration/variant=USA console-setup/ask_detect=false <enter>",
   947          "initrd /install/initrd.gz<enter>",
   948          "boot<enter>"
   949        ],
   950        "shutdown_command": "echo 'packer' | sudo -S -E shutdown -P now",
   951        "ram_size": "{{user `ram_size`}}",
   952        "cpu": "{{user `cpu`}}",
   953        "generation": 2,
   954        "enable_secure_boot": false
   955      }
   956    ]
   957  }
   958  ```
   959  
   960  ### preseed.cfg:
   961  
   962  ``` text
   963  ## Options to set on the command line
   964  d-i debian-installer/locale string en_US.utf8
   965  d-i console-setup/ask_detect boolean false
   966  d-i console-setup/layout string us
   967  
   968  d-i netcfg/get_hostname string nl-ams-basebox3
   969  d-i netcfg/get_domain string unassigned-domain
   970  
   971  d-i time/zone string UTC
   972  d-i clock-setup/utc-auto boolean true
   973  d-i clock-setup/utc boolean true
   974  
   975  d-i kbd-chooser/method select American English
   976  
   977  d-i netcfg/wireless_wep string
   978  
   979  d-i base-installer/kernel/override-image string linux-server
   980  
   981  d-i debconf debconf/frontend select Noninteractive
   982  
   983  d-i pkgsel/install-language-support boolean false
   984  tasksel tasksel/first multiselect standard, ubuntu-server
   985  
   986  ## Partitioning
   987  d-i partman-auto/method string lvm
   988  
   989  d-i partman-lvm/confirm boolean true
   990  d-i partman-lvm/device_remove_lvm boolean true
   991  d-i partman-lvm/confirm boolean true
   992  
   993  d-i partman-auto-lvm/guided_size string max
   994  d-i partman-auto/choose_recipe select atomic
   995  
   996  d-i partman/confirm_write_new_label boolean true
   997  d-i partman/choose_partition select finish
   998  d-i partman/confirm boolean true
   999  d-i partman/confirm_nooverwrite boolean true
  1000  
  1001  # Write the changes to disks and configure LVM?
  1002  d-i partman-lvm/confirm boolean true
  1003  d-i partman-lvm/confirm_nooverwrite boolean true
  1004  
  1005  d-i partman-partitioning/no_bootable_gpt_biosgrub boolean false
  1006  d-i partman-partitioning/no_bootable_gpt_efi boolean false
  1007  d-i partman-efi/non_efi_system boolean true
  1008  
  1009  # Default user
  1010  d-i passwd/user-fullname string packer
  1011  d-i passwd/username string packer
  1012  d-i passwd/user-password password packer
  1013  d-i passwd/user-password-again password packer
  1014  d-i user-setup/encrypt-home boolean false
  1015  d-i user-setup/allow-password-weak boolean true
  1016  
  1017  # Minimum packages
  1018  d-i pkgsel/include string openssh-server ntp linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) linux-cloud-tools-common
  1019  
  1020  # Upgrade packages after debootstrap? (none, safe-upgrade, full-upgrade)
  1021  # (note: set to none for speed)
  1022  d-i pkgsel/upgrade select none
  1023  
  1024  d-i grub-installer/only_debian boolean true
  1025  d-i grub-installer/with_other_os boolean true
  1026  d-i finish-install/reboot_in_progress note
  1027  
  1028  d-i pkgsel/update-policy select none
  1029  
  1030  choose-mirror-bin mirror/http/proxy string
  1031  ```