Hyper-V VMCX: Fix long lines

This commit is contained in:
DanHam 2018-06-14 16:36:24 +01:00
parent 647aef9855
commit 9f528d6eb7
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 95 additions and 86 deletions

View File

@ -12,20 +12,21 @@ page_title: "Hyper-V Builder (from an vmcx)"
Type: `hyperv-vmcx`
The Hyper-V Packer builder is able to use exported virtual machines or clone existing
The Hyper-V Packer builder is able to use exported virtual machines or clone
existing
[Hyper-V](https://www.microsoft.com/en-us/server-cloud/solutions/virtualization.aspx)
virtual machines.
The builder imports a virtual machine or clones an existing virtual machine boots it,
and provisioning software within the OS, then shutting it down. The result of the
Hyper-V builder is a directory containing all the files necessary to run the virtual
machine portably.
The builder imports a virtual machine or clones an existing virtual machine
boots it, and provisioning software within the OS, then shutting it down. The
result of the Hyper-V builder is a directory containing all the files
necessary to run the virtual machine portably.
## Basic Example
Here is a basic example. This example is not functional. It will start the
OS installer but then fail because we don't provide the preseed file for
Ubuntu to self-install. Still, the example serves to show the basic configuration:
Here is a basic example. This example is not functional. It will start the OS
installer but then fail because we don't provide the preseed file for Ubuntu
to self-install. Still, the example serves to show the basic configuration:
Import from folder:
@ -57,13 +58,13 @@ provisioner might not be saved.
## Configuration Reference
There are many configuration options available for the Hyper-V builder.
They are organized below into two categories: required and optional. Within
each category, the available options are alphabetized and described.
There are many configuration options available for the Hyper-V builder. They
are organized below into two categories: required and optional. Within each
category, the available options are alphabetized and described.
In addition to the options listed here, a
[communicator](/docs/templates/communicator.html)
can be configured for this builder.
[communicator](/docs/templates/communicator.html) can be configured for this
builder.
### Required for virtual machine import:
@ -83,11 +84,11 @@ can be configured for this builder.
machine is cloned.
- `boot_command` (array of strings) - This is an array of commands to type
when the virtual machine is first booted. The goal of these commands should
be to type just enough to initialize the operating system installer.
Special keys can be typed as well, and are covered in the section below on
the boot command. If this is not specified, it is assumed the installer
will start itself.
when the virtual machine is first booted. The goal of these commands
should be to type just enough to initialize the operating system
installer. Special keys can be typed as well, and are covered in the
section below on the boot command. If this is not specified, it is assumed
the installer will start itself.
- `boot_wait` (string) - The time to wait after booting the initial virtual
machine before typing the `boot_command`. The value of this should be
@ -98,39 +99,42 @@ can be configured for this builder.
- `cpu` (number) - The number of cpus the virtual machine should use. If
this isn't specified, the default is 1 cpu.
- `enable_dynamic_memory` (boolean) - If true enable dynamic memory for virtual
machine. This defaults to false.
- `enable_dynamic_memory` (boolean) - If true enable dynamic memory for
virtual machine. This defaults to false.
- `enable_mac_spoofing` (boolean) - If true enable mac spoofing for virtual
machine. This defaults to false.
- `enable_secure_boot` (boolean) - If true enable secure boot for virtual machine. This defaults to false.
- `enable_secure_boot` (boolean) - If true enable secure boot for virtual
machine. This defaults to false.
- `secure_boot_template` (string) - The secure boot template to be configured. Valid values are "MicrosoftWindows" (Windows) or
"MicrosoftUEFICertificateAuthority" (Linux). This only takes effect if enable_secure_boot is set to "true". This defaults to "MicrosoftWindows".
- `secure_boot_template` (string) - The secure boot template to be
configured. Valid values are "MicrosoftWindows" (Windows) or
"MicrosoftUEFICertificateAuthority" (Linux). This only takes effect if
enable_secure_boot is set to "true". This defaults to "MicrosoftWindows".
- `enable_virtualization_extensions` (boolean) - If true enable virtualization
extensions for virtual machine. This defaults to false. For nested
virtualization you need to enable mac spoofing, disable dynamic memory and
have at least 4GB of RAM for virtual machine.
- `enable_virtualization_extensions` (boolean) - If true enable
virtualization extensions for virtual machine. This defaults to false. For
nested virtualization you need to enable mac spoofing, disable dynamic
memory and have at least 4GB of RAM for virtual machine.
- `floppy_files` (array of strings) - A list of files to place onto a floppy
disk that is attached when the VM is booted. This is most useful for
unattended Windows installs, which look for an `Autounattend.xml` file on
removable media. By default, no floppy will be attached. All files listed
in this setting get placed into the root directory of the floppy and the
floppy is attached as the first floppy device. Currently, no support exists
for creating sub-directories on the floppy. Wildcard characters (*, ?, and
[]) are allowed. Directory names are also allowed, which will add all the
files found in the directory to the floppy.
floppy is attached as the first floppy device. Currently, no support
exists for creating sub-directories on the floppy. Wildcard characters (*,
?, and []) are allowed. Directory names are also allowed, which will add
all the files found in the directory to the floppy.
- `floppy_dirs` (array of strings) - A list of directories to place onto the
floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
The maximum summary size of all files in the listed directories are the
same as in `floppy_files`.
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are
allowed. The maximum summary size of all files in the listed directories
are the same as in `floppy_files`.
- `guest_additions_mode` (string) - How should guest additions be installed.
If value `attach` then attach iso image with by specified by
@ -140,9 +144,9 @@ can be configured for this builder.
additions.
- `headless` (boolean) - Packer defaults to building Hyper-V virtual
machines by launching a GUI that shows the console of the machine
being built. When this value is set to true, the machine will start without
a console.
machines by launching a GUI that shows the console of the machine being
built. When this value is set to true, the machine will start without a
console.
- `http_directory` (string) - Path to a directory to serve using an HTTP
server. The files in this directory will be available over HTTP that will
@ -154,10 +158,11 @@ can be configured for this builder.
- `http_port_min` and `http_port_max` (number) - These are the minimum and
maximum port to use for the HTTP server started to serve the
`http_directory`. Because Packer often runs in parallel, Packer will choose
a randomly available port in this range to run the HTTP server. If you want
to force the HTTP server to be on one port, make this minimum and maximum
port the same. By default the values are 8000 and 9000, respectively.
`http_directory`. Because Packer often runs in parallel, Packer will
choose a randomly available port in this range to run the HTTP server. If
you want to force the HTTP server to be on one port, make this minimum and
maximum port the same. By default the values are 8000 and 9000,
respectively.
- `iso_checksum` (string) - The checksum for the OS ISO file. Because ISO
files are so large, this is required and Packer will verify it prior to
@ -171,16 +176,16 @@ can be configured for this builder.
from time to time.
- `iso_url` (string) - A URL to the ISO or VHD containing the installation
image. This URL can be either an HTTP URL or a file URL (or path to
a file). If this is an HTTP URL, Packer will download iso and cache it
image. This URL can be either an HTTP URL or a file URL (or path to a
file). If this is an HTTP URL, Packer will download iso and cache it
between runs.
- `iso_urls` (array of strings) - Multiple URLs for the ISO or VHD to
download. Packer will try these in order. If anything goes wrong attempting
to download 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 is
empty and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be
specified.
download. Packer will try these in order. If anything goes wrong
attempting to download 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 is empty and `iso_url` is used. Only one of `iso_url` or
`iso_urls` can be specified.
- `iso_target_extension` (string) - The extension of the iso file after
download. This defaults to "iso".
@ -199,23 +204,23 @@ can be configured for this builder.
- `ram_size` (number) - The size, in megabytes, of the ram to create for the
VM. By default, this is 1 GB.
* `secondary_iso_images` (array of strings) - A list of iso paths to attached
to a VM when it is booted. This is most useful for unattended Windows
installs, which look for an `Autounattend.xml` file on removable media. By
default, no secondary iso will be attached.
* `secondary_iso_images` (array of strings) - A list of iso paths to
attached to a VM when it is booted. This is most useful for unattended
Windows installs, which look for an `Autounattend.xml` file on removable
media. By default, no secondary iso will be attached.
- `shutdown_command` (string) - The command to use to gracefully shut down
the machine once all the provisioning is done. By default this is an empty
string, which tells Packer to just forcefully shut down the machine unless
a shutdown command takes place inside script so this may safely be omitted.
If one or more scripts require a reboot it is suggested to leave this blank
since reboots may fail and specify the final shutdown command in your last
script.
a shutdown command takes place inside script so this may safely be
omitted. If one or more scripts require a reboot it is suggested to leave
this blank since reboots may fail and specify the final shutdown command
in your last script.
- `shutdown_timeout` (string) - The amount of time to wait after executing
the `shutdown_command` for the virtual machine to actually shut down. If it
doesn't shut down in this time, it is an error. By default, the timeout is
"5m", or five minutes.
the `shutdown_command` for the virtual machine to actually shut down. If
it doesn't shut down in this time, it is an error. By default, the timeout
is "5m", or five minutes.
- `skip_compaction` (boolean) - If true skip compacting the hard disk for
virtual machine when exporting. This defaults to false.
@ -226,17 +231,17 @@ can be configured for this builder.
running.
- `switch_vlan_id` (string) - This is the vlan of the virtual switch's
network card. By default none is set. If none is set then a vlan is not set
on the switch's network card. If this value is set it should match the vlan
specified in by `vlan_id`.
network card. By default none is set. If none is set then a vlan is not
set on the switch's network card. If this value is set it should match the
vlan specified in by `vlan_id`.
- `vlan_id` (string) - This is the vlan of the virtual machine's network card
for the new virtual machine. By default none is set. If none is set then
vlans are not set on the virtual machine's network card.
- `vlan_id` (string) - This is the vlan of the virtual machine's network
card for the new virtual machine. By default none is set. If none is set
then vlans are not set on the virtual machine's network card.
- `mac_address` (string) - This allows a specific MAC address to be used on the
default virtual network card. The MAC address must be a string with no
delimiters, for example "0000deadbeef".
- `mac_address` (string) - This allows a specific MAC address to be used on
the default virtual network card. The MAC address must be a string with
no delimiters, for example "0000deadbeef".
- `vm_name` (string) - This is the name of the virtual machine for the new
virtual machine, without the file extension. By default this is
@ -244,22 +249,22 @@ can be configured for this builder.
## Boot Command
The `boot_command` configuration is very important: it specifies the keys
to type when the virtual machine is first booted in order to start the
OS installer. This command is typed after `boot_wait`, which gives the
virtual machine some time to actually load the ISO.
The `boot_command` configuration is very important: it specifies the keys to
type when the virtual machine is first booted in order to start the OS
installer. This command is typed after `boot_wait`, which gives the virtual
machine some time to actually load the ISO.
As documented above, the `boot_command` is an array of strings. The
strings are all typed in sequence. It is an array only to improve readability
within the template.
As documented above, the `boot_command` is an array of strings. The strings
are all typed in sequence. It is an array only to improve readability within
the template.
The boot command is "typed" character for character over the virtual keyboard
to the machine, simulating a human actually typing the keyboard.
<%= partial "partials/builders/boot-command" %>
Example boot command. This is actually a working boot command used to start
an Ubuntu 12.04 installer:
Example boot command. This is actually a working boot command used to start an
Ubuntu 12.04 installer:
```text
[
@ -282,18 +287,22 @@ for the version of Hyper-V that is running.
## Generation 1 vs Generation 2
Floppy drives are no longer supported by generation 2 machines. This requires you to
take another approach when dealing with preseed or answer files. Two possible options
are using virtual dvd drives or using the built in web server.
Floppy drives are no longer supported by generation 2 machines. This requires
you to take another approach when dealing with preseed or answer files. Two
possible options are using virtual dvd drives or using the built in web
server.
When dealing with Windows you need to enable UEFI drives for generation 2 virtual machines.
When dealing with Windows you need to enable UEFI drives for generation 2
virtual machines.
## Creating iso from directory
Programs like mkisofs can be used to create an iso from a directory.
There is a [windows version of mkisofs](http://opensourcepack.blogspot.co.uk/p/cdrtools.html).
Programs like mkisofs can be used to create an iso from a directory. There is
a [windows version of
mkisofs](http://opensourcepack.blogspot.co.uk/p/cdrtools.html).
Example powershell script. This is an actually working powershell script used to create a Windows answer iso:
Example powershell script. This is an actually working powershell script used
to create a Windows answer iso:
```text
$isoFolder = "answer-iso"
@ -855,8 +864,8 @@ Finish proxy after sysprep -->
## Example For Ubuntu Vivid Generation 2
If you are running Windows under virtualization, you may need to create
a virtual switch with an `External` connection type.
If you are running Windows under virtualization, you may need to create a
virtual switch with an `External` connection type.
### Packer config: