Type: hyperv-iso

Microsoft Hyper-V Server 2016 provides new and enhanced features that can help you deliver the scale and performance needs of your mission-critical workloads. The Windows hypervisor technology in Microsoft Hyper-V Server 2016 is the same as what's in the Microsoft Hyper-V role on Windows Server 2016. Free Download Hyper-v Server 2016 iso file Microsoft Hyper-V, codenamed Viridian and formerly known as Windows Server Virtualization, is a native hypervisor; it can create virtual machines on x86-64 systems running Windows.

Hyper V Core Iso Download

The Hyper-V Packer builder is able to createHyper-Vvirtual machines and export them, starting from an ISO image.

The builder builds a virtual machine by creating a new virtual machine fromscratch. Typically, the VM is booted, an OS is installed, and software isprovisioned within the OS. Finally the VM is shut down. The result of theHyper-V builder is a directory containing all the files necessary to runthe virtual machine portably.

» Basic Example

Here is a basic example. This example is not functional. It will start the OSinstaller but then fail because we don't provide the preseed file for Ubuntuto self-install. Still, the example serves to show the basic configuration:

By default Packer will perform a hard power off of a virtual machine.However, when a machine is powered off this way, it is possible thatchanges made to the VMs file system may not be fully synced, possiblyleading to corruption of files or lost changes. As such, it is important toadd a shutdown_command. This tells Packer how to safely shutdown andpower off the VM.

Core

»ISO Configuration Reference

By default, Packer will symlink, download or copy image files to the Packercache into a 'hash($iso_url+$iso_checksum).$iso_target_extension' file.Packer uses hashicorp/go-getter infile mode in order to perform a download.

go-getter supports the following protocols:

Hyper V Core Iso Download For Windows

  • Local files
  • Git
  • Mercurial
  • HTTP
  • Amazon S3

On windows - when referencing a local iso - if packer is running withoutsymlinking rights, the iso will be copied to the cache folder. Read Symlinksin Windows 10! formore info.

»Required:

  • iso_checksum (string) - The checksum for the ISO file or virtual harddrive file. The algorithm to use when computing the checksum can beoptionally specified with iso_checksum_type. When iso_checksum_type isnot set packer will guess the checksumming type based on iso_checksumlength. iso_checksum can be also be a file or an URL, in which caseiso_checksum_type must be set to file; the go-getter will download itand use the first hash found.

  • iso_url (string) - A URL to the ISO containing the installation image orvirtual hard drive (VHD or VHDX) file to clone.

»Optional:

  • iso_checksum_type (string) - The algorithm to be used when computing thechecksum of the file specified in iso_checksum. Currently, valid valuesare ', 'none', 'md5', 'sha1', 'sha256', 'sha512' or 'file'. Since thevalidity of ISO and virtual disk files are typically crucial to asuccessful build, Packer performs a check of any supplied media by default.While setting 'none' will cause Packer to skip this check, corruption oflarge files such as ISOs and virtual hard drives can occur from time totime. As such, skipping this check is not recommended. iso_checksum_typemust be set to file when iso_checksum is an url.

  • iso_checksum_url (string) - A URL to a checksum file containing achecksum for the ISO file. At least one of iso_checksum andiso_checksum_url must be defined. iso_checksum_url will be ignored ifiso_checksum is non empty.

  • iso_target_extension (string) - The extension of the iso file afterdownload. This defaults to iso.

  • iso_target_path (string) - The path where the iso should be saved afterdownload. By default will go in the packer cache, with a hash of theoriginal filename and checksum as its name.

  • iso_urls (array of strings) - Multiple URLs for the ISO to download.Packer will try these in order. If anything goes wrong attempting todownload or while downloading a single URL, it will move on to the next.All URLs must point to the same file (same checksum). By default this isempty and iso_url is used. Only one of iso_url or iso_urls can bespecified.

»Example ISO configurations

go-getter can guess the checksum type based on iso_checksum len.

» Configuration Reference

There are many configuration options available for the Hyper-V builder. Theyare organized below into two categories: required and optional. Within eachcategory, the available options are alphabetized and described.

In addition to the options listed here, acommunicator can be configured for thisbuilder.

» Optional:

  • boot_command (array of strings) - This is an array of commands to typewhen the virtual machine is first booted. The goal of these commandsshould be to type just enough to initialize the operating systeminstaller. Special keys can be typed as well, and are covered in thesection below on the boot command. If this is not specified, it is assumedthe installer will start itself.

  • boot_wait (string) - The time to wait after booting the initial virtualmachine before typing the boot_command. The value specified should bea duration. For example, setting a duration of '1m30s' would causePacker to wait for 1 minute 30 seconds before typing the boot command.The default duration is '10s' (10 seconds).

  • configuration_version (string) - This allows you to set the vm version when calling New-VM to generate the vm.

  • cpus (number) - The number of CPUs the virtual machine should use. Ifthis isn't specified, the default is 1 CPU.

  • differencing_disk (boolean) - If true enables differencing disks. Onlythe changes will be written to the new disk. This is especially useful ifyour source is a VHD/VHDX. This defaults to false.

  • disk_additional_size (array of integers) - The size or sizes of anyadditional hard disks for the VM in megabytes. If this is not specifiedthen the VM will only contain a primary hard disk. Additional driveswill be attached to the SCSI interface only. The builder usesexpandable rather than fixed-size virtual hard disks, so the actualfile representing the disk will not use the full size unless it isfull.

  • disk_block_size (string) - The block size of the VHD to be created.Recommended disk block size for Linux hyper-v guests is 1 MiB. Thisdefaults to '32 MiB'.

  • disk_size (number) - The size, in megabytes, of the hard disk to createfor the VM. By default, this is 40 GB.

  • enable_dynamic_memory (boolean) - If true enable dynamic memory forthe virtual machine. This defaults to false.

  • enable_mac_spoofing (boolean) - If true enable MAC address spoofingfor the virtual machine. This defaults to false.

  • enable_secure_boot (boolean) - If true enable secure boot for thevirtual machine. This defaults to false. See secure_boot_templatebelow for additional settings.

  • enable_virtualization_extensions (boolean) - If true enablevirtualization extensions for the virtual machine. This defaults tofalse. For nested virtualization you need to enable MAC spoofing,disable dynamic memory and have at least 4GB of RAM assigned to thevirtual machine.

  • floppy_dirs (array of strings) - A list of directories to place ontothe floppy disk recursively. This is similar to the floppy_files optionexcept that the directory structure is preserved. This is useful for whenyour floppy disk includes drivers or if you just want to organize it'scontents as a hierarchy. Wildcard characters (*, ?, and []) areallowed. The maximum summary size of all files in the listed directoriesare the same as in floppy_files.

  • floppy_files (array of strings) - A list of files to place onto a floppydisk that is attached when the VM is booted. This is most useful forunattended Windows installs, which look for an Autounattend.xml file onremovable media. By default, no floppy will be attached. All files listedin this setting get placed into the root directory of the floppy and thefloppy is attached as the first floppy device. Currently, no supportexists for creating sub-directories on the floppy. Wildcard characters(*, ?, and []) are allowed. Directory names are also allowed, whichwill add all the files found in the directory to the floppy.

  • generation (number) - The Hyper-V generation for the virtual machine. Bydefault, this is 1. Generation 2 Hyper-V virtual machines do not supportfloppy drives. In this scenario use secondary_iso_images instead. Harddrives and DVD drives will also be SCSI and not IDE.

  • guest_additions_mode (string) - If set to attach then attach andmount the ISO image specified in guest_additions_path. If set tonone then guest additions are not attached and mounted; This is thedefault.

  • guest_additions_path (string) - The path to the ISO image for guestadditions.

  • headless (boolean) - Packer defaults to building Hyper-V virtualmachines by launching a GUI that shows the console of the machine beingbuilt. When this value is set to true, the machine will start without aconsole.

  • http_directory (string) - Path to a directory to serve using Packersinbuilt HTTP server. The files in this directory will be availableover HTTP to the virtual machine. This is useful for hosting kickstartfiles and so on. By default this value is unset and the HTTP server isnot started. The address and port of the HTTP server will be availableas variables in boot_command. This is covered in more detail below.

  • http_port_min and http_port_max (number) - These are the minimum andmaximum port to use for the HTTP server started to serve thehttp_directory. Since Packer often runs in parallel, a randomlyavailable port in this range will be repeatedly chosen until anavailable port is found. To force the HTTP server to use a specificport, set an identical value for http_port_min and http_port_max.By default the values are 8000 and 9000, respectively.

  • mac_address (string) - This allows a specific MAC address to be used onthe default virtual network card. The MAC address must be a string withno delimiters, for example '0000deadbeef'.

  • output_directory (string) - This setting specifies the directory thatartifacts from the build, such as the virtual machine files and disks,will be output to. The path to the directory may be relative orabsolute. If relative, the path is relative to the working directorypacker is executed from. This directory must not exist or, ifcreated, must be empty prior to running the builder. By default this is'output-BUILDNAME' where 'BUILDNAME' is the name of the build.

  • memory (number) - The amount, in megabytes, of RAM to assign to theVM. By default, this is 1 GB.

  • secondary_iso_images (array of strings) - A list of ISO paths toattach to a VM when it is booted. This is most useful for unattendedWindows installs, which look for an Autounattend.xml file on removablemedia. By default, no secondary ISO will be attached.

  • secure_boot_template (string) - The secure boot template to beconfigured. Valid values are 'MicrosoftWindows' (Windows) or'MicrosoftUEFICertificateAuthority' (Linux). This only takes effect ifenable_secure_boot is set to 'true'. This defaults to 'MicrosoftWindows'.

  • shutdown_command (string) - The command to use to gracefully shut downthe machine once all provisioning is complete. By default this is anempty string, which tells Packer to just forcefully shut down themachine. This setting can be safely omitted if for example, a shutdowncommand to gracefully halt the machine is configured inside aprovisioning script. If one or more scripts require a reboot it issuggested to leave this blank (since reboots may fail) and insteadspecify the final shutdown command in your last script.

  • shutdown_timeout (string) - The amount of time to wait after executingthe shutdown_command for the virtual machine to actually shut down.If the machine doesn't shut down in this time it is considered anerror. By default, the time out is '5m' (five minutes).

  • skip_compaction (boolean) - If true skip compacting the hard disk forthe virtual machine when exporting. This defaults to false.

  • skip_export (boolean) - If true Packer will skip the export of the VM.If you are interested only in the VHD/VHDX files, you can enable thisoption. The resulting VHD/VHDX file will be output to<output_directory>/Virtual Hard Disks. By default this option is falseand Packer will export the VM to output_directory.

  • switch_name (string) - The name of the switch to connect the virtualmachine to. By default, leaving this value unset will cause Packer totry and determine the switch to use by looking for an external switchthat is up and running.

  • switch_vlan_id (string) - This is the VLAN of the virtual switch'snetwork card. By default none is set. If none is set then a VLAN is notset on the switch's network card. If this value is set it should matchthe VLAN specified in by vlan_id.

  • temp_path (string) - The location under which Packer will create adirectory to house all the VM files and folders during the build.By default %TEMP% is used which, for most systems, will evaluate to%USERPROFILE%/AppData/Local/Temp.

    The build directory housed under temp_path will have a name similarto packerhv1234567. The seven digit number at the end of the name isautomatically generated by Packer to ensure the directory name isunique.

  • use_fixed_vhd_format (boolean) - If true, creates the boot disk on thevirtual machine as a fixed VHD format disk. The default is false, whichcreates a dynamic VHDX format disk. This option requires settinggeneration to 1, skip_compaction to true, anddifferencing_disk to false. Additionally, any value entered fordisk_block_size will be ignored. The most likely use case for thisoption is outputing a disk that is in the format required for upload toAzure.

  • vlan_id (string) - This is the VLAN of the virtual machine's networkcard for the new virtual machine. By default none is set. If none is setthen VLANs are not set on the virtual machine's network card.

  • vm_name (string) - This is the name of the new virtual machine,without the file extension. By default this is 'packer-BUILDNAME',where 'BUILDNAME' is the name of the build.

  • use_legacy_network_adapter (bool) - If true use a legacy network adapter as the NIC.This defaults to false. A legacy network adapter is fully emulated NIC, and is thussupported by various exotic operating systems, but this emulation requiresadditional overhead and should only be used if absolutely necessary.

» Boot Command

The boot_command configuration is very important: it specifies the keys totype when the virtual machine is first booted in order to start the OSinstaller. This command is typed after boot_wait, which gives the virtualmachine some time to actually load the ISO.

As documented above, the boot_command is an array of strings. The stringsare all typed in sequence. It is an array only to improve readability withinthe template.

The boot command is 'typed' character for character over the virtual keyboardto the machine, simulating a human actually typing the keyboard.

There are a set of special keys available. If these are in your bootcommand, they will be replaced by the proper key:

  • <bs> - Backspace

  • <del> - Delete

  • <enter> <return> - Simulates an actual 'enter' or 'return' keypress.

  • <esc> - Simulates pressing the escape key.

  • <tab> - Simulates pressing the tab key.

  • <f1> - <f12> - Simulates pressing a function key.

  • <up> <down> <left> <right> - Simulates pressing an arrow key.

  • <spacebar> - Simulates pressing the spacebar.

  • <insert> - Simulates pressing the insert key.

  • <home> <end> - Simulates pressing the home and end keys.

  • <pageUp> <pageDown> - Simulates pressing the page up and page down keys.

  • <menu> - Simulates pressing the Menu key.

  • <leftAlt> <rightAlt> - Simulates pressing the alt key.

  • <leftCtrl> <rightCtrl> - Simulates pressing the ctrl key.

  • <leftShift> <rightShift> - Simulates pressing the shift key.

  • <leftSuper> <rightSuper> - Simulates pressing the ⌘ or Windows key.

  • <wait> <wait5> <wait10> - Adds a 1, 5 or 10 second pause beforesending any additional keys. This is useful if you have to generally waitfor the UI to update before typing more.

  • <waitXX> - Add an arbitrary pause before sending any additional keys. Theformat of XX is a sequence of positive decimal numbers, each withoptional fraction and a unit suffix, such as 300ms, 1.5h or 2h45m.Valid time units are ns, us (or µs), ms, s, m, h. For example<wait10m> or <wait1m20s>

»On/Off variants

Any printable keyboard character, and of these 'special' expressions, with theexception of the <wait> types, can also be toggled on or off. For example, tosimulate ctrl+c, use <leftCtrlOn>c<leftCtrlOff>. Be sure to release them,otherwise they will be held down until the machine reboots.

To hold the c key down, you would use <cOn>. Likewise, <cOff> to release.

»Templates inside boot command

In addition to the special keys, each command to type is treated as atemplate engine. Theavailable variables are:

  • HTTPIP and HTTPPort - The IP and port, respectively of an HTTP serverthat is started serving the directory specified by the http_directoryconfiguration parameter. If http_directory isn't specified, these will beblank!
  • Name - The name of the VM.

For more examples of various boot commands, see the sample projects from ourcommunity templates page.

The example shown below is a working boot command used to start an Ubuntu12.04 installer:

For more examples of various boot commands, see the sample projects from ourcommunity templates page.

» Integration Services

Packer will automatically attach the integration services ISO as a DVD drivefor the version of Hyper-V that is running.

» Generation 1 vs Generation 2

Floppy drives are no longer supported by generation 2 machines. This requiresyou to take another approach when dealing with preseed or answer files. Twopossible options are using virtual DVD drives or using Packers built in webserver.

When dealing with Windows you need to enable UEFI drives for generation 2virtual machines.

» Creating an ISO From a Directory

Mount Iso Hyper V

Programs like mkisofs can be used to create an ISO from a directory. There isa windows version ofmkisofs available.

Below is a working PowerShell script that can be used to create a Windowsanswer ISO:

» Example For Windows Server 2012 R2 Generation 2

Packer config:

autounattend.xml:

sysprep-unattend.xml:

Warning: Please note that if you're setting up WinRM for provisioning, you'll probably want to turn it off or restrict its permissions as part of a shutdown script at the end of Packer's provisioning process. For more details on the why/how, check out this useful blog post and the associated code:https://cloudywindows.io/post/winrm-for-provisioning---close-the-door-on-the-way-out-eh/

» Example For Ubuntu Vivid Generation 2

Hyper-v Iso Download

If you are running Windows under virtualization, you may need to create avirtual switch with an External connection type.

Hyper-v Server Iso

» Packer config:

Hyper V 2016 Core Iso Download

» preseed.cfg: